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

week.ts can say how many Next up rows this week's pace reaches, as plain data with no read #12145

Merged opened this

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

Merged

`src/flow/week.ts` now exports `paceCut` and `daysLeftInWeek`, and `test/week-pace.test.ts` covers both. The new tests and `test/week.test.ts` pass, and `bun x tsc --noEmit` is clean. `bun scripts/gate.ts` printed nothing, so I don't know whether it passed. I did not run the full suite, so the forge's check is the first full run.

shipped production is serving it deploy b1c6dc4

opened this

src/flow/week.ts now exports paceCut and daysLeftInWeek, and test/week-pace.test.ts covers both. The new tests and test/week.test.ts pass, and bun x tsc --noEmit is clean. bun scripts/gate.ts printed nothing, so I don't know whether it passed. I did not run the full suite, so the forge's check is the first full run.

  • paceCut({landedPerDay, daysLeft, total, landed}) returns {rows, reason}, with rows = min(total, max(0, floor(landedPerDay * daysLeft))).

- The reason reads "by pace: 2 issues a day, 3 days left". - Zero pace says "nothing has landed lately, so none reach this week". - When landed < 3 the reason ends "(a guess: fewer than 3 landed)". - Non-finite or negative inputs count as zero.

  • daysLeftInWeek(now, resetsAt?) returns fractional days to resetsAt (a Date or an ISO string) when it is a valid instant. Otherwise it returns days to the next Monday 00:00 UTC, so a Monday-midnight now gets 7. It is never negative, and the clock is passed in.

weekView, cutLine, projection and every page are unchanged. I added no database read, no wiring and no dependency.

To try it, run bun test test/week-pace.test.ts.

I did not use keep_plan or estimate: neither tool was available in this session.

Closes #12133

3 earlier comments
commented

src/flow/week.ts now exports paceCut and daysLeftInWeek, and test/week-pace.test.ts covers both. The new tests and test/week.test.ts pass, and bun x tsc --noEmit is clean. bun scripts/gate.ts printed nothing, so I don't know whether it passed. I did not run the full suite, so the forge's check is the first full run.

  • paceCut({landedPerDay, daysLeft, total, landed}) returns {rows, reason}, with rows = min(total, max(0, floor(landedPerDay * daysLeft))).

- The reason reads "by pace: 2 issues a day, 3 days left". - Zero pace says "nothing has landed lately, so none reach this week". - When landed < 3 the reason ends "(a guess: fewer than 3 landed)". - Non-finite or negative inputs count as zero.

  • daysLeftInWeek(now, resetsAt?) returns fractional days to resetsAt (a Date or an ISO string) when it is a valid instant. Otherwise it returns days to the next Monday 00:00 UTC, so a Monday-midnight now gets 7. It is never negative, and the clock is passed in.

weekView, cutLine, projection and every page are unchanged. I added no database read, no wiring and no dependency.

To try it, run bun test test/week-pace.test.ts.

I did not use keep_plan or estimate: neither tool was available in this session.

commented

src/flow/week.ts now exports paceCut and daysLeftInWeek, as plain data with no database read. I rewrapped the one comment line the gate rejected. It was the daysLeftInWeek comment, 132 columns long. It is now a three-line block under 100.

bun scripts/gate.ts exits 0 on the committed tree. bun x tsc --noEmit is clean, and test/week-pace.test.ts and test/week.test.ts pass (13 tests). I did not run the full suite, so the forge's check on this push is the first full run.

  • paceCut({landedPerDay, daysLeft, total, landed}) returns {rows, reason}, where rows = min(total, max(0, floor(landedPerDay * daysLeft))).

- The reason reads "by pace: 2 issues a day, 3 days left". - Zero pace says nothing has landed lately, so none reach this week. - When landed < 3 the reason says the pace is a guess.

  • daysLeftInWeek(now, resetsAt?) returns days to resetsAt when it is a valid instant. Otherwise it returns days to the next Monday 00:00 UTC, so a Monday-midnight now gets 7. It is never negative, and the clock is passed in.

weekView, cutLine, projection and every page are unchanged, and I added no dependency.

To try it, run bun test test/week-pace.test.ts.

commented

paceCut and daysLeftInWeek are now allowed as unused exports. That clears the dead-code test, which was the only failure I could trace to this pull. I haven't seen the forge's re-check of the new push.

  • What changed: I added both functions to scripts/unused-exports-allow.json. src/flow/week.ts and test/week-pace.test.ts are as before. The issue says weekView and the pages stay unchanged and nothing is wired. Nothing in src/ calls either function yet, so the allow-list entry is intended; the follow-up wiring pull should remove it.
  • Checks run here: test/unused-exports.test.ts and test/week-pace.test.ts pass, 10 tests. scripts/gate.ts and bun x tsc --noEmit ran clean (no output).
  • Other failures: the other 43 failures (cookie flags, reserved names and the rest) don't touch week.ts. I ran test/cookie-flags.test.ts on a clean main checkout and it fails the same two tests. One is src/web/pages/home_flow.ts:486, a ${VIEW_COOKIE} cookie with no entry in COOKIES. I ran only the cookie-flags and reserved-names tests, not the other failing ones. The remainder most likely come from main as well, so I left them alone.

To try it, run bun test test/week-pace.test.ts.

commented

Parked by the crew: the check stayed red through 2 automatic tries

Approved

Does what #12133 asks and nothing more: paceCut and daysLeftInWeek are plain data, with no read, no wiring and no page touched. The tests cover each case the issue lists. I read the diff only. I did not fetch the preview, and I did not run bun test. This adds no page, so there is nothing for a phone or a keyboard to reach. Next, in order: (1) wire paceCut into weekView in a follow-up pull and delete the two scripts/unused-exports-allow.json entries in that same pull. (2) Check which of the red tests in the earlier check were already red on main, such as the cookie-flags one, so they do not park the follow-up as well.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs