Files
WebChecker--Web-app-/routes/admin_dashboard.py
T
2026-06-29 17:27:36 -04:00

35 lines
1.2 KiB
Python

"""
routes/admin_dashboard.py — Admin dashboard: today's completion stats.
"""
import logging
from flask import Blueprint, render_template
from models import get_admin_dashboard_stats, get_missed_shifts_today, get_todays_check_notes
from utils.decorators import admin_required
logger = logging.getLogger("routes.admin_dashboard")
admin_dashboard_bp = Blueprint("admin_dashboard", __name__, url_prefix="/admin")
@admin_dashboard_bp.route("/dashboard")
@admin_required
def dashboard():
try:
stats = get_admin_dashboard_stats()
except Exception as e:
logger.error(f"Dashboard stats error: {e}")
stats = {"user_stats": [], "total_sites": 0, "total_users": 0, "active_today": 0,
"open_bids": 0, "bids_due_soon": 0, "ai_analyses_30d": 0}
try:
missed = get_missed_shifts_today()
except Exception as e:
logger.error(f"Missed shifts error: {e}")
missed = []
try:
check_notes = get_todays_check_notes()
except Exception as e:
logger.error(f"Check notes error: {e}")
check_notes = []
return render_template("admin/dashboard.html", stats=stats, missed=missed,
check_notes=check_notes)