24 lines
637 B
Python
24 lines
637 B
Python
"""Agent call log listing endpoint."""
|
|
from fastapi import APIRouter, Depends, Query
|
|
|
|
from app.auth import CurrentUser
|
|
from app.config import settings
|
|
from app.db import get_conn
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/agent-call-logs")
|
|
async def list_logs(
|
|
_user: CurrentUser = None,
|
|
limit: int = Query(default=100, le=500),
|
|
):
|
|
s = settings.db_schema
|
|
async with get_conn() as conn:
|
|
async with conn.cursor() as cur:
|
|
await cur.execute(
|
|
f"SELECT * FROM {s}.agent_call_logs ORDER BY created_at DESC LIMIT %s",
|
|
(limit,),
|
|
)
|
|
return await cur.fetchall()
|