Skip to content

feat(chores): chores every 2, 3 or 4 weeks on set weekdays (#401) - #409

Merged
jherforth merged 1 commit into
mainfrom
feat/every-n-weeks
Nov 29, 2026
Merged

jherforth merged 1 commit into
mainfrom
feat/every-n-weeks

Conversation

@jherforth

Copy link
Copy Markdown
Owner

Closes #401.

Why

Some chores follow a fortnightly rhythm set by something outside the house, such as "put out the check for the cleaners" every other Sunday. Nothing did that before:

  • A weekly schedule shows on the off weeks too.
  • "Again 2 weeks after done" drifts when it's ticked late.
  • "Any day in 2 weeks" isn't tied to a weekday.

Cron can't say it either. The plan on #401 has the details, and the short version is that cron has no week number.

What changes for people

  • The wizard: On certain days of the week asks Every: week, 2 weeks, 3 weeks or 4 weeks. Above one week it asks Starting: this week, next week, and so on, each with its date ("week of Dec 6").
  • The board names the group Every other week: Sunday (next Dec 6), or Every 3 weeks: Mon · Thu (next …). Groups on opposite weeks stay apart.
  • Change days shows a group's rhythm and can change it. Changing only the days keeps it. Copy to carries it.
  • In an off week the chore isn't due at all:
    • no card on the dashboard;
    • no hold on the daily bonus;
    • no miss logged;
    • "off" in the card's 7-day row;
    • nothing marked on the board calendar.
  • "Stays until done" keeps its Sundays, so a card ticked on Monday doesn't move the rhythm. That was the issue's main ask.
  • The Schedules list's next occurrence skips the off weeks.

How it works

  • Storage: migration 45 adds chore_schedules.week_interval (2–4, NULL for every week) and week_anchor (the Sunday of a week that counts).
    • A day counts when the crontab fires and its week is a whole number of intervals from the anchor's week, with weeks running Sunday to Saturday.
    • Only for days of the week (day of month and month *), on day-of or until-completed.
  • One rule on each side, so the card, the bonus and the misses agree:
    • Server: scheduleFiresOnDate (utils/cronDay.js, with utils/weekRhythm.js) replaces cronFiresOnDate in all three places that ask "is it due": the stays-until-done cards, getTodaysRegularChoresForUser (the bonus and misses), and the claim route's open-bonus check.
    • Client: scheduleFiresOn (utils/choreDays.js) does the same for the widget, the 7-day row, the board calendar and the next occurrence.
  • The API: POST/PATCH /api/chore-schedules take week_interval and week_anchor.
    • The anchor is stored as its week's Sunday, and defaults to this week.
    • A rhythm where it means nothing (monthly, "again after done", any-day, one-time) is a 400.
    • A PATCH that changes only the days keeps the rhythm. One that moves the schedule off days of the week, without mentioning the rhythm, drops it, so an editor that doesn't know about it can't leave a stray rhythm.
  • Timings: a week timing carries every and anchor. Its group key holds the phase, so two schedules on the same weeks share a group even with different anchors. scheduleFieldsForTiming writes the rhythm for a week timing and clears it for every other kind.

A change from the plan posted on #401: the rhythm has its own columns instead of reusing interval. interval already means two things (the gap after "again after done", and an any-day period), and several edit paths reset it to null. That would have quietly turned a fortnightly chore weekly.

Not included: the "every few days" fix that the plan mentioned as optional. It's still a separate follow-up.

Checks

  • Server: npm test (TZ=UTC), 841/841. New tests/weekRhythm.test.js (8):
    • the rules: weeks, before and after the anchor, and what may have a rhythm;
    • on a real server: storing one, with an anchor defaulting to this week; refusals; a days-only change keeping it; a move to monthly dropping it; setting and changing it;
    • a stays-until-done card made only in its week;
    • the daily bonus paid when the fortnightly chore is off this week, and held when it's due.
  • Client: vitest 1116/1116, including the new utils/weekRhythm.test.js (14). Eight existing timing expectations now include the cleared rhythm fields. check:i18n (English and Spanish) and the build pass.
  • Edge, against a real server, 13/13:
    • Dashboard: this week's fortnightly chore shows, next week's doesn't.
    • Wizard: Sunday, every 2 weeks, starting next week, stays until done. The review reads "Every other week: Sunday (next Dec 6)". The server stores 0 0 * * 0, 2, 2026-12-06, until-completed.
    • Board: the group label matches.
    • Change days: it opens on 2 weeks and next week; moving to Saturday keeps the rhythm and the anchor.
    • Phone width in Spanish: the label reads Cada dos semanas: …, with no sideways scroll.
    • No page errors.

🤖 Generated with Claude Code

"Every other Sunday" for cleaners who come fortnightly. Cron can't say
it, so the rhythm sits beside the crontab: week_interval (2-4, NULL for
every week) and week_anchor (the Sunday of a week that counts), migration
45. A day counts when the crontab fires and its week is a whole number of
intervals from the anchor's week; only for days of the week, on a day-of
or until-completed schedule ("stays until done" keeps its Sundays however
late it's ticked).

- One rule on each side: scheduleFiresOnDate (server/utils/cronDay.js,
  server/utils/weekRhythm.js) for sticky cards, the daily bonus and
  misses, and the claim route's open-bonus check; scheduleFiresOn
  (client/src/utils/choreDays.js) for the widget, the 7-day row, the
  board calendar and the next-occurrence column. Off weeks are simply not
  due.
- The wizard's "On certain days of the week" asks Every week / 2 / 3 / 4
  weeks and, for more than one, which week it starts. A group's Change
  days shows and changes it, and keeps it when only the days change; Copy
  carries it. The board names it "Every other week: Sunday (next Dec 6)",
  and groups opposite weeks apart.
- The server keeps the rhythm when a PATCH changes only the days, and
  drops it when one moves the schedule off days of the week, so editors
  that don't know about it can't leave a stray rhythm. A rhythm where it
  means nothing is a 400.

Separate columns rather than reusing `interval` (as the plan on #401
suggested): `interval` already means two things, and old edit paths reset
it, which would have turned a fortnightly chore weekly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jherforth
jherforth merged commit 18ee3f3 into main Nov 29, 2026
7 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in HomeGlow Kanban Nov 29, 2026
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).
@jherforth
jherforth deleted the feat/every-n-weeks branch December 4, 2026 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Feat: chores that repeat every N weeks on a set weekday (e.g. every other Sunday)

1 participant