fix: preserve existing FB URL when API lacks link field, show more profile data
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

- Don't overwrite vanity URL with numeric page_id fallback
- Display profile description and completeness bar on Facebook card

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Maciej Pienczyn 2026-02-19 14:03:08 +01:00
parent 592ceff30d
commit 553c48b054
2 changed files with 26 additions and 2 deletions

View File

@ -352,7 +352,8 @@ def sync_facebook_to_social_media(db, company_id: int) -> dict:
if page_info.get('single_line_address'):
completeness += 25
page_url = page_info.get('link') or f"https://facebook.com/{page_id}"
# URL: prefer API link, then existing URL, then numeric fallback
api_link = page_info.get('link')
# 6. Upsert CompanySocialMedia record
# Look for existing Facebook record for this company (any URL)
@ -365,8 +366,12 @@ def sync_facebook_to_social_media(db, company_id: int) -> dict:
if existing:
csm = existing
csm.url = page_url
# Only update URL if API returned a proper link (not numeric fallback)
if api_link:
csm.url = api_link
# Keep existing URL if API didn't return link
else:
page_url = api_link or f"https://facebook.com/{page_id}"
csm = CompanySocialMedia(
company_id=company_id,
platform='facebook',

View File

@ -2627,6 +2627,25 @@
</div>
</div>
{% if sm.profile_description %}
<div style="margin-bottom: var(--spacing-sm);">
<span style="font-size: var(--font-size-sm); color: var(--text-secondary);">Opis:</span>
<div style="font-size: var(--font-size-sm); color: var(--text-primary); line-height: 1.4;">{{ sm.profile_description|truncate(200) }}</div>
</div>
{% endif %}
{% if sm.source == 'facebook_api' and sm.profile_completeness_score is not none %}
<div style="margin-bottom: var(--spacing-sm);">
<span style="font-size: var(--font-size-sm); color: var(--text-secondary);">Kompletność profilu:</span>
<div style="display: flex; align-items: center; gap: var(--spacing-sm); margin-top: 4px;">
<div style="flex: 1; height: 6px; background: #e5e7eb; border-radius: 3px; overflow: hidden;">
<div style="height: 100%; width: {{ sm.profile_completeness_score }}%; background: {% if sm.profile_completeness_score >= 75 %}#10b981{% elif sm.profile_completeness_score >= 50 %}#f59e0b{% else %}#ef4444{% endif %}; border-radius: 3px;"></div>
</div>
<span style="font-size: var(--font-size-xs); font-weight: 600; color: var(--text-secondary);">{{ sm.profile_completeness_score }}%</span>
</div>
</div>
{% endif %}
{% if sm.followers_count %}
<div style="display: flex; gap: var(--spacing-lg); margin-top: var(--spacing-md); padding-top: var(--spacing-md); border-top: 1px solid var(--border);">
<div style="text-align: center;">