ref(backend): Centralize deps and add mypy
Extract reusable API dependencies and activity logging helpers.\nAdd mypy configuration and dev dependency for type checking.\n\nCo-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi import APIRouter, Depends, Query
|
||||
from sqlmodel import Session, select
|
||||
from sqlalchemy import desc
|
||||
from sqlmodel import Session, col, select
|
||||
|
||||
from app.core.auth import get_auth_context
|
||||
from app.api.deps import require_admin_auth
|
||||
from app.core.auth import AuthContext
|
||||
from app.db.session import get_session
|
||||
from app.models.activity_events import ActivityEvent
|
||||
from app.schemas.activity_events import ActivityEventRead
|
||||
from app.services.admin_access import require_admin
|
||||
|
||||
router = APIRouter(prefix="/activity", tags=["activity"])
|
||||
|
||||
@@ -17,10 +18,12 @@ def list_activity(
|
||||
limit: int = Query(50, ge=1, le=200),
|
||||
offset: int = Query(0, ge=0),
|
||||
session: Session = Depends(get_session),
|
||||
auth=Depends(get_auth_context),
|
||||
auth: AuthContext = Depends(require_admin_auth),
|
||||
) -> list[ActivityEvent]:
|
||||
require_admin(auth)
|
||||
statement = (
|
||||
select(ActivityEvent).order_by(ActivityEvent.created_at.desc()).offset(offset).limit(limit)
|
||||
select(ActivityEvent)
|
||||
.order_by(desc(col(ActivityEvent.created_at)))
|
||||
.offset(offset)
|
||||
.limit(limit)
|
||||
)
|
||||
return list(session.exec(statement))
|
||||
|
||||
Reference in New Issue
Block a user