aboutsummaryrefslogtreecommitdiffstats
path: root/server/shared.ts
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2026-06-26 17:50:46 -0700
committerPinapelz <yukais@pinapelz.com>2026-06-26 17:52:22 -0700
commite2446af8e273e412e0c1a1c7f46e43bbfcf732ae (patch)
treef291dcf495da455b944e18ecde409e43df6f809a /server/shared.ts
parentcb6315b1cc7bc7ed936cdb7c70514013c2fdc159 (diff)
enable determinstic mode 30 day no-repeat
Diffstat (limited to 'server/shared.ts')
-rw-r--r--server/shared.ts9
1 files changed, 4 insertions, 5 deletions
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);
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage