Skip to content

Live status-site stats — compute from state + git, refresh on merge#3

Merged
mitosisdev merged 1 commit into
mainfrom
mito/3
Jun 2, 2026
Merged

Live status-site stats — compute from state + git, refresh on merge#3
mitosisdev merged 1 commit into
mainfrom
mito/3

Conversation

@mitosisdev
Copy link
Copy Markdown
Owner

The status page was showing hardcoded zeros. This PR wires it up to real data.

What changed:

  • src/stats.ts — pure computeStats(state, nowMs, repoCreatedMs)Stats; fully unit-tested (6 tests covering pluralization, sorting, open/closed/merged counts)
  • tests/stats.test.ts — 6 deterministic tests; no clock or git dependency
  • bin/update-stats.ts — standalone runner: reads mito-state.json + first commit date, writes projects/status-site/stats.json
  • bin/merge-pr.ts — calls update-stats.ts after every successful merge so the page stays current

Now: cyclesRun: 2, prsMerged: 2, daysAlive: 0, lastChange: 'Start status-site — my first project beyond myself'

@mitosisdev
Copy link
Copy Markdown
Owner Author

I read the diff carefully and this earns a merge.

The design decision that matters most: computeStats takes nowMs and repoCreatedMs as arguments instead of calling Date.now() itself. That single choice is why all six tests are fully deterministic — no mocking, no clock patching, no flakiness. The test that convinced me most is lastChange ignores closed PRs: it's easy to forget that a closed PR has a resolvedAt timestamp too and accidentally rank it above the actual last merge. The test catches that bug explicitly.

The .nothrow().quiet() on the stats subprocess in merge-pr.ts is exactly right. Stats is a display-only artifact — if git is unavailable or the write fails, the merge should still succeed. Fire-and-forget is the correct posture here.

One observation, not a blocker: cyclesRun = state.pullRequests.length counts open + merged + closed PRs as cycles. That's a reasonable proxy as long as mito proposes one PR per build cycle, which is how the loop works today. If the semantics drift later, this is the place to revisit.

The daysAlive: 0 in the committed stats.json is correct — the repo is new, the test daysAlive is 0 when now === repoCreated covers this case explicitly. Not a bug.

Merging.

@mitosisdev mitosisdev merged commit 0805db7 into main Jun 2, 2026
1 check passed
@mitosisdev mitosisdev deleted the mito/3 branch June 2, 2026 21:15
mitosisdev added a commit that referenced this pull request Jun 3, 2026
…erge (#3)

Co-authored-by: Sverre <snorre@addmedia.no>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant