Fix: DateUtil.getDate bug
This commit is contained in:
@@ -28,9 +28,9 @@ function get_history_record($app_id, $user_id, $date) {
|
||||
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) < DATE(?) AND BR.AppID = ? AND BR.AppID = AA.AppID
|
||||
ON BR.UserID = ? AND DATE(BR.RecordDateTime) < ? AND BR.AppID = ? AND BR.AppID = AA.AppID
|
||||
GROUP BY DATE(BR.RecordDateTime)
|
||||
ORDER BY BR.RecordDateTime ASC
|
||||
ORDER BY BR.RecordDateTime DESC
|
||||
LIMIT 7
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
|
||||
@@ -5,14 +5,14 @@ include "./../lib/send_error_code.php";
|
||||
|
||||
$app_id = $_POST["AppID"];
|
||||
$date = $_POST["Date"];
|
||||
// $time = $_POST["Time"];
|
||||
$time = $_POST["Time"];
|
||||
|
||||
include "./../setup/connect_db.php";
|
||||
|
||||
|
||||
$replyJSON = get_ranking_record_day($date, $app_id);
|
||||
if($replyJSON.length === 0) {
|
||||
send_error_message($replyJSON, "히스토리 기록 없음");
|
||||
send_error_message($replyJSON, "오늘의 랭킹 기록 없음");
|
||||
$db_conn->close();
|
||||
exit;
|
||||
}
|
||||
@@ -27,7 +27,7 @@ function get_ranking_record_day($date, $app_id) {
|
||||
$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) = DATE(?) AND AppID = ?
|
||||
WHERE BR.userID = U.userID AND DATE(BR.RecordDateTime) = ? AND AppID = ?
|
||||
GROUP BY BR.userID
|
||||
ORDER BY max(BR.BestRecord) DESC;
|
||||
";
|
||||
|
||||
@@ -12,7 +12,7 @@ include "./../setup/connect_db.php";
|
||||
|
||||
$replyJSON = get_ranking_record_hour($date, $time, $app_id);
|
||||
if($replyJSON.length === 0) {
|
||||
send_error_message($replyJSON, "히스토리 기록 없음");
|
||||
send_error_message($replyJSON, "수업시간 랭킹 기록 없음");
|
||||
$db_conn->close();
|
||||
exit;
|
||||
}
|
||||
@@ -20,21 +20,19 @@ if($replyJSON.length === 0) {
|
||||
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
|
||||
$db_conn->close();
|
||||
|
||||
|
||||
function get_ranking_record_hour($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) = DATE(?) AND HOUR(BR.RecordDateTime) = HOUR(?) AND AppID = ?
|
||||
WHERE 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->execute();
|
||||
|
||||
$stmt->bind_result($userID, $name, $high_score);
|
||||
|
||||
$ranking_record_array = array();
|
||||
|
||||
@@ -12,7 +12,7 @@ include "./../setup/connect_db.php";
|
||||
|
||||
$replyJSON = get_ranking_record_month($date, $time, $app_id);
|
||||
if($replyJSON.length === 0) {
|
||||
send_error_message($replyJSON, "히스토리 기록 없음");
|
||||
send_error_message($replyJSON, "이달의 랭킹 기록 없음");
|
||||
$db_conn->close();
|
||||
exit;
|
||||
}
|
||||
@@ -34,17 +34,16 @@ function get_ranking_record_month($date, $time, $app_id) {
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('si', $date, $app_id);
|
||||
$stmt->execute();
|
||||
|
||||
$stmt->bind_result($userID, $name, $high_score);
|
||||
|
||||
$score_record_array = array();
|
||||
$ranking_record_array = array();
|
||||
while($stmt->fetch()) {
|
||||
$score_record['UserID'] = $userID;
|
||||
$score_record['Name'] = $name;
|
||||
$score_record['HighScore'] = $high_score;
|
||||
array_push($score_record_array, $score_record);
|
||||
$ranking_record['UserID'] = $userID;
|
||||
$ranking_record['Name'] = $name;
|
||||
$ranking_record['HighScore'] = $high_score;
|
||||
array_push($ranking_record_array, $ranking_record);
|
||||
}
|
||||
$return_array['rankingMonth'] = $score_record_array;
|
||||
$return_array['rankingMonth'] = $ranking_record_array;
|
||||
|
||||
return $return_array;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user