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

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

@@ -34,8 +34,8 @@ async def get_placements(self: 'Usecase', input: dto.GetPlacementsInput) -> dto.
placement_ids,
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_counts = await self.database.count_subscriptions_by_placement_batch(placement_ids)
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 {}
@@ -46,7 +46,7 @@ async def get_placements(self: 'Usecase', input: dto.GetPlacementsInput) -> dto.
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_counts.get(placement_post.placement_id, 0),
views_count,
)
if placement_post_output is None: