fix: JSONB mutation not detected by SQLAlchemy — copy dict/list before modifying
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions

content_types and followers_history were mutated in-place on the same
object reference, so SQLAlchemy didn't detect changes and skipped the
UPDATE. Now creates a fresh copy before modifying.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Maciej Pienczyn 2026-03-12 13:16:58 +01:00
parent e07556fd22
commit ee428310f5

View File

@ -586,7 +586,7 @@ def sync_facebook_to_social_media(db, company_id: int) -> dict:
csm.last_checked_at = now csm.last_checked_at = now
# Store all API fields in content_types JSONB (no migration needed) # Store all API fields in content_types JSONB (no migration needed)
extra = csm.content_types or {} extra = dict(csm.content_types or {})
# Page info fields # Page info fields
for key in ('category', 'website', 'phone', 'founded', 'mission'): for key in ('category', 'website', 'phone', 'founded', 'mission'):
if page_info.get(key): if page_info.get(key):
@ -639,7 +639,7 @@ def sync_facebook_to_social_media(db, company_id: int) -> dict:
csm.content_types = extra csm.content_types = extra
# Append to followers_history # Append to followers_history
history = csm.followers_history or [] history = list(csm.followers_history or [])
if followers > 0: if followers > 0:
today_str = now.strftime('%Y-%m-%d') today_str = now.strftime('%Y-%m-%d')
# Don't duplicate entries for the same day # Don't duplicate entries for the same day