Delete four stale SEO and style agent report JSON/MD files from agents/reports/ that had zero findings or were superseded. Export PYTHONDONTWRITEBYTECODE=1 in the Makefile so all make targets suppress bytecode generation, and add a `tree` target that lists the repository file tree via git ls-tree. Update AGENTS.md and CLAUDE.md documentation to reflect that routers now form a directory tree mirroring URL paths and that bytecode writing is disabled project-wide.
28 lines
929 B
Python
28 lines
929 B
Python
# retoor <retoor@molodetz.nl>
|
|
|
|
import logging
|
|
from fastapi import APIRouter, Request
|
|
from fastapi.responses import HTMLResponse, JSONResponse
|
|
from devplacepy.database import get_platform_analytics
|
|
from devplacepy.utils import require_admin, get_current_user, is_admin
|
|
from devplacepy.responses import action_result
|
|
|
|
logger = logging.getLogger(__name__)
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("", response_class=HTMLResponse)
|
|
async def admin_index(request: Request):
|
|
require_admin(request)
|
|
return action_result(request, "/admin/users")
|
|
|
|
|
|
@router.get("/analytics")
|
|
async def admin_analytics(request: Request, top_n: int = 10):
|
|
user = get_current_user(request)
|
|
if not user:
|
|
return JSONResponse({"error": "Authentication required"}, status_code=401)
|
|
if not is_admin(user):
|
|
return JSONResponse({"error": "Admin access required"}, status_code=403)
|
|
return JSONResponse(get_platform_analytics(top_n))
|