Skip to content

fix(chores): the nightly job keeps chores that have no schedule - #408

Merged
jherforth merged 1 commit into
mainfrom
fix/keep-unscheduled-chores
Nov 29, 2026
Merged

jherforth merged 1 commit into
mainfrom
fix/keep-unscheduled-chores

Conversation

@jherforth

Copy link
Copy Markdown
Owner

Why

The nightly job deleted every chore definition with no schedules ("to avoid clutter", #41). That was meant for one-time chores that were done, but it caught much more. On main, one run of the job (GET /api/system/backgroundTasks) deleted all of these:

Deleted overnight What it was
"Not scheduled yet" A chore made in Admin and not scheduled yet
"Unload dishwasher" A follow-up target. The rule that hands it out went too (ON DELETE CASCADE), so Dishes stopped handing it on
"Get ready for soccer" A calendar routine's chore. The routine itself was deleted (routines.chore_id … ON DELETE CASCADE). A calendar routine has schedules only for matching events in the next 14 days, so a routine with nothing coming up has none
"Wash the car" A one-time chore that was done: the case #41 meant

Deleting a chore's schedule also lost the chore definition that night.

Found while reviewing #407, which relies on this prune.

What changes

A chore's definition is deleted only when:

  • the same run just pruned its last schedule (a finished one-time chore, or an any-day card whose period ended);
  • nothing still points at it: no other schedule, no follow-up rule handing it out, and no routine owning it.

So "Wash the car" still goes once it's done, as #41 wanted. A chore that simply has no schedule stays.

Nothing to migrate. Anything this would have kept on an existing install was already deleted by earlier nights.

Checks

  • New server/tests/nightlyChorePrune.test.js (real server, the job run on demand):

    • kept: an unscheduled chore, a chore whose schedule was deleted, a follow-up target whose one-time card was done and pruned (its rule intact), and a calendar routine with no events;
    • deleted: only the done one-time chore;
    • a second night changes nothing.

    It fails on main's code and passes with the fix.

  • Server npm test (TZ=UTC), 832/833. The one failure is mirrorReload.test.js, which compares clocks across two processes with no tolerance. It fails the same way on unmodified main on this machine, and it passed and failed at random when re-run.

  • The same check on a real server, before and after: main pruned four chores and one routine; the fix prunes only "Wash the car".

🤖 Generated with Claude Code

The nightly cleanup deleted every chore definition with no schedules
(#41). That was meant for one-time chores once done, but it also deleted
a chore made and not yet scheduled, a chore whose schedule was deleted, a
follow-up target (and, by cascade, the rule handing it out), and a
calendar routine's chore with no events coming up (and, by cascade, the
routine itself).

Now a definition goes only when this run pruned its last schedule, and no
follow-up rule or routine points at it. A finished one-time chore still
takes its definition with it.

New server/tests/nightlyChorePrune.test.js runs the job on a real server:
it fails on the old code and passes now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jherforth
jherforth merged commit f75e179 into main Nov 29, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in HomeGlow Kanban Nov 29, 2026
@jherforth jherforth added the bug Something isn't working label Nov 29, 2026
@jherforth jherforth self-assigned this Nov 29, 2026
@jherforth jherforth added this to the 2.1 milestone Nov 29, 2026
@jherforth
jherforth deleted the fix/keep-unscheduled-chores branch November 29, 2026 00:34
adamecker pushed a commit to adamecker/HomeGlow that referenced this pull request Nov 29, 2026
…h#409), nightly job keeps unscheduled chores (jherforth#408), bonus chore offered to some people only (jherforth#403/jherforth#404)

Upstream's migrations 44 (choreClaimUsers) and 45 (weekRhythm) collide
with the prod line's own 44 (anyDayChores) and 45 (prizePaused), so they
land here renumbered as 50 and 51, per the established prod-line practice.
anyDayChores test updated for the new final schema version (51).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant