From e2446af8e273e412e0c1a1c7f46e43bbfcf732ae Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Fri, 26 Jun 2026 17:50:46 -0700 Subject: enable determinstic mode 30 day no-repeat --- server/shared.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'server/shared.ts') diff --git a/server/shared.ts b/server/shared.ts index 003e4df..3b5344c 100644 --- a/server/shared.ts +++ b/server/shared.ts @@ -52,7 +52,7 @@ function hashString(str: string): number { return hash; } -export function getDailySong(date: string): Song { +export function pickSong(date: string): Song { const seed = hashString(date); const index = seed % songs.length; return songs[index]; @@ -68,12 +68,11 @@ function getLastNDates(n: number): string[] { return dates; } -export function getDailySongNoRepeat(): Song { - const today = getUtcDate(); +export function getDailySong(today: string): Song { const recentSongs = new Set( - getLastNDates(30).map(d => getDailySong(d).youtubeId) + getLastNDates(30).map(d => pickSong(d).youtubeId) ); - let candidate = getDailySong(today); + let candidate = pickSong(today); let guard = 0; while (recentSongs.has(candidate.youtubeId) && guard < songs.length) { const rerollSeed = hashString(today + ":" + guard); -- cgit v1.2.3