# -*- coding: utf-8 -*-
import json, re
h = open(r"D:\work buddy\2026-11-05-14-15-52\index_main.html", "r", encoding="utf-8").read()
ids = set(re.findall(r'\{id:"([^"]+)"', h))
print("PROGRAMS unique ids:", len(ids))

todo = json.load(open(r"D:\work buddy\2026-11-05-14-15-52\todo_upgrade.json", "r", encoding="utf-8"))
hot = [t for t in todo if t.get("disc") in ("cs", "biz", "sci", "eng", "soc")]
print("hot candidates:", len(hot))

# For each candidate, check if it's already represented in PROGRAMS
# by matching school code + keywords in id
def already_done(s, en, deg):
    # crude: look for id starting with s- and containing a recognizable keyword from en
    en_low = en.lower()
    # extract key words
    words = re.findall(r'[a-z]{4,}', en_low)
    candidates = [i for i in ids if i.startswith(s + "-")]
    for c in candidates:
        c_low = c.lower()
        # if any word from en appears in id, consider done
        if any(w in c_low for w in words[:3]):
            return c
    return None

# Show first 50 hot candidates with their status
shown = 0
for t in hot:
    s = t["s"]
    en = t["en"]
    deg = t["deg"]
    col = t.get("col", "")
    det = t.get("det", "")
    done = already_done(s, en, deg)
    if not done:
        print(f"[TODO] {s:8s} | {en[:55]:55s} | {deg:4s} | {col[:35]:35s} | {det}")
        shown += 1
        if shown >= 50:
            break
print("---")
print("shown TODO count:", shown)
