Fix: request history and ranking record with maestroID
This commit is contained in:
@@ -81,7 +81,7 @@ class DBConnectManager {
|
||||
xhr.send("maestro_id=" + maestroID);
|
||||
}
|
||||
|
||||
requestPlayerHistory(date, listener) {
|
||||
requestPlayerHistory(maestroID, date, listener) {
|
||||
let historyRecordManager = new HistoryRecordManager();
|
||||
|
||||
/*
|
||||
@@ -111,7 +111,8 @@ class DBConnectManager {
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
};
|
||||
let params = "AppID=" + sessionStorageManager.playingAppID
|
||||
let params = "MaestroID=" + sessionStorageManager.maestroID
|
||||
+ "&AppID=" + sessionStorageManager.playingAppID
|
||||
+ "&UserID=" + sessionStorageManager.playerUserID
|
||||
+ "&Date=" + date;
|
||||
xhr.send(params);
|
||||
@@ -160,7 +161,7 @@ class DBConnectManager {
|
||||
*/
|
||||
}
|
||||
|
||||
requestRanking(type, date, time, listener) {
|
||||
requestRanking(type, maestroID, date, time, listener) {
|
||||
let rankingRecordManager = new RankingRecordManager();
|
||||
|
||||
/*
|
||||
@@ -190,7 +191,8 @@ class DBConnectManager {
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
};
|
||||
let params = "AppID=" + sessionStorageManager.playingAppID
|
||||
let params = "MaestroID=" + sessionStorageManager.maestroID
|
||||
+ "&AppID=" + sessionStorageManager.playingAppID
|
||||
+ "&Date=" + date
|
||||
+ "&Time=" + time;
|
||||
xhr.send(params);
|
||||
|
||||
@@ -16,6 +16,7 @@ class HistoryBoard {
|
||||
let today = new Date();
|
||||
let date = DateUtil.getYYYYMMDD(today);
|
||||
this.dbConnectManager.requestPlayerHistory(
|
||||
sessionStorageManager.maestroID,
|
||||
date,
|
||||
historyRecordManager => {
|
||||
if(historyRecordManager.count == 0) {
|
||||
|
||||
@@ -17,7 +17,7 @@ class RankingBoard {
|
||||
let date = DateUtil.getYYYYMMDD(today);
|
||||
let time = DateUtil.getHHMMSS(today);
|
||||
this.dbConnectManager.requestRanking(
|
||||
type, date, time,
|
||||
type, sessionStorageManager.maestroID, date, time,
|
||||
(type, rankingRecordManager) => {
|
||||
if(rankingRecordManager.count == 0) {
|
||||
console.log("ranking board - no data");
|
||||
|
||||
@@ -28,6 +28,7 @@ class Start {
|
||||
let today = new Date();
|
||||
let date = DateUtil.getYYYYMMDD(today);
|
||||
this.dbConnectManager.requestPlayerHistory(
|
||||
sessionStorageManager.maestroID,
|
||||
date,
|
||||
historyRecordManager => {
|
||||
this.printChartBaseLine();
|
||||
|
||||
@@ -3,6 +3,7 @@ header('Content-Type: application/json');
|
||||
|
||||
include "./../send_error_code.php";
|
||||
|
||||
$maestro_id = $_POST["MaestroID"];
|
||||
$app_id = $_POST["AppID"];
|
||||
$user_id = $_POST["UserID"];
|
||||
$date = $_POST["Date"];
|
||||
@@ -10,7 +11,7 @@ $date = $_POST["Date"];
|
||||
include "./../setup/connect_db.php";
|
||||
|
||||
|
||||
$replyJSON = get_history_record($app_id, $user_id, $date);
|
||||
$replyJSON = get_history_record($maestro_id, $app_id, $user_id, $date);
|
||||
if($replyJSON.length === 0) {
|
||||
send_error_message($replyJSON, "히스토리 기록 없음");
|
||||
$db_conn->close();
|
||||
@@ -21,20 +22,20 @@ echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
|
||||
$db_conn->close();
|
||||
|
||||
|
||||
function get_history_record($app_id, $user_id, $date) {
|
||||
function get_history_record($maestro_id, $app_id, $user_id, $date) {
|
||||
global $db_conn;
|
||||
|
||||
$query = "
|
||||
SELECT DATE(BR.RecordDateTime) AS Date, MAX(BR.BestRecord) AS HighScore, AA.AppName AS AppName
|
||||
FROM moty_best_record BR
|
||||
INNER JOIN moty_app AS AA
|
||||
ON BR.UserID = ? AND DATE(BR.RecordDateTime) < ? AND BR.AppID = ? AND BR.AppID = AA.AppID
|
||||
ON BR.MaestroID = ? AND BR.UserID = ? AND DATE(BR.RecordDateTime) < ? AND BR.AppID = ? AND BR.AppID = AA.AppID
|
||||
GROUP BY DATE(BR.RecordDateTime)
|
||||
ORDER BY BR.RecordDateTime DESC
|
||||
LIMIT 7
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('isi', $user_id, $date, $app_id);
|
||||
$stmt->bind_param('iisi', $maestro_id, $user_id, $date, $app_id);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($date, $score, $app_name);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ header('Content-Type: application/json');
|
||||
|
||||
include "./../lib/send_error_code.php";
|
||||
|
||||
$maestro_id = $_POST["MaestroID"];
|
||||
$app_id = $_POST["AppID"];
|
||||
$date = $_POST["Date"];
|
||||
$time = $_POST["Time"];
|
||||
@@ -10,7 +11,7 @@ $time = $_POST["Time"];
|
||||
include "./../setup/connect_db.php";
|
||||
|
||||
|
||||
$replyJSON = get_ranking_record_day($date, $app_id);
|
||||
$replyJSON = get_ranking_record_day($maestro_id, $date, $app_id);
|
||||
if($replyJSON.length === 0) {
|
||||
send_error_message($replyJSON, "오늘의 랭킹 기록 없음");
|
||||
$db_conn->close();
|
||||
@@ -21,18 +22,18 @@ echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
|
||||
$db_conn->close();
|
||||
|
||||
|
||||
function get_ranking_record_day($date, $app_id) {
|
||||
function get_ranking_record_day($maestro_id, $date, $app_id) {
|
||||
global $db_conn;
|
||||
|
||||
$query = "
|
||||
SELECT BR.userID As UserID, U.Name AS Name, MAX(BR.BestRecord) AS HighScore
|
||||
FROM moty_best_record BR, moty_user U
|
||||
WHERE BR.userID = U.userID AND DATE(BR.RecordDateTime) = ? AND AppID = ?
|
||||
WHERE BR.MaestroID = ? AND BR.userID = U.userID AND DATE(BR.RecordDateTime) = ? AND AppID = ?
|
||||
GROUP BY BR.userID
|
||||
ORDER BY max(BR.BestRecord) DESC;
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('si', $date, $app_id);
|
||||
$stmt->bind_param('isi', $maestro_id, $date, $app_id);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($userID, $name, $high_score);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ header('Content-Type: application/json');
|
||||
|
||||
include "./../lib/send_error_code.php";
|
||||
|
||||
$maestro_id = $_POST["MaestroID"];
|
||||
$app_id = $_POST["AppID"];
|
||||
$date = $_POST["Date"];
|
||||
$time = $_POST["Time"];
|
||||
@@ -10,7 +11,7 @@ $time = $_POST["Time"];
|
||||
include "./../setup/connect_db.php";
|
||||
|
||||
|
||||
$replyJSON = get_ranking_record_hour($date, $time, $app_id);
|
||||
$replyJSON = get_ranking_record_hour($maestro_id, $date, $time, $app_id);
|
||||
if($replyJSON.length === 0) {
|
||||
send_error_message($replyJSON, "수업시간 랭킹 기록 없음");
|
||||
$db_conn->close();
|
||||
@@ -20,18 +21,18 @@ if($replyJSON.length === 0) {
|
||||
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
|
||||
$db_conn->close();
|
||||
|
||||
function get_ranking_record_hour($date, $time, $app_id) {
|
||||
function get_ranking_record_hour($maestro_id, $date, $time, $app_id) {
|
||||
global $db_conn;
|
||||
|
||||
$query = "
|
||||
SELECT BR.userID As UserID, U.Name AS Name, MAX(BR.BestRecord) AS HighScore
|
||||
FROM moty_best_record BR, moty_user U
|
||||
WHERE BR.userID = U.userID AND DATE(BR.RecordDateTime) = ? AND HOUR(BR.RecordDateTime) = HOUR(?) AND AppID = ?
|
||||
WHERE BR.MaestroID = ? AND BR.userID = U.userID AND DATE(BR.RecordDateTime) = ? AND HOUR(BR.RecordDateTime) = HOUR(?) AND AppID = ?
|
||||
GROUP BY BR.userID
|
||||
ORDER BY max(BR.BestRecord) DESC;
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('ssi', $date, $time, $app_id);
|
||||
$stmt->bind_param('issi', $maestro_id, $date, $time, $app_id);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($userID, $name, $high_score);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ header('Content-Type: application/json');
|
||||
|
||||
include "./../lib/send_error_code.php";
|
||||
|
||||
$maestro_id = $_POST["MaestroID"];
|
||||
$app_id = $_POST["AppID"];
|
||||
$date = $_POST["Date"];
|
||||
$time = $_POST["Time"];
|
||||
@@ -10,7 +11,7 @@ $time = $_POST["Time"];
|
||||
include "./../setup/connect_db.php";
|
||||
|
||||
|
||||
$replyJSON = get_ranking_record_month($date, $time, $app_id);
|
||||
$replyJSON = get_ranking_record_month($maestro_id, $date, $time, $app_id);
|
||||
if($replyJSON.length === 0) {
|
||||
send_error_message($replyJSON, "이달의 랭킹 기록 없음");
|
||||
$db_conn->close();
|
||||
@@ -21,18 +22,18 @@ echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
|
||||
$db_conn->close();
|
||||
|
||||
|
||||
function get_ranking_record_month($date, $time, $app_id) {
|
||||
function get_ranking_record_month($maestro_id, $date, $time, $app_id) {
|
||||
global $db_conn;
|
||||
|
||||
$query = "
|
||||
SELECT BR.userID As UserID, U.Name AS Name, MAX(BR.BestRecord) AS HighScore
|
||||
FROM moty_best_record BR, moty_user U
|
||||
WHERE BR.userID = U.userID AND MONTH(BR.RecordDateTime) = MONTH(?) AND AppID = ?
|
||||
WHERE BR.MaestroID = ? AND BR.userID = U.userID AND MONTH(BR.RecordDateTime) = MONTH(?) AND AppID = ?
|
||||
GROUP BY BR.userID
|
||||
ORDER BY max(BR.BestRecord) DESC;
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('si', $date, $app_id);
|
||||
$stmt->bind_param('isi', $maestro_id, $date, $app_id);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($userID, $name, $high_score);
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ QUnit.test( "User login", function( assert ) {
|
||||
});
|
||||
|
||||
QUnit.test( "Player history", function( assert ) {
|
||||
sessionStorageManager.maestroID = 1; // jisangs
|
||||
sessionStorageManager.playerUserID = "8"; // 부현율
|
||||
sessionStorageManager.playingAppID = 9;
|
||||
let date = "2018-05-16";
|
||||
@@ -31,6 +32,7 @@ QUnit.test( "Player history", function( assert ) {
|
||||
let done = assert.async();
|
||||
setTimeout(function() {
|
||||
dbConnectManager.requestPlayerHistory(
|
||||
1, // maestroID for jisangs
|
||||
date,
|
||||
(historyRecordManager) => {
|
||||
console.log(historyRecordManager);
|
||||
@@ -50,6 +52,7 @@ QUnit.test( "Player history", function( assert ) {
|
||||
});
|
||||
|
||||
QUnit.test( "Player ranking", function( assert ) {
|
||||
sessionStorageManager.maestroID = 1; // jisangs
|
||||
sessionStorageManager.playingAppID = 9;
|
||||
let date = "2018-05-16";
|
||||
let time = "14:50:00";
|
||||
@@ -59,6 +62,7 @@ QUnit.test( "Player ranking", function( assert ) {
|
||||
setTimeout(function() {
|
||||
dbConnectManager.requestRanking(
|
||||
DBConnectManager.TYPE_MY_RANKING_HOUR,
|
||||
1, // maestroID for jisangs
|
||||
date,
|
||||
time,
|
||||
(type, rankingRecordManager) => {
|
||||
@@ -80,6 +84,7 @@ QUnit.test( "Player ranking", function( assert ) {
|
||||
setTimeout(function() {
|
||||
dbConnectManager.requestRanking(
|
||||
DBConnectManager.TYPE_MY_RANKING_DAY,
|
||||
1, // maestroID for jisangs
|
||||
date,
|
||||
time,
|
||||
(type, rankingRecordManager) => {
|
||||
@@ -101,6 +106,7 @@ QUnit.test( "Player ranking", function( assert ) {
|
||||
setTimeout(function() {
|
||||
dbConnectManager.requestRanking(
|
||||
DBConnectManager.TYPE_MY_RANKING_MONTH,
|
||||
1, // maestroID for jisangs
|
||||
date,
|
||||
time,
|
||||
(type, rankingRecordManager) => {
|
||||
|
||||
Reference in New Issue
Block a user