# pages/dashboard.py - Dashboard page import streamlit as st import pandas as pd from modules.database import Session, Student, User, AcademicTerm, Mark, DisciplineReport def show(): """Display dashboard""" st.header("📊 Dashboard") session = Session() # Get statistics total_students = session.query(Student).count() total_staff = session.query(User).filter(User.role == 'teacher').count() total_terms = session.query(AcademicTerm).count() # Display metrics col1, col2, col3 = st.columns(3) with col1: st.metric("Total Students", total_students) with col2: st.metric("Total Staff", total_staff) with col3: active_term = session.query(AcademicTerm).filter_by(is_active=True).first() st.metric("Active Term", active_term.term_name if active_term else "None") # Recent activity st.subheader("Recent Activity") logs = pd.read_sql("SELECT * FROM audit_logs ORDER BY timestamp DESC LIMIT 5", session.bind.engine.url.replace('sqlite:///', '')) if not logs.empty: st.dataframe(logs, use_container_width=True) else: st.info("No activity logs yet") session.close()