Merge remote-tracking branch 'origin/statistics'
# Conflicts: # main.py # routers/__init__.py # schemas/deal.py
This commit is contained in:
		@@ -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
									
								
							
							
						
						
									
										40
									
								
								routers/statistics.py
									
									
									
									
									
										Normal 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)
 | 
			
		||||
@@ -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()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user