fix: Split combined URLs in company_websites, use relationship in banner
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

Migration 067 copied comma-separated URLs as single records.
067b splits them into individual rows and syncs companies.website.
Banner now uses primary from relationship instead of company.website.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Maciej Pienczyn 2026-02-17 07:52:39 +01:00
parent 7e570e0492
commit b877773b69
2 changed files with 60 additions and 9 deletions

View File

@ -0,0 +1,51 @@
-- Migration 067b: Fix combined URLs that were migrated as single records
-- Split comma/space-separated URLs into individual rows
-- Date: 2026-02-17
-- Step 1: Insert split URLs as separate rows (non-primary)
-- Handles patterns like "https://a.pl, https://b.pl" or "https://a.pl https://b.pl"
INSERT INTO company_websites (company_id, url, is_primary, source, created_at)
SELECT cw.company_id,
trim(both ' ' from unnest(
string_to_array(
regexp_replace(cw.url, ',\s*', ',', 'g'),
','
)
)) as split_url,
FALSE,
'migration_fix',
NOW()
FROM company_websites cw
WHERE cw.url LIKE '%,%'
AND cw.source = 'migration';
-- Step 2: Delete the original combined rows
DELETE FROM company_websites
WHERE url LIKE '%,%'
AND source = 'migration';
-- Step 3: Mark the first URL per company as primary (if none is primary)
UPDATE company_websites cw
SET is_primary = TRUE
WHERE cw.id = (
SELECT min(cw2.id)
FROM company_websites cw2
WHERE cw2.company_id = cw.company_id
)
AND NOT EXISTS (
SELECT 1 FROM company_websites cw3
WHERE cw3.company_id = cw.company_id AND cw3.is_primary = TRUE
);
-- Step 4: Sync companies.website with the primary URL
UPDATE companies c
SET website = (
SELECT cw.url
FROM company_websites cw
WHERE cw.company_id = c.id AND cw.is_primary = TRUE
LIMIT 1
)
WHERE EXISTS (
SELECT 1 FROM company_websites cw
WHERE cw.company_id = c.id AND cw.is_primary = TRUE
);

View File

@ -2468,12 +2468,14 @@
{% endif %} {# END REKOMENDACJE DISABLED #}
<!-- Unified Website Section -->
{% if company.website and website_analysis %}
{% set primary_website = company.websites|selectattr('is_primary')|first if company.websites else none %}
{% set primary_url = primary_website.url if primary_website else company.website %}
{% if primary_url and website_analysis %}
<div class="company-section">
<h2 class="section-title">Strona WWW</h2>
<!-- Website URL - prominent display -->
<div style="margin-bottom: var(--spacing-lg); padding: var(--spacing-lg); background: linear-gradient(135deg, #3b82f6, #1d4ed8); border-radius: var(--radius-lg); display: flex; align-items: center; gap: var(--spacing-md);">
<!-- Primary website - prominent display -->
<div style="margin-bottom: var(--spacing-md); padding: var(--spacing-lg); background: linear-gradient(135deg, #3b82f6, #1d4ed8); border-radius: var(--radius-lg); display: flex; align-items: center; gap: var(--spacing-md);">
<div style="width: 56px; height: 56px; border-radius: 12px; background: rgba(255,255,255,0.2); display: flex; align-items: center; justify-content: center;">
<svg width="28" height="28" fill="white" viewBox="0 0 24 24">
<circle cx="12" cy="12" r="10" fill="none" stroke="white" stroke-width="2"/>
@ -2481,16 +2483,16 @@
</svg>
</div>
<div style="flex: 1;">
<div style="font-size: var(--font-size-sm); color: rgba(255,255,255,0.8); margin-bottom: 4px;">Adres strony</div>
<a href="{{ company.website|ensure_url }}" target="_blank" rel="noopener noreferrer"
<div style="font-size: var(--font-size-sm); color: rgba(255,255,255,0.8); margin-bottom: 4px;">Adres strony{% if primary_website and primary_website.label %} &mdash; {{ primary_website.label }}{% endif %}</div>
<a href="{{ primary_url|ensure_url }}" target="_blank" rel="noopener noreferrer"
style="font-size: var(--font-size-xl); font-weight: 600; color: white; text-decoration: none; display: flex; align-items: center; gap: var(--spacing-sm);">
{{ company.website|replace('https://', '')|replace('http://', '')|replace('www.', '') }}
{{ primary_url|replace('https://', '')|replace('http://', '')|replace('www.', '') }}
<svg width="20" height="20" fill="white" viewBox="0 0 24 24" style="opacity: 0.8;">
<path d="M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z"/>
</svg>
</a>
</div>
<a href="{{ company.website|ensure_url }}" target="_blank" rel="noopener noreferrer"
<a href="{{ primary_url|ensure_url }}" target="_blank" rel="noopener noreferrer"
style="padding: var(--spacing-sm) var(--spacing-lg); background: white; color: #1d4ed8; border-radius: var(--radius); text-decoration: none; font-weight: 600; font-size: var(--font-size-sm);">
Odwiedź stronę
</a>
@ -2499,7 +2501,6 @@
<!-- Additional websites -->
{% if company.websites %}
{% set extra_websites = company.websites|rejectattr('is_primary')|list %}
{% if extra_websites %}
{% for w in extra_websites %}
<div style="margin-bottom: var(--spacing-md); padding: var(--spacing-md) var(--spacing-lg); background: linear-gradient(135deg, #64748b, #475569); border-radius: var(--radius-lg); display: flex; align-items: center; gap: var(--spacing-md);">
<div style="width: 40px; height: 40px; border-radius: 10px; background: rgba(255,255,255,0.2); display: flex; align-items: center; justify-content: center;">
@ -2525,7 +2526,6 @@
</div>
{% endfor %}
{% endif %}
{% endif %}
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--spacing-lg);">