Fix: update best record for every hour

This commit is contained in:
2018-06-06 00:06:40 +09:00
parent 3f43f80c3d
commit b4f0531db0
5 changed files with 17 additions and 6 deletions
@@ -28,7 +28,7 @@ function get_best_record($maestro_id, $app_id, $user_id) {
$query = "
SELECT BestRecord
FROM moty_best_record
WHERE MaestroID = ? AND AppID = ? AND UserID = ? AND DATE(RecordDateTime) = Date(NOW())
WHERE MaestroID = ? AND AppID = ? AND UserID = ? AND DATE(RecordDateTime) = DATE(NOW())
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("iii", $maestro_id, $app_id, $user_id);
+3 -3
View File
@@ -38,7 +38,7 @@ function get_best_record($maestro_id, $app_id, $user_id) {
$query = "
SELECT BestRecordID, BestRecord
FROM moty_best_record
WHERE MaestroID = ? AND AppID = ? AND UserID = ? AND DATE(RecordDateTime) = DATE(NOW())
WHERE MaestroID = ? AND AppID = ? AND UserID = ? AND DATE(RecordDateTime) = DATE(NOW()) AND HOUR(RecordDateTime) = HOUR(NOW())
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("iii", $maestro_id, $app_id, $user_id);
@@ -71,8 +71,8 @@ function update_best_record($prev_best_record_id, $best_record) {
$query = "
UPDATE moty_best_record
SET BestRecord = ?, RecordDateTime = now()
WHERE BestRecordID = ? AND DATE(RecordDateTime) = DATE(NOW())
SET BestRecord = ?, RecordDateTime = NOW()
WHERE BestRecordID = ? AND DATE(RecordDateTime) = DATE(NOW()) AND HOUR(RecordDateTime) = HOUR(NOW())
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('ii', $best_record, $prev_best_record_id);