Repository navigation
fix(reports): stop old and already-reviewed reports from hiding an entry - #201
Conversation
jamesconwaydev
left a comment
There was a problem hiding this comment.
Thanks for this. The idea's right, and I like that un-hiding stays a plain edit. A few things before it goes in:
-
track_hiddencan stop the hourly sync. It runs beforerun()with nothing around it, so one failedhidden.jsonwrite (a 409 after three tries, or a 5xx) raises out ofmain()anddiscussions.jsonnever syncs. #199 just went in to stop exactly that. Please wrap it so a failure is logged andrun()still goes ahead, and add a test where thehidden.jsonPUT fails anddiscussions.jsonis still written. -
Dates need strict parsing.
fromisoformattakes date-only and naive strings, and a naive one throwsTypeErroron the compare. We've settled on an ASCIIre.fullmatchforYYYY-MM-DDTHH:MM:SSZand thenstrptime(..., "%Y-%m-%dT%H:%M:%SZ")with UTC attached. (_establishedand_recent_checkshave the same loose pattern; leave those, I'll get them separately.) -
Put a time limit on "hidden:true but visible means cutoff now". If
on_mergekeeps failing, that entry can't be hidden by reports at all, for as long as the failures last. Only treat it as "just un-hidden" when the record was stamped in the last 2 hours; past that, fall back to the 30-day window. -
Tests: unreadable
hidden.jsonshould raise and hide nothing, and a malformed or naiveunhidden_atshould raise. Also, the body says 3 new report tests fail on main, but 4 were added, andunhide_of_another_entrypasses on main. Just tidy the wording. -
Note two gaps in the PR body and leave them: a missing
hidden.jsonfalls back to the plain 30-day window (fine, that's today's behaviour), and a hidden entry renamed by rot loses its record. A one-line comment next to the shortcut covers the rename case.
Then rebase onto main to pick up #199. It applies cleanly.
on_merge now keeps hidden.json on the stats branch: the entries that are hidden, and when one was last un-hid. A spam or other report only counts toward a hide if it was filed after that un-hide and within the last 30 days. An entry that was hidden at the last hourly look but is visible now counts no reports yet, so the window before on_merge sees the un-hide is covered too. The decide token gets contents: read to fetch hidden.json.
84fdbae to
39ae24e
Compare
|
Thanks, all five are in 39ae24e, rebased onto main:
|
jamesconwaydev
left a comment
There was a problem hiding this comment.
That's all five, thanks. Putting the 2-hour bound on seen_at is a neat way to do it, and the two shortcuts are documented right where someone will look.
What and why
Closes #41.
Un-hides are recorded.
on_mergealready runs hourly with a stats-branch token, so it now also keepshidden.jsonthere. Each hidden entry gets a record withseen_at, the last time a run saw it hidden. When an entry it saw hidden is visible again, the record gets anunhidden_atstamp. Entries that leave the list are dropped. Nothing inentries.jsonor its schema changes, so un-hiding is still the same hand edit. A failedhidden.jsonwrite is logged, and the Discussions sync still runs.Only newer reports count.
_reportersskips spam/other reports filed before a cutoff. The cutoff is the later of 30 days ago and the entry'sunhidden_at. Ifhidden.jsonstill says hidden but the entry is visible, andseen_atis under 2 hours old, the entry was just un-hidden, so the cutoff is now. Past 2 hours,on_mergeis failing, so it falls back to the normal window rather than blocking hides. Timestamps are parsed strictly (ASCIIYYYY-MM-DDTHH:MM:SSZ, thenstrptimewith UTC attached). A malformed or naive one raises, and so does an unreadablehidden.json, so nothing gets hidden on bad data.Known gaps, left on purpose:
hidden.jsonyet means the plain 30-day window, which is today's behaviour.Other changes:
decidetoken inreports.ymlgetscontents: readto fetchhidden.json.REPORT_MAX_AGE, and the 2 hours isJUST_UNHIDDEN.Tests: 7 new report tests. 5 fail on
main; the other two (a stale snapshot, a record for a different entry) pin behaviourmainalready has. Plustrack_hiddentests and one where thehidden.jsonPUT fails anddiscussions.jsonis still written. Rebased ontomainwith #199.Checks
python3 -m unittest discover -s scripts -t .passes (581)npm --prefix site testpasses (if you touchedsite/)npx prettier --check .passesdata/entries.jsonby hand (submissions go through the form)