ref: рефакторинг usecases
This commit is contained in:
@@ -10,18 +10,16 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def get_views_history(self: 'Usecase', input: dto.GetViewsHistoryInput) -> dto.GetViewsHistoryOutput:
|
||||
"""Получить историю просмотров для закупа."""
|
||||
async with self.database.transaction():
|
||||
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)
|
||||
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)
|
||||
|
||||
histories = await self.database.get_views_history(
|
||||
input.placement_id,
|
||||
from_date=input.from_date,
|
||||
to_date=input.to_date,
|
||||
)
|
||||
histories = await self.database.get_views_history(
|
||||
input.placement_id,
|
||||
from_date=input.from_date,
|
||||
to_date=input.to_date,
|
||||
)
|
||||
|
||||
return dto.GetViewsHistoryOutput(
|
||||
histories=[
|
||||
|
||||
Reference in New Issue
Block a user