from app.database import SessionLocal
from app.models.article import Article
from app.services import crosslink

TODAY = [7,93,96,107,116,117,118,123,156,169,192,194,196,206,216,220,232,239,
         259,269,333,378,387,400,408,419,420,465,469,470,471,472,473,474]
db = SessionLocal()
total = 0
for article_id in TODAY:
    a = db.get(Article, article_id)
    if not a or a.deleted_at is not None:
        continue
    found = crosslink.propose(db, a)
    total += len(found)
    if article_id in (470, 408, 117):
        print(f"\n--- {article_id} {a.title[:40]}: {len(found)}")
        for row in found[:4]:
            print(f"    {row['term']!r:34} -> {row['target_article_id']} "
                  f"{row['target_title'][:26]:26} ({row['reason']})")
    else:
        print(f"{article_id:4} {a.title[:40]:42} {len(found)}")
print("\ntotal proposed across today's rewrites:", total)
db.close()
