{% extends "base.html" %} {% block title %}Audyt Social Media - {{ company.name }} - Norda Biznes Partner{% endblock %} {% block extra_css %} {% endblock %} {% block content %}
Powrót do audytu

{{ company.name }}

{% if company.website %} {{ company.website }} {% endif %}
Profil firmy
{{ platform_details|length }} Platform
{{ "{:,}".format(platform_details|sum(attribute='followers_count')).replace(",", " ") }} Obserwujących
{% set total_posts = platform_details|sum(attribute='posts_count_30d') %} {{ total_posts }} Postów (30 dni)
{% set comp_scores = platform_details|selectattr('profile_completeness_score', 'gt', 0)|map(attribute='profile_completeness_score')|list %} {% set avg_comp = (comp_scores|sum / comp_scores|length)|round|int if comp_scores else 0 %} {{ avg_comp }}% Śr. kompletność
{% set eng_rates = platform_details|selectattr('engagement_rate', 'gt', 0)|map(attribute='engagement_rate')|list %} {% set avg_eng = (eng_rates|sum / eng_rates|length)|round(2) if eng_rates else 0 %} {{ avg_eng }}% Śr. engagement
{% if company_scores and platform_details %}
{{ company_scores.health_score }}
Social Health Score
{% if company_scores.health_score >= 60 %}Dobra kondycja {% elif company_scores.health_score >= 30 %}Wymaga uwagi {% else %}Pilne do poprawy{% endif %}
{{ company_scores.activity_label }}
Aktywność
{{ company_scores.cross_platform_score }}%
Cross-platform
{% for p in platform_details %} {% if p.followers_growth_trend != 'unknown' %}
{% if p.followers_growth_trend == 'up' %}▲{% elif p.followers_growth_trend == 'down' %}▼{% else %}●{% endif %} {{ p.followers_growth_rate }}%
{{ p.platform|capitalize }} wzrost
{% endif %} {% endfor %}
{% endif %} {% if recommendations %}

Zalecenia

{% for rec in recommendations %}
{% if rec.severity == 'critical' %} {% elif rec.severity == 'warning' %} {% else %} {% endif %} {{ rec.text }}
{% endfor %}
{% endif %}

Profile social media

{% if platform_details %} {% set platform_icons = { 'facebook': '', 'instagram': '', 'linkedin': '', 'youtube': '', 'twitter': '', 'tiktok': '' } %} {% for p in platform_details %}
{{ platform_icons[p.platform]|safe }}

{{ p.platform|capitalize }}{% if p.page_name %} — {{ p.page_name }}{% endif %}

