import json, sqlite3, sys

db = sys.argv[1]
counts = {"Many PRs (20)": 20, "Many PRs (43)": 43, "Few PRs (3)": 3}
states = ["open", "merged", "closed"]
con = sqlite3.connect(db)
for title, n in counts.items():
    row = con.execute(
        "select thread_id, payload_json from orchestration_v2_projection_threads where title=?", (title,)
    ).fetchone()
    payload = json.loads(row[1])
    prs = []
    for i in range(n):
        num = 1000 + i
        prs.append({
            "host": "github.com",
            "repository": "acme/widgets",
            "number": num,
            "url": f"https://github.com/acme/widgets/pull/{num}",
            "source": "manual",
            "linkedAt": "2026-11-18T10:00:00.000Z",
            "snapshot": {
                "state": states[i % 3],
                "title": f"Synthetic linked pull request number {i + 1} with a longish title",
                "headBranch": f"feature/{num}",
                "baseBranch": "main",
                "isDraft": False,
                "updatedAt": "2026-11-18T10:00:00.000Z",
                "syncedAt": "2026-11-18T10:00:00.000Z",
            },
            "stack": None,
        })
    payload["pullRequests"] = prs
    con.execute(
        "update orchestration_v2_projection_threads set payload_json=? where thread_id=?",
        (json.dumps(payload), row[0]),
    )
    print(title, n)
con.commit()
