from app import create_app, db
from app.models.learning import LearningMaterial
from app.models.topics import Topic

def check_missing_subjects():
    app = create_app('development')
    with app.app_context():
        lm_subs = {s[0] for s in db.session.query(LearningMaterial.subject).distinct().all()}
        t_subs = {s[0] for s in db.session.query(Topic.subject).distinct().all()}
        
        missing = lm_subs - t_subs
        if missing:
            print("Subjects in LearningMaterial missing from Topic:")
            for m in missing:
                print(f"- {m}")
        else:
            print("No subjects missing between LearningMaterial and Topic.")

if __name__ == '__main__':
    check_missing_subjects()
