Reddit scraper PRs get a review summary; the form/Reddit overlap is measured (#23, #24)
CI / test (pull_request) Successful in 40s
CI / test (pull_request) Successful in 40s
- collection/etl/review_reddit.py (`python -m collection review-reddit`) and .gitea/workflows/reddit-review.yml: on every scraper pull request, one comment (refreshed on each push) listing the runs added, changed and gone, the runs that break a game rule (left out of the model and stats until corrected), other flags, runs that may also be in the form, and result pages already counted; plus how to reject / fix / add. forge.upsert_comment keeps it to one comment. collection/README.md: "Reviewing Reddit runs". - analysis/overlap/overlap.py -> data/public/overlap.json: a Reddit run with at least 4 route answers "matches" a form row giving the same answers within a day; chance is the same test a few weeks off. 9 of 36 comparable runs match, ~7.3 by chance: about 2 of 82 look reported twice, too few to matter. Nothing is removed. Shown on the page's Data & methods tab; in the dataset metadata; checked in test:py; part of `rebuild`. - Neither the form nor the register records a result-page id, so the only proven copy (comment <-> result page) stays the one #18 applies. - data/public/stats.json: the statistics of #42 (impossible runs left out), which did not make it into that merge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
0df6b8d473
commit
98be27fc1f
@@ -335,6 +335,30 @@ class RedditComments(unittest.TestCase):
|
||||
kept = build_policy.drop_flagged(rows)
|
||||
self.assertEqual([r["source"] for r in kept], ["reddit comment", "reddit spreadsheet"])
|
||||
|
||||
def test_review_summary_and_overlap(self):
|
||||
sys.path.insert(0, str(ROOT / "core"))
|
||||
from collection.etl import review_reddit
|
||||
ov = review_reddit._overlap()
|
||||
base = {"runs": [{"id": "a1", "thread": "t", "answers": {"outcome": "Bonded"}}]}
|
||||
head = {"runs": [{"id": "a1", "thread": "t", "answers": {"outcome": "Incinerated at a bonding encounter"}},
|
||||
{"id": "b2", "thread": "t", "answers": {}}, {"id": "c3", "thread": "t", "answers": {}, "result": "THRESH-X1"}]}
|
||||
self.assertEqual(review_reddit.diff(base, head), (["b2", "c3"], ["a1"], []))
|
||||
route = dict(company="Alone", direction="East", scream="Ignore the scream", hour="Tree", outcome="Bonded",
|
||||
outcome_color="Red", date="2026-10-05")
|
||||
runs = [{"run_id": "comment-b2", "source": "reddit comment", "data_flags": "read from a Reddit comment; "
|
||||
"Black recorded on a Valley run (the Black is only reached from the tree)", **{k: None for k in ov.FIELDS}, "date": None},
|
||||
{"run_id": "comment-c3", "source": "reddit comment", "data_flags": "", **{k: None for k in ov.FIELDS}, **route},
|
||||
{"run_id": "sheet-1", "source": "reddit spreadsheet", "data_flags": "", **{k: None for k in ov.FIELDS}, **route}]
|
||||
m = ov.measure(runs)
|
||||
self.assertEqual((m["comparable"], m["matched"]), (1, 1))
|
||||
self.assertEqual(m["matches"], [{"comment": "comment-c3", "form": ["sheet-1"]}])
|
||||
text = review_reddit.summary(base, head, runs, {"THRESH-X1"}, m)
|
||||
self.assertIn("**2 new**, 1 changed", text)
|
||||
self.assertIn("Black recorded on a Valley run", text)
|
||||
self.assertIn("sheet-1", text)
|
||||
self.assertIn("THRESH-X1", text)
|
||||
self.assertTrue(text.startswith(review_reddit.MARKER))
|
||||
|
||||
def test_delivered_not_extracted(self):
|
||||
spec = read_yaml("collection/pipeline.yaml")["sources"]["reddit_comments"]
|
||||
with self.assertRaises(extract.Skip):
|
||||
|
||||
Reference in New Issue
Block a user