Add: lowest is prefered app - highest record, ranking sorting sequence
This commit is contained in:
@@ -43,7 +43,7 @@
|
||||
<script src="../../game/result/history_board.js"></script>
|
||||
<script src="../../game/result/ranking_board.js"></script>
|
||||
<script src="../../game/result/record_board.js"></script>
|
||||
<script src="../../game/result/result.js?update_date=191225"></script>
|
||||
<script src="../../game/result/result.js?update_date=190510"></script>
|
||||
<script src="../../game/result/main.js"></script>
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
function is_highest_record_prefer_app($app_id) {
|
||||
if($app_id == 105)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -3,6 +3,7 @@ header('Content-Type: application/json');
|
||||
|
||||
include "./../lib/send_reply_json.php";
|
||||
include "./../setup/connect_db.php";
|
||||
include "./../lib/util_app.php";
|
||||
|
||||
$maestroID = $_POST["MaestroID"];
|
||||
$appID = $_POST["AppID"];
|
||||
@@ -27,8 +28,12 @@ function get_ranking_hour($maestroID, $appID) {
|
||||
FROM best_record BR, player P
|
||||
WHERE BR.PlayerID = P.PlayerID AND DATE(BR.RecordDateTime) = DATE(NOW()) AND HOUR(BR.RecordDateTime) = HOUR(NOW()) AND BR.MaestroID = ? AND BR.AppID = ?
|
||||
GROUP BY BR.PlayerID
|
||||
ORDER BY max(BR.BestRecord) DESC;
|
||||
ORDER BY max(BR.BestRecord)
|
||||
";
|
||||
if(is_highest_record_prefer_app($appID))
|
||||
$query = $query." DESC;";
|
||||
else
|
||||
$query = $query." ASC;";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('ii', $maestroID, $appID);
|
||||
$stmt->execute();
|
||||
@@ -52,8 +57,12 @@ function get_ranking_day($maestroID, $appID) {
|
||||
FROM best_record BR, player P
|
||||
WHERE BR.PlayerID = P.PlayerID AND DATE(BR.RecordDateTime) = DATE(NOW()) AND BR.MaestroID = ? AND BR.AppID = ?
|
||||
GROUP BY BR.PlayerID
|
||||
ORDER BY max(BR.BestRecord) DESC;
|
||||
ORDER BY max(BR.BestRecord)
|
||||
";
|
||||
if(is_highest_record_prefer_app($appID))
|
||||
$query = $query." DESC;";
|
||||
else
|
||||
$query = $query." ASC;";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('ii', $maestroID, $appID);
|
||||
$stmt->execute();
|
||||
@@ -77,8 +86,12 @@ function get_ranking_month($maestroID, $appID) {
|
||||
FROM best_record BR, player P
|
||||
WHERE BR.PlayerID = P.PlayerID AND MONTH(BR.RecordDateTime) = MONTH(NOW()) AND BR.MaestroID = ? AND BR.AppID = ?
|
||||
GROUP BY BR.PlayerID
|
||||
ORDER BY max(BR.BestRecord) DESC;
|
||||
ORDER BY max(BR.BestRecord)
|
||||
";
|
||||
if(is_highest_record_prefer_app($appID))
|
||||
$query = $query." DESC;";
|
||||
else
|
||||
$query = $query." ASC;";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('ii', $maestroID, $appID);
|
||||
$stmt->execute();
|
||||
|
||||
@@ -7,6 +7,7 @@ $date = $_POST["Date"];
|
||||
$time = $_POST["Time"];
|
||||
|
||||
include "./../setup/connect_db.php";
|
||||
include "./../lib/util_app.php";
|
||||
|
||||
|
||||
$replyJSON = get_ranking_record_day($maestro_id, $date, $app_id);
|
||||
@@ -28,8 +29,12 @@ function get_ranking_record_day($maestro_id, $date, $app_id) {
|
||||
FROM best_record BR, player U
|
||||
WHERE BR.MaestroID = ? AND BR.playerID = U.playerID AND DATE(BR.RecordDateTime) = ? AND AppID = ?
|
||||
GROUP BY BR.playerID
|
||||
ORDER BY max(BR.BestRecord) DESC;
|
||||
ORDER BY max(BR.BestRecord)
|
||||
";
|
||||
if(is_highest_record_prefer_app($app_id))
|
||||
$query = $query." DESC;";
|
||||
else
|
||||
$query = $query." ASC;";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('isi', $maestro_id, $date, $app_id);
|
||||
$stmt->execute();
|
||||
|
||||
@@ -7,6 +7,7 @@ $date = $_POST["Date"];
|
||||
$time = $_POST["Time"];
|
||||
|
||||
include "./../setup/connect_db.php";
|
||||
include "./../lib/util_app.php";
|
||||
|
||||
|
||||
$replyJSON = get_ranking_record_hour($maestro_id, $date, $time, $app_id);
|
||||
@@ -27,8 +28,12 @@ function get_ranking_record_hour($maestro_id, $date, $time, $app_id) {
|
||||
FROM best_record BR, player U
|
||||
WHERE BR.MaestroID = ? AND BR.playerID = U.playerID AND DATE(BR.RecordDateTime) = ? AND HOUR(BR.RecordDateTime) = HOUR(?) AND AppID = ?
|
||||
GROUP BY BR.playerID
|
||||
ORDER BY max(BR.BestRecord) DESC;
|
||||
ORDER BY max(BR.BestRecord)
|
||||
";
|
||||
if(is_highest_record_prefer_app($app_id))
|
||||
$query = $query." DESC;";
|
||||
else
|
||||
$query = $query." ASC;";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('issi', $maestro_id, $date, $time, $app_id);
|
||||
$stmt->execute();
|
||||
|
||||
@@ -7,6 +7,7 @@ $date = $_POST["Date"];
|
||||
$time = $_POST["Time"];
|
||||
|
||||
include "./../setup/connect_db.php";
|
||||
include "./../lib/util_app.php";
|
||||
|
||||
|
||||
$replyJSON = get_ranking_record_month($maestro_id, $date, $time, $app_id);
|
||||
@@ -28,8 +29,12 @@ function get_ranking_record_month($maestro_id, $date, $time, $app_id) {
|
||||
FROM best_record BR, player U
|
||||
WHERE BR.MaestroID = ? AND BR.playerID = U.playerID AND MONTH(BR.RecordDateTime) = MONTH(?) AND AppID = ?
|
||||
GROUP BY BR.playerID
|
||||
ORDER BY max(BR.BestRecord) DESC;
|
||||
ORDER BY max(BR.BestRecord)
|
||||
";
|
||||
if(is_highest_record_prefer_app($app_id))
|
||||
$query = $query." DESC;";
|
||||
else
|
||||
$query = $query." ASC;";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('isi', $maestro_id, $date, $app_id);
|
||||
$stmt->execute();
|
||||
|
||||
@@ -9,7 +9,7 @@ $record = $_POST["Record"];
|
||||
|
||||
include "./../setup/connect_db.php";
|
||||
include "./../lib/app_highest_record.php";
|
||||
|
||||
include "./../lib/util_app.php";
|
||||
|
||||
// best record is for the saved data by every hour
|
||||
$prev_best_record_id = -1;
|
||||
@@ -23,9 +23,16 @@ if($prev_best_record_id === null || $prev_best_record_id < 0) {
|
||||
insert_best_record($maestro_id, $app_id, $player_id, $record);
|
||||
} else {
|
||||
echo $record." ".$prev_best_record;
|
||||
if($record > $prev_best_record) {
|
||||
echo "update";
|
||||
update_best_record($prev_best_record_id, $record);
|
||||
if(is_highest_record_prefer_app($app_id)) {
|
||||
if($record > $prev_best_record) {
|
||||
echo "update";
|
||||
update_best_record($prev_best_record_id, $record);
|
||||
}
|
||||
} else {
|
||||
if($record < $prev_best_record) {
|
||||
echo "update";
|
||||
update_best_record($prev_best_record_id, $record);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,12 +44,22 @@ echo "\napp_highest_record : $app_highest_record";
|
||||
if($app_highest_record == null) {
|
||||
insert_app_highest_record($maestro_id, $app_id, $player_id, $record);
|
||||
// echo "\ninsert_app_highest_record : $record";
|
||||
}
|
||||
else if($record > $app_highest_record) {
|
||||
remove_app_highest_record($maestro_id, $app_id, $player_id);
|
||||
// echo "\nremove_app_highest_record";
|
||||
insert_app_highest_record($maestro_id, $app_id, $player_id, $record);
|
||||
// echo "\ninsert_app_highest_record : $record";
|
||||
} else {
|
||||
if(is_highest_record_prefer_app($app_id)) {
|
||||
if($record > $app_highest_record) {
|
||||
remove_app_highest_record($maestro_id, $app_id, $player_id);
|
||||
// echo "\nremove_app_highest_record";
|
||||
insert_app_highest_record($maestro_id, $app_id, $player_id, $record);
|
||||
// echo "\ninsert_app_highest_record : $record";
|
||||
}
|
||||
} else {
|
||||
if($record < $app_highest_record) {
|
||||
remove_app_highest_record($maestro_id, $app_id, $player_id);
|
||||
// echo "\nremove_app_highest_record";
|
||||
insert_app_highest_record($maestro_id, $app_id, $player_id, $record);
|
||||
// echo "\ninsert_app_highest_record : $record";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$db_conn->close();
|
||||
|
||||
Reference in New Issue
Block a user