import json, pathlib
from collections import Counter, defaultdict

data = json.loads(pathlib.Path('outputs/Calgary-Highlanders_Sep44_positions.json').read_text())

cats = Counter(p['category'] for p in data)
print('=== CATEGORIES ===')
for k, v in sorted(cats.items()):
    print(f'  {k}: {v}')

eod = [p for p in data if p['is_end_of_day']]
print(f'\n=== EOD entries: {len(eod)} ===')
for p in eod:
    print(f"  {str(p['date']):<16} cat={p['category']:<14} grid={str(p['grid']):<8} place={p['place_name']}")

eod_by_date = defaultdict(list)
for p in eod:
    eod_by_date[p['date']].append(p)
multi = {d: ps for d, ps in eod_by_date.items() if len(ps) > 1}
if multi:
    print('\nWARNING - multiple EOD on same date:')
    for d, ps in multi.items():
        print(f'  {d}: {len(ps)} entries')
else:
    print('\nOK: exactly one EOD per date')

# List dates with no EOD
all_dates = sorted({p['date'] for p in data if p['date']})
eod_dates = set(eod_by_date.keys())
missing = [d for d in all_dates if d not in eod_dates]
if missing:
    print(f'\nDates with NO EOD: {missing}')

