feat: db constistancy

This commit is contained in:
Artem Tsyrulnikov
2025-12-23 10:38:24 +03:00
parent 45a5b59cc8
commit 829cd82bcf
9 changed files with 253 additions and 195 deletions

View File

@@ -37,6 +37,17 @@ async def fetch_placement_post_cycle(self: 'Usecase', interval_seconds: int) ->
).first()
if matching_post:
# Validate channel consistency
if matching_post.channel_id != placement.placement_channel_id:
log.error(
'Post %s channel_id mismatch: expected %s, got %s. Skipping placement %s',
matching_post.id,
placement.placement_channel_id,
matching_post.channel_id,
placement.id,
)
continue
placement.post = matching_post
await placement.save()
updated_count += 1