@ywkrlerche/richardwho 1.0.38 → 1.0.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/app.js +14 -0
  2. package/package.json +1 -1
package/app.js CHANGED
@@ -684,6 +684,8 @@
684
684
  // Newest first. Add an entry here with every publish; its version should match package.json.
685
685
  // Each has: new (features), games (added/removed/fixed games), fixes (bugs). Leave a list out if empty.
686
686
  const CHANGELOG = [
687
+ { version: "1.0.39", date: "2026-10-29",
688
+ fixes: ["Old daily challenge scores clean themselves up after 2 days"] },
687
689
  { version: "1.0.38", date: "2026-10-29",
688
690
  new: ["Daily trivia challenge: the same 10 questions for everyone, one try a day, with a leaderboard", "A quick tour of the site for first-time visitors (replay it from Settings)"],
689
691
  fixes: ["Trimmed the trivia puzzle list to the best ones"] },
@@ -2762,9 +2764,21 @@
2762
2764
  });
2763
2765
  } catch { /* already played today from this browser, or offline: the local score still shows */ }
2764
2766
  }
2767
+ // Old boards clean themselves up: whoever opens Trivia deletes scores more than 2 days old (the database allows
2768
+ // that for anyone), a few days at a time, so the owner never has to
2769
+ async function sweepOldDaily(db) {
2770
+ try {
2771
+ const cutoff = dailyDate(new Date(Date.now() - 3 * 86400000)), old = Date.now() - 2 * 86400000;
2772
+ const days = await db.ref("daily").orderByKey().endAt(cutoff).limitToFirst(5).once("value");
2773
+ const changes = {};
2774
+ days.forEach((day) => { day.forEach((row) => { if ((row.val() || {}).ts < old) changes[`daily/${day.key}/${row.key}`] = null; }); });
2775
+ if (Object.keys(changes).length) await db.ref().update(changes);
2776
+ } catch { /* older rules, or someone else swept first */ }
2777
+ }
2765
2778
  async function watchDailyBoard() {
2766
2779
  const app = await getFirebase();
2767
2780
  if (!app) return;
2781
+ signedInUser(app).then(() => sweepOldDaily(app.database()));
2768
2782
  if (daily.ref) daily.ref.off();
2769
2783
  daily.ref = app.database().ref(`daily/${dailyDate()}`).orderByChild("score").limitToLast(10);
2770
2784
  daily.ref.on("value", (s) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ywkrlerche/richardwho",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
4
4
  "description": "Richards Unblocked Games",
5
5
  "license": "UNLICENSED",
6
6
  "files": [