From 1840105cf9adfa2e57662fc2f50436ddfe343fac Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Wed, 18 Feb 2026 23:12:27 +0000 Subject: [PATCH] Auto commit: 2026-02-18T23:12:26.737Z --- api/song_requests.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/api/song_requests.php b/api/song_requests.php index f0032ed..300a958 100644 --- a/api/song_requests.php +++ b/api/song_requests.php @@ -60,7 +60,28 @@ if ($method === 'POST') { } } - echo json_encode(['success' => true]); + // Check if this user is now the #1 listener of the week + $topStmt = $db->query(" + SELECT requester, COUNT(*) as total_requests + FROM song_requests + WHERE requester IS NOT NULL AND requester != '' AND requester != 'AnĂ³nimo' + AND created_at > DATE_SUB(NOW(), INTERVAL 7 DAY) + GROUP BY requester + ORDER BY total_requests DESC + LIMIT 1 + "); + $topListener = $topStmt->fetch(); + + $isNewTop = false; + if ($topListener && $topListener['requester'] === $requester) { + $isNewTop = true; + } + + echo json_encode([ + 'success' => true, + 'is_top' => $isNewTop, + 'top_name' => $topListener['requester'] ?? '' + ]); } catch (Exception $e) { echo json_encode(['success' => false, 'error' => $e->getMessage()]); }