Fix: request history and ranking record with maestroID
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user