updated rewards assignment and reward progress
This commit is contained in:
@@ -32,9 +32,9 @@
|
||||
weekdayInTz,
|
||||
wallClockToUtc,
|
||||
resolveTz,
|
||||
periodStart,
|
||||
periodEnd,
|
||||
isCompleteForPeriod
|
||||
isCompleteForPeriod,
|
||||
bonusWindow,
|
||||
completionInWindow
|
||||
} from '@shared/timezone';
|
||||
|
||||
let { data } = $props();
|
||||
@@ -466,20 +466,20 @@
|
||||
return !cfg.memberId || cfg.memberId === memberId;
|
||||
})
|
||||
.map((cfg) => {
|
||||
const per = cfg.period || 'weekly';
|
||||
const pStart = periodStart(per, paydayDay, famTz);
|
||||
const pEnd = periodEnd(per, pStart);
|
||||
const win = bonusWindow(cfg, paydayDay, famTz);
|
||||
const pStart = win.from || '';
|
||||
const pEnd = win.to || '';
|
||||
const periodDays =
|
||||
Math.round(
|
||||
(new Date(pEnd + 'T00:00:00').getTime() - new Date(pStart + 'T00:00:00').getTime()) /
|
||||
86400000
|
||||
) + 1;
|
||||
pStart && pEnd
|
||||
? Math.round(
|
||||
(new Date(pEnd + 'T00:00:00').getTime() -
|
||||
new Date(pStart + 'T00:00:00').getTime()) /
|
||||
86400000
|
||||
) + 1
|
||||
: 1;
|
||||
|
||||
const periodCompletions = completions.filter(
|
||||
(c) =>
|
||||
c.memberId === memberId &&
|
||||
(c.date?.slice(0, 10) || c.date) >= pStart &&
|
||||
(c.date?.slice(0, 10) || c.date) <= pEnd
|
||||
(c) => c.memberId === memberId && completionInWindow(c, win)
|
||||
);
|
||||
|
||||
// Percent thresholds are "X% of the chores done this period" — the
|
||||
|
||||
Reference in New Issue
Block a user