feat: web UI chat render, panels, presence + analytics
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
from typing import Annotated
|
||||
|
||||
import asyncpg
|
||||
from dishka.integrations.fastapi import DishkaRoute, FromDishka
|
||||
from fastapi import APIRouter, Query
|
||||
|
||||
from utils.read import analytics
|
||||
from utils.read.models import ResponseStats, VolumeBucket
|
||||
|
||||
router = APIRouter(prefix="/api/analytics", tags=["analytics"], route_class=DishkaRoute)
|
||||
|
||||
AccountId = Annotated[int, Query()]
|
||||
ChatId = Annotated[int, Query()]
|
||||
|
||||
|
||||
@router.get("/volume")
|
||||
async def volume(
|
||||
pool: FromDishka[asyncpg.Pool],
|
||||
account_id: AccountId,
|
||||
chat_id: ChatId,
|
||||
days: Annotated[int, Query()] = 90,
|
||||
) -> list[VolumeBucket]:
|
||||
return await analytics.message_volume(pool, account_id, chat_id, days=days)
|
||||
|
||||
|
||||
@router.get("/response-time")
|
||||
async def response_time(
|
||||
pool: FromDishka[asyncpg.Pool], account_id: AccountId, chat_id: ChatId
|
||||
) -> ResponseStats:
|
||||
return await analytics.response_stats(pool, account_id, chat_id)
|
||||
Reference in New Issue
Block a user