Add: lowest is prefered app - highest record, ranking sorting sequence

This commit is contained in:
2019-05-10 11:09:07 +09:00
parent 6fb0872269
commit 20dfb711eb
12 changed files with 145 additions and 64 deletions
+16 -3
View File
@@ -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();