Fix: ranking_record_hour, day, month SQL bug
This commit is contained in:
@@ -26,7 +26,7 @@ function get_ranking_record_day($maestro_id, $date, $app_id) {
|
||||
|
||||
$query = "
|
||||
FROM best_record BR, player U
|
||||
WHERE BR.MaestroID = ? AND BR.playerID = U.playerID AND DATE(BR.RecordDateTime) = ? AND AppID = ?
|
||||
WHERE BR.MaestroID = ? AND BR.playerID = U.playerID AND YEAR(BR.RecordDateTime) = YEAR(?) AND MONTH(BR.RecordDateTime) = MONTH(?) AND DAYOFMONTH(BR.RecordDateTime) = DAYOFMONTH(?) AND AppID = ?
|
||||
GROUP BY BR.playerID
|
||||
";
|
||||
if(is_highest_record_prefer_app($app_id)) {
|
||||
@@ -37,7 +37,7 @@ function get_ranking_record_day($maestro_id, $date, $app_id) {
|
||||
$query = $query."ORDER BY MIN(BR.BestRecord) ASC;";
|
||||
}
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('isi', $maestro_id, $date, $app_id);
|
||||
$stmt->bind_param('isssi', $maestro_id, $date, $date, $date, $app_id);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($playerID, $name, $high_score);
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ function get_ranking_record_hour($maestro_id, $date, $time, $app_id) {
|
||||
|
||||
$query = "
|
||||
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 = ?
|
||||
WHERE BR.MaestroID = ? AND BR.playerID = U.playerID AND YEAR(BR.RecordDateTime) = YEAR(?) AND MONTH(BR.RecordDateTime) = MONTH(?) AND DAYOFMONTH(BR.RecordDateTime) = DAYOFMONTH(?) AND HOUR(BR.RecordDateTime) = HOUR(?) AND AppID = ?
|
||||
GROUP BY BR.playerID
|
||||
";
|
||||
if(is_highest_record_prefer_app($app_id)) {
|
||||
@@ -37,7 +37,7 @@ function get_ranking_record_hour($maestro_id, $date, $time, $app_id) {
|
||||
$query = $query."ORDER BY MIN(BR.BestRecord) ASC;";
|
||||
}
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('issi', $maestro_id, $date, $time, $app_id);
|
||||
$stmt->bind_param('issssi', $maestro_id, $date, $date, $date, $time, $app_id);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($playerID, $name, $high_score);
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ function get_ranking_record_month($maestro_id, $date, $time, $app_id) {
|
||||
|
||||
$query = "
|
||||
FROM best_record BR, player U
|
||||
WHERE BR.MaestroID = ? AND BR.playerID = U.playerID AND MONTH(BR.RecordDateTime) = MONTH(?) AND AppID = ?
|
||||
WHERE BR.MaestroID = ? AND BR.playerID = U.playerID AND YEAR(BR.RecordDateTime) = YEAR(?) AND MONTH(BR.RecordDateTime) = MONTH(?) AND AppID = ?
|
||||
GROUP BY BR.playerID
|
||||
";
|
||||
if(is_highest_record_prefer_app($app_id)) {
|
||||
@@ -37,7 +37,7 @@ function get_ranking_record_month($maestro_id, $date, $time, $app_id) {
|
||||
$query = $query."ORDER BY MIN(BR.BestRecord) ASC;";
|
||||
}
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('isi', $maestro_id, $date, $app_id);
|
||||
$stmt->bind_param('issi', $maestro_id, $date, $date, $app_id);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($playerID, $name, $high_score);
|
||||
|
||||
|
||||
+29
@@ -121,6 +121,35 @@ QUnit.test( "App ranking", function( assert ) {
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
// #3 Day 2019-08-23
|
||||
let date4 = "2019-08-23";
|
||||
let time4 = "16:53:00";
|
||||
|
||||
let done4 = assert.async();
|
||||
setTimeout(function() {
|
||||
dbConnectManager.requestRanking(
|
||||
DBConnectManager.TYPE_MY_RANKING_MONTH,
|
||||
sessionStorageManager.getMaestroID(),
|
||||
date4,
|
||||
time4,
|
||||
(type, rankingRecordManager) => {
|
||||
assert.equal(rankingRecordManager.getCount(), 0, "no data");
|
||||
// assert.equal(rankingRecordManager.getRankAt(0), 1, "day - rank #3");
|
||||
// assert.equal(rankingRecordManager.getBestRecordAt(0), 99.18, "day - best record");
|
||||
// assert.equal(rankingRecordManager.getPlayerIDAt(0), 46, "day - player ID");
|
||||
// assert.equal(rankingRecordManager.getPlayerNameAt(0), "강예원", "day - player name");
|
||||
|
||||
// assert.equal(rankingRecordManager.getRankAt(5), 6, "day - rank");
|
||||
// assert.equal(rankingRecordManager.getBestRecordAt(5), 94.48, "day - best record");
|
||||
// assert.equal(rankingRecordManager.getPlayerIDAt(5), 57, "day - player ID");
|
||||
// assert.equal(rankingRecordManager.getPlayerNameAt(5), "고울", "day - player name");
|
||||
|
||||
done4();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user