feat: add workspace

This commit is contained in:
Artem Tsyrulnikov
2025-12-13 22:09:55 +03:00
parent 2fdd56c3e0
commit af32e2a507
55 changed files with 677 additions and 227 deletions

View File

@@ -8,16 +8,18 @@ from fastapi.routing import APIRouter
from src import deps, dto
from src.adapter.jwt import JWTPayload
analytics_router = APIRouter(prefix='/analytics', tags=['analytics'])
analytics_router = APIRouter(prefix='/workspaces/{workspace_id}/analytics', tags=['analytics'])
@analytics_router.get('/placements')
async def get_placements_analytics(
workspace_id: uuid.UUID,
current_user: Annotated[JWTPayload, Depends(deps.get_current_user)],
target_channel_id: uuid.UUID | None = None,
) -> dto.GetPlacementsAnalyticsOutput:
input = dto.GetPlacementsAnalyticsInput(
user_id=current_user.user_id,
workspace_id=workspace_id,
target_channel_id=target_channel_id,
)
return await deps.get_usecase().get_placements_analytics(input)
@@ -25,11 +27,13 @@ async def get_placements_analytics(
@analytics_router.get('/creatives')
async def get_creatives_analytics(
workspace_id: uuid.UUID,
current_user: Annotated[JWTPayload, Depends(deps.get_current_user)],
target_channel_id: uuid.UUID | None = None,
) -> dto.GetCreativesAnalyticsOutput:
input = dto.GetCreativesAnalyticsInput(
user_id=current_user.user_id,
workspace_id=workspace_id,
target_channel_id=target_channel_id,
)
return await deps.get_usecase().get_creatives_analytics(input)
@@ -37,11 +41,13 @@ async def get_creatives_analytics(
@analytics_router.get('/external-channels')
async def get_external_channels_analytics(
workspace_id: uuid.UUID,
current_user: Annotated[JWTPayload, Depends(deps.get_current_user)],
target_channel_id: uuid.UUID | None = None,
) -> dto.GetExternalChannelsAnalyticsOutput:
input = dto.GetExternalChannelsAnalyticsInput(
user_id=current_user.user_id,
workspace_id=workspace_id,
target_channel_id=target_channel_id,
)
return await deps.get_usecase().get_external_channels_analytics(input)
@@ -49,6 +55,7 @@ async def get_external_channels_analytics(
@analytics_router.get('/spending')
async def get_spending_analytics(
workspace_id: uuid.UUID,
current_user: Annotated[JWTPayload, Depends(deps.get_current_user)],
target_channel_id: uuid.UUID | None = None,
date_from: datetime.datetime | None = None,
@@ -57,6 +64,7 @@ async def get_spending_analytics(
) -> dto.GetSpendingAnalyticsOutput:
input = dto.GetSpendingAnalyticsInput(
user_id=current_user.user_id,
workspace_id=workspace_id,
target_channel_id=target_channel_id,
date_from=date_from,
date_to=date_to,