#!/usr/bin/env python3
"""Date filter verification — 2026-06-15 (fixed)"""
import json

RESULTS_FILE = "/home/kiro/trend-engine/trends/x/account-monitor/scan_results_2026-06-15.json"

with open(RESULTS_FILE) as f:
    data = json.load(f)

issues = 0
for acc in data["accounts"]:
    tweets = acc.get("tweets", [])
    for t in tweets:
        date_str = t.get("date", "")
        if date_str and date_str < "2026-06-12":
            raw = repr(t.get("createdAt", ""))[:60]
            print(f"WARN: {acc['handle']}: date={date_str} raw={raw} — BEFORE cutoff")
            issues += 1

if issues == 0:
    print("ALL QUALIFYING TWEET DATES OK — within 3-day window (June 12-15)")
else:
    print(f"\n{issues} issues found")

# Show stats
qual_tweets = sum(len(acc.get("tweets", [])) for acc in data["accounts"])
qual_accounts = sum(1 for acc in data["accounts"] if acc.get("qualifying_count", 0) > 0)
print(f"\n{qual_tweets} qualifying tweets from {qual_accounts} accounts out of {len(data['accounts'])} total")
