mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-18 20:01:52 +03:00
22 lines
750 B
Python
22 lines
750 B
Python
|
from uuid import UUID
|
||
|
from fastapi import APIRouter, Depends, Query
|
||
|
from middlewares.auth.auth_bearer import AuthBearer, get_current_user
|
||
|
from modules.analytics.entity.analytics import Range
|
||
|
from modules.analytics.service.analytics_service import AnalyticsService
|
||
|
|
||
|
analytics_service = AnalyticsService()
|
||
|
analytics_router = APIRouter()
|
||
|
|
||
|
@analytics_router.get(
|
||
|
"/analytics/brains-usages", dependencies=[Depends(AuthBearer())], tags=["Analytics"]
|
||
|
)
|
||
|
async def get_brains_usages(
|
||
|
user: UUID = Depends(get_current_user),
|
||
|
brain_id: UUID = Query(None),
|
||
|
graph_range: Range = Query(Range.WEEK, alias="graph_range")
|
||
|
):
|
||
|
"""
|
||
|
Get all user brains usages
|
||
|
"""
|
||
|
|
||
|
return analytics_service.get_brains_usages(user.id, graph_range, brain_id)
|