Fix: get db data with date, time

This commit is contained in:
2018-05-24 20:48:22 +09:00
parent 82e290db86
commit 4863a8d3f1
7 changed files with 75 additions and 51 deletions
+5 -2
View File
@@ -64,7 +64,7 @@ class DBConnectManager {
xhr.send("name=" + userName + "&enter_code=" + enterCode);
}
requestPlayerHistory(listener) {
requestPlayerHistory(date, listener) {
let historyRecordManager = new HistoryRecordManager();
/*
@@ -94,7 +94,10 @@ class DBConnectManager {
onFailedListener(jsonData);
}
};
xhr.send("UserID=" + sessionStorageManager.playerUserID + "&AppName=" + sessionStorageManager.playingAppName);
let params = "UserID=" + sessionStorageManager.playerUserID
+ "&AppName=" + sessionStorageManager.playingAppName
+ "&Date=" + date;
xhr.send(params);
}
parseJSONtoHistoryRecord(json) {
+21 -11
View File
@@ -13,20 +13,30 @@ class HistoryBoard {
this.textMyRanking = game.add.text(posX, posY + 100, '', arrayTabStyle)
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
this.dbConnectManager.requestPlayerHistory( historyRecordManager => {
let maxIndex = historyRecordManager.count - 1;
if(maxIndex > 6)
maxIndex = 6;
let today = new Date();
let date = DateUtil.getYYYYMMDD(today);
this.dbConnectManager.requestPlayerHistory(
date,
historyRecordManager => {
if(historyRecordManager.count == 0) {
console.log("history board - no data");
return;
}
for(let i = 0; i < historyRecordManager.count; i++) {
if(i > 6)
break;
let maxIndex = historyRecordManager.count - 1;
if(maxIndex > 6)
maxIndex = 6;
let data = historyRecordManager.getAt(maxIndex);
this.printRecord(i, data.date, data.score);
maxIndex--;
for(let i = 0; i < historyRecordManager.count; i++) {
if(i > 6)
break;
let data = historyRecordManager.getAt(maxIndex);
this.printRecord(i, data.date, data.score);
maxIndex--;
}
}
});
);
}
+16 -8
View File
@@ -16,16 +16,24 @@ class RankingBoard {
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);
this.dbConnectManager.requestRanking(
type, date, time,
(type, rankingRecordManager) => {
if(rankingRecordManager.count == 0) {
console.log("ranking board - no data");
return;
}
for(let i = 0; i < endIndex - beginIndex; i++) {
let index = beginIndex + i;
let data = rankingRecordManager.getAt(index);
this.printRecord(type, i, data);
let beginIndex = this.getBeginIndex(rankingRecordManager);
let endIndex = this.getEndIndex(rankingRecordManager);
for(let i = 0; i < endIndex - beginIndex; i++) {
let index = beginIndex + i;
let data = rankingRecordManager.getAt(index);
this.printRecord(type, i, data);
}
}
});
);
}
getMyRank(rankingRecordManager) {
+22 -13
View File
@@ -25,23 +25,32 @@ class Start {
// contents
this.printHowToPlay(appInfoManager.getHowToPlayText(sessionStorageManager.playingAppName));
this.makeStartButton();
this.dbConnectManager.requestPlayerHistory( historyRecordManager => {
this.printChartBaseLine();
let today = new Date();
let date = DateUtil.getYYYYMMDD(today);
this.dbConnectManager.requestPlayerHistory(
date,
historyRecordManager => {
this.printChartBaseLine();
let underValue = historyRecordManager.underValueForGraph();
let upperValue = historyRecordManager.upperValueForGraph();
if(historyRecordManager.count == 0) {
console.log("start - history record : no data");
return;
}
let minValue = underValue - (upperValue - underValue) / 10;
let maxValue = upperValue;// + (upperValue - underValue) / 10;
for(let i = 0; i < historyRecordManager.count; i++) {
if(i > 6)
break;
let underValue = historyRecordManager.underValueForGraph();
let upperValue = historyRecordManager.upperValueForGraph();
let data = historyRecordManager.getAt(i);
this.drawRecordGraph(i, data.date, data.score, minValue, maxValue);
let minValue = underValue - (upperValue - underValue) / 10;
let maxValue = upperValue;// + (upperValue - underValue) / 10;
for(let i = 0; i < historyRecordManager.count; i++) {
if(i > 6)
break;
let data = historyRecordManager.getAt(i);
this.drawRecordGraph(i, data.date, data.score, minValue, maxValue);
}
}
});
);
// bottom
+1
View File
@@ -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/db_connect_manager.js"></script>
<script src="../../game/lib/input_type_text.js"></script>
+3 -2
View File
@@ -5,6 +5,7 @@ include "./../lib/send_error_code.php";
$user_id = $_POST["UserID"];
$app_name = $_POST["AppName"];
$date = $_POST["Date"];
include "./../setup/connect_db.php";
@@ -13,14 +14,14 @@ include "./../setup/connect_db.php";
$query = "
SELECT DATE(DateTime) AS Date, MAX(Score) AS HighScore, AppName AS AppName
FROM moty_record D
WHERE UserID = ?
WHERE UserID = ? AND DATE(D.DateTime) < DATE(?) AND AppName = ?
GROUP BY DATE(DateTime)
ORDER BY DateTime ASC
LIMIT 7;
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('s', $user_id);
$stmt->bind_param('sss', $user_id, $date, $app_name);
$stmt->execute();
$stmt->bind_result($date, $score, $app_name);