mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-20 21:01:36 +03:00
8d3bc79a7e
# Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Checklist before requesting a review Please delete options that are not relevant. - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate):
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) |