aboutsummaryrefslogtreecommitdiffstats
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
parentcb6315b1cc7bc7ed936cdb7c70514013c2fdc159 (diff)
enable determinstic mode 30 day no-repeat
-rw-r--r--server/daily.ts2
-rw-r--r--server/shared.ts9
2 files changed, 5 insertions, 6 deletions
diff --git a/server/daily.ts b/server/daily.ts
index 35350f7..cfc9d6a 100644
--- a/server/daily.ts
+++ b/server/daily.ts
@@ -2,7 +2,6 @@ import { Router } from "express";
import rateLimit from "express-rate-limit";
import {
buildSessionToken,
- getDailySong,
getUtcDate,
GuessEntry,
normalizeSignedState,
@@ -11,6 +10,7 @@ import {
signState,
verifySessionToken,
verifyStateSignature,
+ getDailySong,
} from "./shared";
export const dailyRouter = Router();
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