Repository navigation
fix: keep Trending honest across renames and tabs - #109
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.