- collection/pipeline.yaml declares every source (extract kind, transform, privacy rules, load target, run source); `python -m collection update|build` - extract keeps data/raw/<source>/current + previous only (git-ignored); data/manifest.json records the current raw checksum and change date - transforms are pure; validate checks runs against data/dictionary.yaml before load; load writes byte-stable files only when they change - data/public/runs_clean.csv: every run from every source with a new `source` column (reddit spreadsheet, reddit thread, reported, bot, reddit pdf); the sheet's own row label moves to `entry`; run_id is text - bot importer ported to Python (same output as bot.js on the fixture); labels and crosswalk in collection/specs/bot.yaml, written into graph.js - Reddit through the official API (result links to add by hand); the 12 result pages move to collection/manual/reddit_results.yaml - "Report a run": a GitHub issue form generated from collection/specs/report_form.yaml, collected as source "reported", plus a site tab pointing to it, the community spreadsheet and the megathread - analysis and the route model read runs_clean.csv (sources in measures.yaml); stats.json and policy.json unchanged apart from the factor's new name - daily workflow runs the pipeline; the raw store is kept between runs in the Actions cache, encrypted with RAW_ARCHIVE_KEY Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
32 lines
1.4 KiB
Python
32 lines
1.4 KiB
Python
"""Run reports (raw: the "run report" issues from the GitHub API) -> data/public/reports.json.
|
|
|
|
Kept per report: the issue number, the date it was opened, and the answers (the option labels chosen). GitHub
|
|
usernames and any other text are dropped. Reports closed as "not planned" or carrying a reject label (e.g.
|
|
invalid, duplicate) are left out, so a maintainer removes a bad report by closing it that way."""
|
|
import json
|
|
from pathlib import Path
|
|
|
|
from .. import report_form
|
|
|
|
|
|
def transform(raw_path, spec, ctx):
|
|
issues = json.loads(Path(raw_path).read_text(encoding="utf-8"))
|
|
reject = set(spec["transform"].get("reject_labels", []))
|
|
form = report_form.spec()
|
|
reports = []
|
|
for i in sorted(issues, key=lambda i: i["number"]):
|
|
labels = {lb["name"] if isinstance(lb, dict) else lb for lb in i.get("labels") or []}
|
|
if labels & reject or i.get("state_reason") == "not_planned":
|
|
continue
|
|
answers = report_form.parse_body(i.get("body"), form)
|
|
if not answers:
|
|
continue
|
|
reports.append({"number": i["number"], "opened": (i.get("created_at") or "")[:10] or None, "answers": answers})
|
|
return {"source": spec["label"], "reports": reports}
|
|
|
|
|
|
def describe(old, new):
|
|
o = {r["number"] for r in (old or {}).get("reports", [])}
|
|
n = {r["number"] for r in new["reports"]}
|
|
return [f"{len(n)} report(s) ({len(n - o)} new, {len(o - n)} removed)"]
|