Skip to content

fix: keep Trending honest across renames and tabs - #109

Merged
jamesconwaydev merged 3 commits into
mainfrom
fix-review-wave1
Nov 6, 2026
Merged

jamesconwaydev merged 3 commits into
mainfrom
fix-review-wave1

Conversation

@jamesconwaydev

Copy link
Copy Markdown
Collaborator

Three findings from the final review.

I3: the Trending tab now uses the Trending rule. The tab marked any unflagged row with a positive 7-day delta, so an hour-old submission with one Like showed up there even though the hero's `trending()` would refuse it. Leaderboard now marks rows from `trending()` itself, and the client script only filters on that mark, so the built HTML and the tab agree. A dist test checks that the marked rows are exactly what `trending()` returns, including a row climbing by 3.

I4: a rename keeps its Likes and its baseline. `rot finish` now also moves `likes.json` and `meta.json`, and records each rename in `renames.json` on the stats branch (`{old: {to, at}}`, pruned after 8 days). `sync_likes` replays the renames made since the baseline snapshot over that snapshot, oldest first, so the renamed entry is compared with its own past instead of counting every Like as this week's gain. One small file write instead of rewriting a week of snapshots, all through the existing `update_json` retry. Tests cover a rename followed by a sync, chained renames, and a rename older than the baseline.

I11: Like threads no longer starve. Submit and the health check now run `on_merge` themselves once their PR has merged, while still holding `list-writes`; in the health check it runs after `finish`, so a renamed entry's thread is already under its new key. The `push` trigger on on-merge goes; the hourly run stays, still in `list-writes`, as the backstop. Deploy also runs after Submit and Health check, so the Like link and a renamed entry's Likes appear without waiting for the next sync.

A separate `discussions` group for on-merge was considered and rejected: run between a rename's merge and `finish`, it opens a second thread for the new name, and `finish` then points the key back at the old thread, leaving the new one orphaned. Neither the `setdefault` adoption nor title adoption catches it, because the old thread still carries the old title at that point.

Part of the v0.1 launch.

The tab marked any unflagged row with a positive 7-day delta, so a
fresh submission with one Like showed up there even though trending()
would refuse it. Mark rows from trending() itself.
A rename moved discussions.json and flags.json only. The site then
read 0 Likes under the new name until the next sync, and the sync
compared the new name against snapshots keyed by the old one, so every
Like counted as a 7-day gain and the entry jumped onto Trending.

finish now moves likes.json and meta.json too, and records each
rename in renames.json. sync_likes replays the renames made since the
baseline snapshot over that snapshot before computing deltas.
on-merge sat in the one pending slot of list-writes, so each new
submission cancelled it and new entries had no thread to Like until a
quiet hour. Submit and the health check now run on_merge themselves
once their PR has merged, still holding the lock, so a rename's keys
have moved first. The push trigger goes; the hourly run stays as the
backstop. Deploy also runs after those two, so the Like link and a
renamed entry's moved Likes show without waiting for the next sync.
@jamesconwaydev
jamesconwaydev merged commit e78524c into main Nov 6, 2026
9 checks passed
@jamesconwaydev
jamesconwaydev deleted the fix-review-wave1 branch November 6, 2026 04:35
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