add showboaters

This commit is contained in:
JCEEE
2026-09-15 15:23:44 +01:00
parent 234b2cd8ee
commit 812f6a4f88
+13 -7
View File
@@ -1166,11 +1166,12 @@ async function seedDemoCompletions(): Promise<void> {
const startDate = addDays(todayDate, -20); const startDate = addDays(todayDate, -20);
// Track per-member-per-week totals for weekly_history // Track per-member-per-week totals for weekly_history
type WeekKey = string; // "YYYY-MM-DD" (Monday) type WeekKey = string; // "YYYY-MM-DD" (week start: day after payday)
const weekTotals: Record< const weekTotals: Record<
string, string,
Record<string, { points: number; money: number; count: number }> Record<string, { points: number; money: number; count: number }>
> = {}; > = {};
const demoPayday = fam.payday ?? 1;
for (const member of members) { for (const member of members) {
const profile = COMPLETION_PROFILES[member.name] || COMPLETION_PROFILES['Jalipo']; const profile = COMPLETION_PROFILES[member.name] || COMPLETION_PROFILES['Jalipo'];
@@ -1180,10 +1181,14 @@ async function seedDemoCompletions(): Promise<void> {
const ds = dateStr(day); const ds = dateStr(day);
const dow = day.getUTCDay(); // 0=Sun const dow = day.getUTCDay(); // 0=Sun
// Compute week start (Monday) for weekly_history tracking // Compute week start (payday-anchored: weeks close on payday, so
const weekMonday = new Date(day); // the bucket opens the day after — same rule as weekStart()).
weekMonday.setUTCDate(weekMonday.getUTCDate() - ((weekMonday.getUTCDay() + 6) % 7)); const dowNum = day.getUTCDay(); // 0=Sun
const ws = dateStr(weekMonday); const sincePayday = (((dowNum - demoPayday) % 7) + 7) % 7;
const back = sincePayday === 0 ? 6 : sincePayday - 1;
const wsDay = new Date(day);
wsDay.setUTCDate(wsDay.getUTCDate() - back);
const ws = dateStr(wsDay);
if (!weekTotals[member.id]) weekTotals[member.id] = {}; if (!weekTotals[member.id]) weekTotals[member.id] = {};
if (!weekTotals[member.id][ws]) weekTotals[member.id][ws] = { points: 0, money: 0, count: 0 }; if (!weekTotals[member.id][ws]) weekTotals[member.id][ws] = { points: 0, money: 0, count: 0 };
@@ -1196,8 +1201,9 @@ async function seedDemoCompletions(): Promise<void> {
); );
for (const chore of memberChores) { for (const chore of memberChores) {
// Weekly chores: only complete on Monday (dow=1) // Weekly chores: only complete on the week's first day
if (chore.frequency === 'weekly' && dow !== 1) continue; // (day after payday).
if (chore.frequency === 'weekly' && dow !== (demoPayday + 1) % 7) continue;
const prob = dayProfile[chore.customName] || dayProfile.default; const prob = dayProfile[chore.customName] || dayProfile.default;
const rng = demoRng( const rng = demoRng(