from core.config import get_db
from models import Course, User, Participant, Staff, UserWallet, Parent, Event, BursaryDiscountApplication


class DashboardService:
    def admin_dashboard(self):
        with get_db() as db:
            courses_count = db.query(Course).count()
            parents_count = db.query(Parent).count()
            participants_count = db.query(Participant).count()
            teachers_count = db.query(Staff).count()
            event_count=db.query(Event).count()
            bursary_application=db.query(BursaryDiscountApplication).count()
            return {
                "total_courses": courses_count, "total_parents": parents_count,
                "total_participants": participants_count, "total_teachers": teachers_count,
                "total_event":event_count,"bursary_application":bursary_application
            }

    def parent_dashboard(self, user_id):
        with get_db() as db:
            parent = db.query(Parent).filter(Parent.id == user_id).first()
            return {"wallet_balance": parent.wallet_amount if parent else 0}
