Fix: get ranking with date, time
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
class DateUtil {
|
||||
|
||||
static getYYYYMMDD(date) {
|
||||
return date.toISOString().slice(0,10);
|
||||
}
|
||||
|
||||
static getHHMMSS(date) {
|
||||
return StringUtil.getNumberStartWithZero(date.getHours(), 2) + ":"
|
||||
+ StringUtil.getNumberStartWithZero(date.getMinutes(), 2) + ":"
|
||||
+ StringUtil.getNumberStartWithZero(date.getSeconds(), 2);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -140,7 +140,7 @@ class DBConnectManager {
|
||||
*/
|
||||
}
|
||||
|
||||
requestRanking(type, listener) {
|
||||
requestRanking(type, date, time, listener) {
|
||||
let rankingRecordManager = new RankingRecordManager();
|
||||
|
||||
/*
|
||||
@@ -171,7 +171,9 @@ class DBConnectManager {
|
||||
}
|
||||
};
|
||||
let params = "UserID=" + sessionStorageManager.playerUserID
|
||||
+ "&AppName=" + sessionStorageManager.playingAppName;
|
||||
+ "&AppName=" + sessionStorageManager.playingAppName
|
||||
+ "&Date=" + date
|
||||
+ "&Time=" + time;
|
||||
xhr.send(params);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,4 +20,9 @@ class StringUtil {
|
||||
return numberWithCommas + " 점";
|
||||
}
|
||||
|
||||
static getNumberStartWithZero(number, digitCount) {
|
||||
let n = number + '';
|
||||
return n.length >= digitCount ? n : new Array(digitCount - n.length + 1).join('0') + n;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,7 +13,10 @@ class RankingBoard {
|
||||
|
||||
|
||||
requestRanking(type, rankingRecordManager) {
|
||||
this.dbConnectManager.requestRanking(type, (type, rankingRecordManager) => {
|
||||
let today = new Date();
|
||||
let date = DateUtil.getYYYYMMDD(today);
|
||||
let time = DateUtil.getHHMMSS(today);
|
||||
this.dbConnectManager.requestRanking(type, date, time, (type, rankingRecordManager) => {
|
||||
let beginIndex = this.getBeginIndex(rankingRecordManager);
|
||||
let endIndex = this.getEndIndex(rankingRecordManager);
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
<!-- library source files -->
|
||||
<script src="../../game/lib/number_util.js"></script>
|
||||
<script src="../../game/lib/string_util.js"></script>
|
||||
<script src="../../game/lib/date_util.js"></script>
|
||||
<script src="../../game/lib/history_record_manager.js"></script>
|
||||
<script src="../../game/lib/ranking_record_manager.js"></script>
|
||||
<script src="../../game/lib/db_connect_manager.js"></script>
|
||||
|
||||
@@ -5,6 +5,8 @@ include "./../lib/send_error_code.php";
|
||||
|
||||
$user_id = $_POST["UserID"];
|
||||
$app_name = $_POST["AppName"];
|
||||
$date = $_POST["Date"];
|
||||
$time = $_POST["Time"];
|
||||
|
||||
include "./../setup/connect_db.php";
|
||||
|
||||
@@ -19,6 +21,7 @@ $query = "
|
||||
ORDER BY max(D.Score) DESC;
|
||||
";
|
||||
*/
|
||||
/*
|
||||
$query = "
|
||||
SELECT D.userID As UserID, U.Name AS Name, MAX(D.Score) AS HighScore
|
||||
FROM moty_record D, moty_user U
|
||||
@@ -26,8 +29,16 @@ $query = "
|
||||
GROUP BY D.userID
|
||||
ORDER BY max(D.Score) DESC;
|
||||
";
|
||||
*/
|
||||
$query = "
|
||||
SELECT D.userID As UserID, U.Name AS Name, MAX(D.Score) AS HighScore
|
||||
FROM moty_record D, moty_user U
|
||||
WHERE D.userID = U.userID AND DATE(D.DateTime) = DATE(?) AND AppName = ?
|
||||
GROUP BY D.userID
|
||||
ORDER BY max(D.Score) DESC;
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('s', $app_name);
|
||||
$stmt->bind_param('ss', $date, $app_name);
|
||||
$stmt->execute();
|
||||
|
||||
$stmt->bind_result($userID, $name, $high_score);
|
||||
|
||||
@@ -5,6 +5,8 @@ include "./../lib/send_error_code.php";
|
||||
|
||||
$user_id = $_POST["UserID"];
|
||||
$app_name = $_POST["AppName"];
|
||||
$date = $_POST["Date"];
|
||||
$time = $_POST["Time"];
|
||||
|
||||
include "./../setup/connect_db.php";
|
||||
|
||||
@@ -19,15 +21,24 @@ $query = "
|
||||
ORDER BY max(D.Score) DESC;
|
||||
";
|
||||
*/
|
||||
/*
|
||||
$query = "
|
||||
SELECT D.userID As UserID, U.Name AS Name, MAX(D.Score) AS HighScore
|
||||
FROM moty_record D, moty_user U
|
||||
WHERE D.userID = U.userID AND DATE(D.DateTime) = DATE('2018-05-16') AND HOUR(D.DateTime) = HOUR('13:05:05') AND AppName = 'korean_word'
|
||||
WHERE D.userID = U.userID AND DATE(D.DateTime) = DATE('?') AND HOUR(D.DateTime) = HOUR('?') AND AppName = '?'
|
||||
GROUP BY D.userID
|
||||
ORDER BY max(D.Score) DESC;
|
||||
";
|
||||
*/
|
||||
$query = "
|
||||
SELECT D.userID As UserID, U.Name AS Name, MAX(D.Score) AS HighScore
|
||||
FROM moty_record D, moty_user U
|
||||
WHERE D.userID = U.userID AND DATE(D.DateTime) = DATE(?) AND HOUR(D.DateTime) = HOUR(?) AND AppName = ?
|
||||
GROUP BY D.userID
|
||||
ORDER BY max(D.Score) DESC;
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('s', $app_name);
|
||||
$stmt->bind_param('sss', $date, $time, $app_name);
|
||||
$stmt->execute();
|
||||
|
||||
$stmt->bind_result($userID, $name, $high_score);
|
||||
|
||||
@@ -5,6 +5,8 @@ include "./../lib/send_error_code.php";
|
||||
|
||||
$user_id = $_POST["UserID"];
|
||||
$app_name = $_POST["AppName"];
|
||||
$date = $_POST["Date"];
|
||||
$time = $_POST["Time"];
|
||||
|
||||
include "./../setup/connect_db.php";
|
||||
|
||||
@@ -19,6 +21,7 @@ $query = "
|
||||
ORDER BY max(D.Score) DESC;
|
||||
";
|
||||
*/
|
||||
/*
|
||||
$query = "
|
||||
SELECT D.userID As UserID, U.Name AS Name, MAX(D.Score) AS HighScore
|
||||
FROM moty_record D, moty_user U
|
||||
@@ -26,8 +29,16 @@ $query = "
|
||||
GROUP BY D.userID
|
||||
ORDER BY max(D.Score) DESC;
|
||||
";
|
||||
*/
|
||||
$query = "
|
||||
SELECT D.userID As UserID, U.Name AS Name, MAX(D.Score) AS HighScore
|
||||
FROM moty_record D, moty_user U
|
||||
WHERE D.userID = U.userID AND MONTH(D.DateTime) = MONTH(?) AND AppName = ?
|
||||
GROUP BY D.userID
|
||||
ORDER BY max(D.Score) DESC;
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('s', $app_name);
|
||||
$stmt->bind_param('ss', $date, $app_name);
|
||||
$stmt->execute();
|
||||
|
||||
$stmt->bind_result($userID, $name, $high_score);
|
||||
|
||||
Reference in New Issue
Block a user