Merge remote-tracking branch 'origin/statistics'

# Conflicts:
#	main.py
#	routers/__init__.py
#	schemas/deal.py
This commit is contained in:
2024-11-21 01:36:26 +03:00
14 changed files with 567 additions and 10 deletions

View File

@@ -14,3 +14,4 @@ from .time_tracking import time_tracking_router
from .billing import billing_router
from .task import task_router
from .work_shifts import work_shifts_router
from .statistics import statistics_router

40
routers/statistics.py Normal file
View File

@@ -0,0 +1,40 @@
from typing import Annotated
from fastapi import APIRouter, Depends
from sqlalchemy.ext.asyncio import AsyncSession
from backend.session import get_session
from schemas.statistics import GetProfitChartDataRequest, GetProfitChartDataResponse, GetProfitTableDataResponse, \
GetProfitTableDataRequest
from services.auth import authorized_user
from services.statistics import StatisticsService
statistics_router = APIRouter(
prefix="/statistics",
tags=["statistics"],
dependencies=[Depends(authorized_user)]
)
@statistics_router.post(
'/get-profit-chart-data',
response_model=GetProfitChartDataResponse,
operation_id='get_profit_chart_data',
)
async def get_profit_chart_data(
session: Annotated[AsyncSession, Depends(get_session)],
request: GetProfitChartDataRequest
):
return await StatisticsService(session).get_profit_chart_data(request)
@statistics_router.post(
'/get-profit-table-data',
response_model=GetProfitTableDataResponse,
operation_id='get_profit_table_data',
)
async def get_profit_table_data(
session: Annotated[AsyncSession, Depends(get_session)],
request: GetProfitTableDataRequest
):
return await StatisticsService(session).get_profit_table_data(request)

View File

@@ -45,3 +45,14 @@ async def create(
request: CreateUserRequest
):
return await UserService(session).create(request)
@user_router.get(
'/get-managers',
response_model=GetManagersResponse,
operation_id='get_managers',
)
async def get_managers(
session: SessionDependency,
):
return await UserService(session).get_managers()