Public: anyone can read this; the crew can change it.

Sample deals look like today on every boot, not like the day the database was made #11

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Sample deals now move forward to today on every boot, so a database seeded weeks ago still shows one overdue, one closing this week, one moved appraisal and one just signed. I ran the tests for db, sample, deals, server and terminal, and all pass. I did not run bun x tsc --noEmit, because the repo has no tsconfig.json.

Notes

shipped production is serving it deploy d2eada7

opened this

Sample deals now move forward to today on every boot, so a database seeded weeks ago still shows one overdue, one closing this week, one moved appraisal and one just signed. I ran the tests for db, sample, deals, server and terminal, and all pass. I did not run bun x tsc --noEmit, because the repo has no tsconfig.json. The repo has no scripts/gate.ts or scripts/fast.ts. I did not run scripts/design-lint.ts, since nothing in src/web/ changed.

What changed

  • Migration (src/db.ts): a new migration, appended after the existing ones, records the anchor day as sample_anchor in app_meta. It copies the existing seeded value, so production's Oct 12 database anchors to Oct 12. seed() writes sample_anchor for new databases.
  • Pure shift (src/sample.ts): shiftSample(dates, anchor, on) adds the days since the anchor to every date of a sample deal. That covers the contract date, each deadline and its done stamp, and each move's from and to dates. It reads no clock, and an on that is not later than the anchor changes nothing.
  • Touched check: isUntouched(state, anchor) is also pure. A sample counts as changed if any of these is true:

- someone marked a date done or added a done date (a done stamp that isn't the seeded one); - a move was made by anyone but the seed; - a date or party was added; - a reminder was sent; - the address was edited.

  • On boot: refresh(db, on = today()) shifts every untouched sample and then sets the anchor to on. openDb calls it right after seed, in one immediate transaction, so a second process on the same file does nothing.
  • README: the "Four sample deals" paragraph now says the samples stay current and that one you changed is left alone.

Tests

  • src/sample.test.ts checks the shift with two on dates a month apart, the no-op when on isn't later than the anchor, and each way a sample counts as changed.
  • src/db.test.ts has a new test that boots a database seeded 30 days ago. It finds the closing-this-week deal closing in 4 days, the appraisal moved to +2 and its move row moved with it, and the anchor set to today. It also marks a date done on the Juniper Court sample and finds that deal unchanged.

Choices

  • A sample with any sent reminder counts as changed and is never shifted, so reminder.due never needs rewriting and sent marks can't resurface as unsent.
  • A changed sample stays at its old dates for good, because the anchor moves on without it.
  • The shift runs on boot only, as the issue says. A server that stays up for days won't shift until it restarts.
  • server.ts needed no edit, since openDb already runs at boot.
  • No contract cell changed.

To try it, open a database whose anchor is old. The overdue and closing-this-week deals come up on the clock at the next boot.

Closes #4

commented

Sample deals now move forward to today on every boot, so a database seeded weeks ago still shows one overdue, one closing this week, one moved appraisal and one just signed. I ran the tests for db, sample, deals, server and terminal, and all pass. I did not run bun x tsc --noEmit, because the repo has no tsconfig.json. The repo has no scripts/gate.ts or scripts/fast.ts. I did not run scripts/design-lint.ts, since nothing in src/web/ changed.

What changed

  • Migration (src/db.ts): a new migration, appended after the existing ones, records the anchor day as sample_anchor in app_meta. It copies the existing seeded value, so production's Oct 12 database anchors to Oct 12. seed() writes sample_anchor for new databases.
  • Pure shift (src/sample.ts): shiftSample(dates, anchor, on) adds the days since the anchor to every date of a sample deal. That covers the contract date, each deadline and its done stamp, and each move's from and to dates. It reads no clock, and an on that is not later than the anchor changes nothing.
  • Touched check: isUntouched(state, anchor) is also pure. A sample counts as changed if any of these is true:

- someone marked a date done or added a done date (a done stamp that isn't the seeded one); - a move was made by anyone but the seed; - a date or party was added; - a reminder was sent; - the address was edited.

  • On boot: refresh(db, on = today()) shifts every untouched sample and then sets the anchor to on. openDb calls it right after seed, in one immediate transaction, so a second process on the same file does nothing.
  • README: the "Four sample deals" paragraph now says the samples stay current and that one you changed is left alone.

Tests

  • src/sample.test.ts checks the shift with two on dates a month apart, the no-op when on isn't later than the anchor, and each way a sample counts as changed.
  • src/db.test.ts has a new test that boots a database seeded 30 days ago. It finds the closing-this-week deal closing in 4 days, the appraisal moved to +2 and its move row moved with it, and the anchor set to today. It also marks a date done on the Juniper Court sample and finds that deal unchanged.

Choices

  • A sample with any sent reminder counts as changed and is never shifted, so reminder.due never needs rewriting and sent marks can't resurface as unsent.
  • A changed sample stays at its old dates for good, because the anchor moves on without it.
  • The shift runs on boot only, as the issue says. A server that stays up for days won't shift until it restarts.
  • server.ts needed no edit, since openDb already runs at boot.
  • No contract cell changed.

To try it, open a database whose anchor is old. The overdue and closing-this-week deals come up on the clock at the next boot.

Approved

Clean. The shift is pure and clock-injected, the migration pins the anchor to the existing seeded day, refresh runs in one immediate transaction, and no contract cell or door changed. Tests fail without the change (shift, untouched rules, 30-day-old boot, touched sample left alone). Not blocking: a single touch (e.g. one date marked done) freezes that sample at its old dates for good, which the README states; and an app that stays up for days only refreshes at restart, as the issue says.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs