feat: доменный нейминг изменен
This commit is contained in:
@@ -12,26 +12,26 @@ log = logging.getLogger(__name__)
|
||||
async def get_views_history(self: 'Usecase', input: dto.GetViewsHistoryInput) -> dto.GetViewsHistoryOutput:
|
||||
"""Получить историю просмотров для закупа."""
|
||||
async with self.database.transaction():
|
||||
purchase = await self.database.get_purchase(input.user_id, input.purchase_id)
|
||||
if not purchase:
|
||||
log.warning('Purchase %s not found for user %s', input.purchase_id, input.user_id)
|
||||
raise domain.PurchaseNotFound(input.purchase_id)
|
||||
placement = await self.database.get_placement(input.user_id, input.placement_id)
|
||||
if not placement:
|
||||
log.warning('Placement %s not found for user %s', input.placement_id, input.user_id)
|
||||
raise domain.PlacementNotFound(input.placement_id)
|
||||
|
||||
snapshots = await self.database.get_views_history(
|
||||
input.purchase_id,
|
||||
histories = await self.database.get_views_history(
|
||||
input.placement_id,
|
||||
from_date=input.from_date,
|
||||
to_date=input.to_date,
|
||||
)
|
||||
|
||||
return dto.GetViewsHistoryOutput(
|
||||
snapshots=[
|
||||
dto.ViewsSnapshotOutput(
|
||||
id=snapshot.id,
|
||||
purchase_id=snapshot.purchase_id,
|
||||
views_count=snapshot.views_count,
|
||||
fetched_at=snapshot.fetched_at,
|
||||
created_at=snapshot.created_at,
|
||||
histories=[
|
||||
dto.PlacementViewsHistoryOutput(
|
||||
id=history.id,
|
||||
placement_id=history.placement_id,
|
||||
views_count=history.views_count,
|
||||
fetched_at=history.fetched_at,
|
||||
created_at=history.created_at,
|
||||
)
|
||||
for snapshot in snapshots
|
||||
for history in histories
|
||||
]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user