import json

with open('todo_upgrade.json','r',encoding='utf-8') as f:
    todo = json.load(f)

print(f'todo_upgrade 总数: {len(todo)}')
print()

# 按 disc 优先级统计
priority = ['cs','ee','fin','econ','ba','ds','stat','mech','bio','mgmt']
by_disc = {}
for item in todo:
    disc = item.get('disc','other')
    by_disc[disc] = by_disc.get(disc,0)+1

print('按学科分布:')
for d in priority + [k for k in by_disc if k not in priority]:
    if d in by_disc:
        print(f'  {d}: {by_disc[d]}')
print()

# 打印前 20 条（按优先级排序）
def sort_key(item):
    disc = item.get('disc','zzz')
    try:
        idx = priority.index(disc)
    except:
        idx = 99
    return (idx, item.get('s',''), item.get('en',''))

sorted_todo = sorted(todo, key=sort_key)
print('前 25 条待核验:')
for i, item in enumerate(sorted_todo[:25]):
    disc = item.get('disc','?')
    s = item.get('s','?')
    n = item.get('n','?')
    en = item.get('en','?')[:60]
    det = item.get('det','?')[:50]
    lvl = item.get('lvl','?')
    print(f'{i+1}. [{disc}][{lvl}] {s} - {n} | {en} | det: {det}')
