Spaces:
Sleeping
Sleeping
File size: 1,221 Bytes
c6e646f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# 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() |