#!/usr/bin/env python3
"""Recent E001 events — focus SuperPick 60/69/61."""
import json
import sys
from collections import Counter
from pathlib import Path

tid = (sys.argv[1] if len(sys.argv) > 1 else "E001").upper()
since = sys.argv[2] if len(sys.argv) > 2 else "2026-07-20T18:58"
p = Path.home() / "EtherGold/dev/data/events.jsonl"
c = Counter()
samples = []
for line in p.read_text(errors="replace").splitlines()[-12000:]:
    if tid not in line.upper():
        continue
    try:
        e = json.loads(line)
    except Exception:
        continue
    utc = e.get("utc") or ""
    if utc and utc < since:
        continue
    msg = e.get("msg") or e.get("sent_msg")
    c[(e.get("ev"), msg)] += 1
    if msg in ("60", "69", "61", "20", "29", "21"):
        samples.append(
            (
                utc[-15:] if utc else "",
                e.get("ev"),
                msg,
                e.get("game"),
                e.get("outcome_retry"),
            )
        )
print(f"since={since} tid={tid}")
for k, v in c.most_common(30):
    print(v, k)
print("--- samples ---")
for s in samples[-40:]:
    print(s)
