Add lightweight analytics dashboard
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -16,6 +16,7 @@ from .config import AppConfig, load_app_config
|
||||
from .storage import HistoryDB
|
||||
from .task_manager import JobManager
|
||||
from .ui import monitoring_js_path, monitoring_page_html
|
||||
from .utils import utc_now_iso
|
||||
|
||||
|
||||
class CreateJobRequest(BaseModel):
|
||||
@@ -386,6 +387,12 @@ def create_app(config: AppConfig | None = None) -> FastAPI:
|
||||
def stats(_: None = Depends(require_token)) -> dict[str, Any]:
|
||||
return manager.stats()
|
||||
|
||||
@app.get("/api/analytics")
|
||||
def analytics(_: None = Depends(require_token)) -> dict[str, Any]:
|
||||
payload = manager.analytics()
|
||||
payload["generated_at"] = utc_now_iso()
|
||||
return payload
|
||||
|
||||
if not app_config.disable_ui:
|
||||
@app.get("/", response_class=HTMLResponse)
|
||||
def ui_root() -> str:
|
||||
|
||||
Reference in New Issue
Block a user