nordabiz/database/migrations/083_zopk_cleanup.sql
Maciej Pienczyn 55088f0ccb
Some checks are pending
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
fix: ZOPK knowledge base image display and data quality issues
- Fix broken news thumbnails by adding og:image extraction during content
  scraping (replaces Brave proxy URLs that block hotlinking)
- Add image onerror fallback in templates showing domain favicon when
  original image fails to load
- Decode Brave proxy image URLs to original source URLs before saving
- Enforce English-only entity types in AI extraction prompt to prevent
  mixed Polish/English type names
- Add migration 083 to normalize 14 existing Polish entity types and
  clean up 5 stale fetch jobs stuck in 'running' status
- Add backfill script for existing articles with broken image URLs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 08:57:41 +01:00

30 lines
1.4 KiB
SQL

-- Migration 083: ZOPK data cleanup and normalization
-- Date: 2026-03-15
-- Description:
-- 1. Normalize entity types (Polish → English)
-- 2. Clean up stale fetch jobs
-- 3. Grant permissions
-- ============================================================
-- 1. Normalize entity types (Polish → English)
-- ============================================================
UPDATE zopk_knowledge_entities SET entity_type = 'organization' WHERE entity_type = 'Organizacja';
UPDATE zopk_knowledge_entities SET entity_type = 'place' WHERE entity_type = 'Lokalizacja';
UPDATE zopk_knowledge_entities SET entity_type = 'person' WHERE entity_type = 'Osoba';
UPDATE zopk_knowledge_entities SET entity_type = 'project' WHERE entity_type = 'Projekt';
UPDATE zopk_knowledge_entities SET entity_type = 'company' WHERE entity_type = 'Dokument/Umowa';
UPDATE zopk_knowledge_entities SET entity_type = 'organization' WHERE entity_type = 'Kraj/Narodowość';
UPDATE zopk_knowledge_entities SET entity_type = 'technology' WHERE entity_type = 'Element techniczny';
-- ============================================================
-- 2. Clean up stale fetch jobs (stuck in 'running' status)
-- ============================================================
UPDATE zopk_news_fetch_jobs
SET status = 'failed',
error_message = 'Automatycznie zakończony — utknął w statusie running',
completed_at = NOW()
WHERE status = 'running'
AND started_at < NOW() - INTERVAL '1 hour';