2025-12-06 02:22:01 +01:00
|
|
|
from fastapi import APIRouter, Request
|
|
|
|
|
from fastapi.templating import Jinja2Templates
|
|
|
|
|
from fastapi.responses import HTMLResponse
|
2026-01-10 21:09:29 +01:00
|
|
|
from app.core.database import execute_query_single
|
2025-12-06 02:22:01 +01:00
|
|
|
|
|
|
|
|
router = APIRouter()
|
|
|
|
|
templates = Jinja2Templates(directory="app")
|
|
|
|
|
|
2025-12-16 15:36:11 +01:00
|
|
|
@router.get("/", response_class=HTMLResponse)
|
2025-12-06 02:22:01 +01:00
|
|
|
async def dashboard(request: Request):
|
|
|
|
|
"""
|
|
|
|
|
Render the dashboard page
|
|
|
|
|
"""
|
2026-01-10 21:09:29 +01:00
|
|
|
# Fetch count of unknown billing worklogs
|
|
|
|
|
unknown_query = """
|
|
|
|
|
SELECT COUNT(*) as count
|
|
|
|
|
FROM tticket_worklog
|
|
|
|
|
WHERE billing_method = 'unknown'
|
|
|
|
|
AND status NOT IN ('billed', 'rejected')
|
|
|
|
|
"""
|
|
|
|
|
start_date = "2024-01-01" # Filter ancient history if needed, but for now take all
|
|
|
|
|
|
|
|
|
|
result = execute_query_single(unknown_query)
|
|
|
|
|
unknown_count = result['count'] if result else 0
|
|
|
|
|
|
|
|
|
|
return templates.TemplateResponse("dashboard/frontend/index.html", {
|
|
|
|
|
"request": request,
|
|
|
|
|
"unknown_worklog_count": unknown_count
|
|
|
|
|
})
|