{{ p.url }}
{% if p.check_status == 'needs_verification' %} Do weryfikacji {% endif %}
{{ "{:,}".format(p.followers_count).replace(",", " ") }} {% if p.followers_growth_trend != 'unknown' %} {% if p.followers_growth_trend == 'up' %}▲{% elif p.followers_growth_trend == 'down' %}▼{% else %}—{% endif %} {{ p.followers_growth_rate }}% {% endif %}
Obserwujących
{{ p.engagement_rate }}%
Engagement rate
{{ p.activity_label }}
Status aktywności
{{ p.posts_count_30d }}
Postów (30 dni)
{{ p.posts_count_365d }}
Postów (rok)
{{ p.posting_frequency_score }}/10
Regularność
{% if p.last_post_date %} {{ p.last_post_date.strftime('%d.%m.%Y') }} {% else %} b/d {% endif %}
Ostatni post
{% if p.profile_completeness_score > 0 %}
Kompletność profilu: {{ p.profile_completeness_score }}%
{% endif %}
{% if p.has_profile_photo is not none %} {{ '✓' if p.has_profile_photo else '✗' }} Zdjęcie profilowe {% else %} ? Zdjęcie profilowe {% endif %} {% if p.has_cover_photo is not none %} {{ '✓' if p.has_cover_photo else '✗' }} Zdjęcie w tle {% else %} ? Zdjęcie w tle {% endif %} {% if p.has_bio is not none %} {{ '✓' if p.has_bio else '✗' }} Opis / bio {% else %} ? Opis / bio {% endif %}
{% if p.profile_description %}
{{ p.profile_description[:300] }}{% if p.profile_description|length > 300 %}...{% endif %}
{% endif %} {% if p.content_types %} {% set ct = p.content_types %} {% set info_fields = [] %} {% if ct.get('phone') %}{% if info_fields.append(('📞', ct.phone)) %}{% endif %}{% endif %} {% if ct.get('emails') %}{% for e in ct.emails %}{% if info_fields.append(('✉️', e)) %}{% endif %}{% endfor %}{% endif %} {% if ct.get('address') %}{% if info_fields.append(('📍', ct.address)) %}{% endif %}{% endif %} {% if ct.get('website') %}{% if info_fields.append(('🌐', ct.website)) %}{% endif %}{% endif %} {% if ct.get('category') %}{% if info_fields.append(('🏷️', ct.category)) %}{% endif %}{% endif %} {% if ct.get('founded') %}{% if info_fields.append(('📅', 'Założono: ' ~ ct.founded)) %}{% endif %}{% endif %} {% if ct.get('price_range') %}{% if info_fields.append(('💰', 'Ceny: ' ~ ct.price_range)) %}{% endif %}{% endif %} {% if ct.get('hours') %}{% if info_fields.append(('🕐', 'Godziny otwarcia ustawione')) %}{% endif %}{% endif %} {% if ct.get('username') %}{% if info_fields.append(('🔗', '@' ~ ct.username)) %}{% endif %}{% endif %} {% if ct.get('verification_status') == 'blue_verified' or ct.get('is_verified') %}{% if info_fields.append(('✅', 'Zweryfikowana')) %}{% endif %}{% endif %} {% if info_fields %}
{% for icon, val in info_fields %} {{ icon }} {{ val }} {% endfor %}
{% endif %} {% if ct.get('talking_about_count') or ct.get('overall_star_rating') or ct.get('were_here_count') or ct.get('category_list') %}
{% if ct.get('talking_about_count') %} 🗣️ {{ ct.talking_about_count }} interakcji (7 dni) {% endif %} {% if ct.get('overall_star_rating') %} ⭐ {{ ct.overall_star_rating }}/5 {% if ct.get('rating_count') %}({{ ct.rating_count }} ocen){% endif %} {% endif %} {% if ct.get('were_here_count') %} 📌 {{ "{:,}".format(ct.were_here_count).replace(",", " ") }} zameldowań {% endif %} {% if ct.get('category_list') %} 🏷️ {{ ct.category_list|join(', ') }} {% endif %}
{% endif %} {% if ct.get('total_likes') or ct.get('total_comments') or ct.get('total_shares') %}
Zaangażowanie w posty (rok)
👍 {{ ct.total_likes }} polubień postów 💬 {{ ct.total_comments }} komentarzy 🔄 {{ ct.total_shares }} udostępnień
{% endif %} {% if ct.get('post_types') %}
{% for ptype, count in ct.post_types.items() %} {{ ptype }}: {{ count }} {% endfor %}
{% endif %} {# Meta deprecated impressions metrics on 2026-06-30. New: page_media_view, page_total_media_view_unique. Fallback to old keys for historical data. #} {% set page_views_metric = ct.get('insights_page_total_media_view_unique') or ct.get('insights_page_impressions') %} {% set page_video_metric = ct.get('insights_page_media_view') or ct.get('insights_page_video_views') %} {% set page_reach_metric = ct.get('insights_page_posts_impressions') %} {% set has_insights = page_views_metric or ct.get('insights_page_views_total') or ct.get('insights_page_post_engagements') or page_reach_metric or ct.get('insights_page_daily_follows') %} {% if has_insights %}
📊 Insights (28 dni)
{% if page_reach_metric %}{{ "{:,}".format(page_reach_metric).replace(",", " ") }} zasięg postów{% endif %} {% if page_views_metric %}{{ "{:,}".format(page_views_metric).replace(",", " ") }} wyświetleń strony{% endif %} {% if ct.get('insights_page_views_total') %}{{ "{:,}".format(ct.insights_page_views_total).replace(",", " ") }} odsłon strony{% endif %} {% if ct.get('insights_page_post_engagements') %}{{ "{:,}".format(ct.insights_page_post_engagements).replace(",", " ") }} interakcji{% endif %} {% if page_video_metric %}{{ "{:,}".format(page_video_metric).replace(",", " ") }} odsłon wideo{% endif %} {% if ct.get('insights_page_daily_follows') %}+{{ ct.insights_page_daily_follows }} nowych obserwujących{% endif %} {% if ct.get('insights_page_daily_unfollows') %}-{{ ct.insights_page_daily_unfollows }} utraconych{% endif %} {% if ct.get('insights_page_fan_adds') %}+{{ ct.insights_page_fan_adds }} nowych fanów{% endif %} {% if ct.get('insights_page_fan_removes') %}-{{ ct.insights_page_fan_removes }} utraconych fanów{% endif %}
{% endif %} {% if ct.get('recent_posts') %}
Ostatnie posty
{% for rp in ct.recent_posts %}
{{ rp.date }} {{ rp.type }} {{ rp.title or '(bez tekstu)' }} 👍{{ rp.likes }} 💬{{ rp.comments }} 🔄{{ rp.shares }}
{% endfor %}
{% endif %} {% if p.platform == 'instagram' and (ct.get('follows_count') or ct.get('media_count') or ct.get('media_types')) %}
{% set ig_info = [] %} {% if ct.get('media_count') %}{% if ig_info.append(('📸', '{:,}'.format(ct.media_count).replace(',', ' ') ~ ' postów łącznie')) %}{% endif %}{% endif %} {% if ct.get('follows_count') %}{% if ig_info.append(('👤', '{:,}'.format(ct.follows_count).replace(',', ' ') ~ ' obserwowanych')) %}{% endif %}{% endif %} {% if ct.get('website') %}{% if ig_info.append(('🔗', ct.website)) %}{% endif %}{% endif %} {% if ct.get('media_types') %} {% set types_str = [] %} {% for mt, cnt in ct.media_types.items() %}{% if types_str.append(mt ~ ': ' ~ cnt) %}{% endif %}{% endfor %} {% if ig_info.append(('🎬', types_str|join(', '))) %}{% endif %} {% endif %} {% if ct.get('ig_reach_total') %}{% if ig_info.append(('📊', '{:,}'.format(ct.ig_reach_total).replace(',', ' ') ~ ' zasięg (28d)')) %}{% endif %}{% endif %} {% if ct.get('ig_impressions_total') %}{% if ig_info.append(('👁️', '{:,}'.format(ct.ig_impressions_total).replace(',', ' ') ~ ' wyświetleń (28d)')) %}{% endif %}{% endif %} {% if ig_info %}
{% for icon, val in ig_info %} {{ icon }} {{ val }} {% endfor %}
{% endif %} {% if ct.get('recent_posts') %}
Ostatnie posty
{% for post in ct.recent_posts %}
{{ post.date }} {{ post.caption or '(bez opisu)' }} ❤️{{ post.likes }} 💬{{ post.comments }} {% if post.permalink %} ↗ Zobacz {% endif %}
{% endfor %} {% endif %}
{% endif %} {% if p.platform == 'twitter' and (ct.get('following_count') or ct.get('location') or ct.get('media_count')) %}
{% set tw_info = [] %} {% if ct.get('following_count') %}{% if tw_info.append(('👤', '{:,}'.format(ct.following_count).replace(',', ' ') ~ ' obserwowanych')) %}{% endif %}{% endif %} {% if ct.get('media_count') %}{% if tw_info.append(('🖼️', '{:,}'.format(ct.media_count).replace(',', ' ') ~ ' mediów')) %}{% endif %}{% endif %} {% if ct.get('favourites_count') %}{% if tw_info.append(('❤️', '{:,}'.format(ct.favourites_count).replace(',', ' ') ~ ' polubień')) %}{% endif %}{% endif %} {% if ct.get('listed_count') %}{% if tw_info.append(('📋', '{:,}'.format(ct.listed_count).replace(',', ' ') ~ ' list')) %}{% endif %}{% endif %} {% if ct.get('location') %}{% if tw_info.append(('📍', ct.location)) %}{% endif %}{% endif %} {% if ct.get('created_at') %}{% if tw_info.append(('📅', 'Konto od: ' ~ ct.created_at[:16])) %}{% endif %}{% endif %} {% if ct.get('verified') %}{% if tw_info.append(('✓', 'Zweryfikowany')) %}{% endif %}{% endif %} {% if tw_info %}
{% for icon, val in tw_info %} {{ icon }} {{ val }} {% endfor %}
{% endif %}
{% endif %} {% if ct.get('view_count') or ct.get('recent_videos') %}
{% set yt_info = [] %} {% if ct.get('view_count') %}{% if yt_info.append(('👁️', '{:,}'.format(ct.view_count).replace(',', ' ') ~ ' wyświetleń łącznie')) %}{% endif %}{% endif %} {% if ct.get('country') %}{% if yt_info.append(('🌍', ct.country)) %}{% endif %}{% endif %} {% if ct.get('published_at') %}{% if yt_info.append(('📅', 'Kanał od: ' ~ ct.published_at)) %}{% endif %}{% endif %} {% if ct.get('custom_url') %}{% if yt_info.append(('🔗', ct.custom_url)) %}{% endif %}{% endif %} {% if yt_info %}
{% for icon, val in yt_info %} {{ icon }} {{ val }} {% endfor %}
{% endif %} {% if ct.get('recent_videos') %}
Ostatnie filmy
{% for vid in ct.recent_videos %}
{{ vid.date }} {{ vid.title or '(bez tytułu)' }} {% if vid.video_id %} ▶ Oglądaj {% endif %}
{% endfor %} {% endif %}
{% endif %} {% endif %}
{% if p.source_icon == 'api' %} {% elif p.source_icon == 'scrape' %} {% elif p.source_icon == 'manual' %} {% else %} {% endif %} {{ p.source_label }} Priorytet: {{ p.source_priority }}/3
{% if p.verified_at %}
Zweryfikowano: {{ p.verified_at|local_time('%d.%m.%Y %H:%M') }}
{% endif %} {% if p.last_checked_at %}
Ostatni check: {{ p.last_checked_at|local_time('%d.%m.%Y %H:%M') }}
{% endif %}
Status HTTP: {{ p.check_status or 'ok' }}
{% if p.oauth_available %} {% if p.oauth_connected and not p.oauth_expired %}
OAuth połączony {% if p.oauth_account_name %} ({{ p.oauth_account_name }}) {% endif %} {% if p.oauth_page_configured %} ✓ Strona skonfigurowana {% else %} Wybierz stronę → {% endif %} {% if p.oauth_last_sync %} Sync: {{ p.oauth_last_sync|local_time('%d.%m.%Y') }} {% endif %}
{% elif p.oauth_connected and p.oauth_expired %}
Token OAuth wygasł Odnów połączenie →
{% else %}
Połącz {{ p.platform|capitalize }} API przez OAuth, aby uzyskać dokładne dane (followers, engagement, insights). Połącz OAuth →
{% endif %} {% else %}
{% if p.platform == 'instagram' %} Dane Instagram wymagają połączenia z Meta API. Aby pobierać statystyki: (1) konto IG musi być typu Business/Creator, (2) musi być powiązane ze stroną Facebook firmy, (3) firma musi mieć podłączony Facebook OAuth na portalu. {% elif p.platform == 'twitter' %} Dane pobierane automatycznie przez Twitter API (bez OAuth). Uruchom skan, aby pobrać aktualne statystyki. {% elif p.platform == 'youtube' %} Dane pobierane automatycznie przez YouTube Data API v3 (bez OAuth). Uruchom skan, aby pobrać aktualne statystyki. {% elif p.platform == 'facebook' %} Facebook blokuje publiczny dostęp. Podłącz Graph API (OAuth) w ustawieniach firmy, aby pobierać dane. {% else %} OAuth API niedostępne dla {{ p.platform|capitalize }}. Dane pochodzą ze scrapingu publicznych profili. {% endif %}
{% endif %}
{% endfor %} {% else %}

Firma nie ma żadnych profili social media.

{% endif %}
{% if invalid_profiles %}

Nieaktywne / nieważne profile ({{ invalid_profiles|length }})

{% for p in invalid_profiles %}
{{ p.platform }} {{ p.url|truncate(60) }} {{ p.check_status or 'invalid' }}
{% endfor %}
{% endif %}
{% endblock %} {% block extra_js %} function runSingleEnrichment(companyId) { var btn = document.getElementById('enrichSingleBtn'); btn.disabled = true; btn.innerHTML = ' Audytowanie...'; fetch('{{ url_for("admin.admin_social_audit_run_enrichment") }}', { method: 'POST', headers: {'Content-Type': 'application/x-www-form-urlencoded', 'X-CSRFToken': '{{ csrf_token() }}'}, body: 'company_ids=' + companyId }) .then(function(r) { return r.json(); }) .then(function(data) { if (data.status === 'started') { pollSingleEnrichment(); } else { btn.disabled = false; btn.textContent = data.error || 'Błąd'; setTimeout(function() { btn.textContent = 'Uruchom audyt'; }, 3000); } }) .catch(function(e) { btn.disabled = false; btn.textContent = 'Błąd: ' + e.message; setTimeout(function() { btn.textContent = 'Uruchom audyt'; }, 3000); }); } function pollSingleEnrichment() { var btn = document.getElementById('enrichSingleBtn'); fetch('{{ url_for("admin.admin_social_audit_enrichment_status") }}') .then(function(r) { return r.json(); }) .then(function(data) { if (data.running) { var pct = data.progress || 0; btn.innerHTML = ' ' + pct + '% (' + data.completed + '/' + data.total + ')'; setTimeout(pollSingleEnrichment, 1500); } else if (data.pending_count > 0) { window.location.href = '{{ url_for("admin.admin_social_audit_enrichment_review") }}'; } else if (data.api_synced_count > 0) { btn.textContent = 'Zsynchronizowano! Odświeżam...'; setTimeout(function() { window.location.reload(); }, 1000); } else { btn.disabled = false; btn.textContent = 'Brak nowych danych'; setTimeout(function() { btn.textContent = 'Uruchom audyt'; }, 5000); } }); } {% endblock %}