feat: аналитика
This commit is contained in:
@@ -38,8 +38,36 @@ __all__ = (
|
||||
'FetchViewsManuallyOutput',
|
||||
'UpdateViewsManuallyInput',
|
||||
'UserOutput',
|
||||
'DateGrouping',
|
||||
'PlacementAnalyticsOutput',
|
||||
'CreativeAnalyticsOutput',
|
||||
'ExternalChannelAnalyticsOutput',
|
||||
'GetPlacementsAnalyticsInput',
|
||||
'GetPlacementsAnalyticsOutput',
|
||||
'GetCreativesAnalyticsInput',
|
||||
'GetCreativesAnalyticsOutput',
|
||||
'GetExternalChannelsAnalyticsInput',
|
||||
'GetExternalChannelsAnalyticsOutput',
|
||||
'SpendingDataPoint',
|
||||
'GetSpendingAnalyticsInput',
|
||||
'GetSpendingAnalyticsOutput',
|
||||
)
|
||||
|
||||
from .analytics import (
|
||||
CreativeAnalyticsOutput,
|
||||
DateGrouping,
|
||||
ExternalChannelAnalyticsOutput,
|
||||
GetCreativesAnalyticsInput,
|
||||
GetCreativesAnalyticsOutput,
|
||||
GetExternalChannelsAnalyticsInput,
|
||||
GetExternalChannelsAnalyticsOutput,
|
||||
GetPlacementsAnalyticsInput,
|
||||
GetPlacementsAnalyticsOutput,
|
||||
GetSpendingAnalyticsInput,
|
||||
GetSpendingAnalyticsOutput,
|
||||
PlacementAnalyticsOutput,
|
||||
SpendingDataPoint,
|
||||
)
|
||||
from .creative import (
|
||||
CreateCreativeInput,
|
||||
CreativeOutput,
|
||||
@@ -78,8 +106,8 @@ from .target_channel import (
|
||||
UpdateTargetChanPermissionsInput,
|
||||
)
|
||||
from .telegram_login import TelegramLoginInput
|
||||
from .validate_login_token import ValidateLoginTokenInput, ValidateLoginTokenOutput
|
||||
from .user import UserOutput
|
||||
from .validate_login_token import ValidateLoginTokenInput, ValidateLoginTokenOutput
|
||||
from .views import (
|
||||
FetchViewsInputManually,
|
||||
FetchViewsManuallyOutput,
|
||||
|
||||
105
src/dto/analytics.py
Normal file
105
src/dto/analytics.py
Normal file
@@ -0,0 +1,105 @@
|
||||
import datetime
|
||||
import uuid
|
||||
from enum import StrEnum
|
||||
|
||||
import pydantic
|
||||
|
||||
|
||||
class DateGrouping(StrEnum):
|
||||
DAY = 'day'
|
||||
WEEK = 'week'
|
||||
MONTH = 'month'
|
||||
QUARTER = 'quarter'
|
||||
YEAR = 'year'
|
||||
|
||||
|
||||
class PlacementAnalyticsOutput(pydantic.BaseModel):
|
||||
id: uuid.UUID
|
||||
target_channel_id: uuid.UUID
|
||||
target_channel_title: str
|
||||
external_channel_id: uuid.UUID
|
||||
external_channel_title: str
|
||||
creative_id: uuid.UUID
|
||||
creative_name: str
|
||||
placement_date: datetime.datetime
|
||||
cost: float | None
|
||||
subscriptions_count: int
|
||||
views_count: int | None
|
||||
cpf: float | None
|
||||
cpm: float | None
|
||||
|
||||
|
||||
class CreativeAnalyticsOutput(pydantic.BaseModel):
|
||||
id: uuid.UUID
|
||||
name: str
|
||||
placements_count: int
|
||||
total_cost: float
|
||||
total_subscriptions: int
|
||||
total_views: int
|
||||
avg_cpf: float | None
|
||||
avg_cpm: float | None
|
||||
|
||||
|
||||
class ExternalChannelAnalyticsOutput(pydantic.BaseModel):
|
||||
id: uuid.UUID
|
||||
title: str
|
||||
username: str | None
|
||||
placements_count: int
|
||||
total_cost: float
|
||||
total_subscriptions: int
|
||||
total_views: int
|
||||
avg_cpf: float | None
|
||||
avg_cpm: float | None
|
||||
|
||||
|
||||
class GetPlacementsAnalyticsInput(pydantic.BaseModel):
|
||||
user_id: uuid.UUID
|
||||
target_channel_id: uuid.UUID | None = None
|
||||
|
||||
|
||||
class GetPlacementsAnalyticsOutput(pydantic.BaseModel):
|
||||
placements: list[PlacementAnalyticsOutput]
|
||||
|
||||
|
||||
class GetCreativesAnalyticsInput(pydantic.BaseModel):
|
||||
user_id: uuid.UUID
|
||||
target_channel_id: uuid.UUID | None = None
|
||||
|
||||
|
||||
class GetCreativesAnalyticsOutput(pydantic.BaseModel):
|
||||
creatives: list[CreativeAnalyticsOutput]
|
||||
|
||||
|
||||
class GetExternalChannelsAnalyticsInput(pydantic.BaseModel):
|
||||
user_id: uuid.UUID
|
||||
target_channel_id: uuid.UUID | None = None
|
||||
|
||||
|
||||
class GetExternalChannelsAnalyticsOutput(pydantic.BaseModel):
|
||||
external_channels: list[ExternalChannelAnalyticsOutput]
|
||||
|
||||
|
||||
class SpendingDataPoint(pydantic.BaseModel):
|
||||
period: str
|
||||
cost: float
|
||||
subscriptions: int
|
||||
views: int
|
||||
cpf: float | None
|
||||
cpm: float | None
|
||||
|
||||
|
||||
class GetSpendingAnalyticsInput(pydantic.BaseModel):
|
||||
user_id: uuid.UUID
|
||||
target_channel_id: uuid.UUID | None = None
|
||||
date_from: datetime.datetime | None = None
|
||||
date_to: datetime.datetime | None = None
|
||||
grouping: DateGrouping = DateGrouping.DAY
|
||||
|
||||
|
||||
class GetSpendingAnalyticsOutput(pydantic.BaseModel):
|
||||
total_cost: float
|
||||
total_subscriptions: int
|
||||
total_views: int
|
||||
avg_cpf: float | None
|
||||
avg_cpm: float | None
|
||||
chart_data: list[SpendingDataPoint]
|
||||
Reference in New Issue
Block a user