подписки сразу отслеживаются

This commit is contained in:
Artem Tsyrulnikov
2026-01-28 11:42:09 +03:00
parent 2d35588a85
commit 0b25566ffb
9 changed files with 205 additions and 47 deletions

View File

@@ -74,8 +74,8 @@ async def get_placement_user(self: 'Usecase', input: dto.GetPlacementInput) -> d
placement_id=placement.id,
include_archived=True,
)
placement_post_ids = [post.id for post in placement_posts]
subscriptions_counts = await self.database.count_subscriptions_by_placement_post_batch(placement_post_ids)
# Подсчёт подписок по placement_id (один Placement = одна ссылка = один счётчик подписок)
subscriptions_count = await self.database.count_subscriptions_by_placement(placement.id)
post_ids = [placement_post.post.id for placement_post in placement_posts if placement_post.post]
views_map = await self.database.get_latest_views_data_batch(post_ids) if post_ids else {}
@@ -89,7 +89,7 @@ async def get_placement_user(self: 'Usecase', input: dto.GetPlacementInput) -> d
views_count = views_map.get(placement_post.post.id, (None,))[0]
placement_post_output = _build_placement_post_output(
placement_post,
subscriptions_counts.get(placement_post.id, 0),
subscriptions_count,
views_count,
)
if placement_post_output is not None: