from app import create_app, db
from app.models.topics import Topic, TopicVideo
from sqlalchemy import func

def list_all_counts():
    app = create_app('development')
    with app.app_context():
        # Get all distinct subjects from Topic table
        all_subs = [s[0] for s in db.session.query(Topic.subject).distinct().all()]
        
        for sub in all_subs:
            count = db.session.query(TopicVideo).join(Topic).filter(Topic.subject == sub).count()
            print(f"{sub}: {count} videos")

if __name__ == '__main__':
    list_all_counts()
