Files
politics-tracking/backend/migrations/0010_data_fixes_orf_fee_legal.sql
T
simonandClaude Opus 5.5 f2d72fe464 fixes: immunity outcomes without political connection, ORF fee rows, dropped WKStA investigations
- parlament.items (parser 3): a committee finding of no connection to the political activity
  (Art. 57 Abs. 3 B-VG) means prosecution may proceed; it was left at 'requested'. Authority and
  case number no longer run into the following sentence on older reports.
- rtr.medientransparenz (parser 2): notice type 31 is the ORF's licence-fee income under section 31
  ORF-G, not a payment to an organisation named after the paragraph.
- enrich.legal: 'Einstellung der Ermittlungen' is proceedings_dropped, not an investigation.
- reparse -p kinds=a,b replays only responses of these request kinds (no stale sweep then).
- migration 0010 removes the wrong ORF rows and organisations and re-queues the affected headlines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 10:03:11 +01:00

29 lines
2.0 KiB
SQL

-- Data fixes that go with parser changes of November 2026.
-- 1. RTR notice type 31 (§ 31 ORF-G) is the ORF's licence-fee income. It was stored as a "payment" from the ORF to
-- an organisation named after the legal basis. rtr.medientransparenz (parser_version 2) now emits it as ORF income;
-- `politrack reparse rtr.medientransparenz -p kinds=quartal` recreates the rows.
DELETE FROM claim c USING money_flow mf
WHERE mf.claim_id = c.id AND c.created_by = 'rtr.medientransparenz' AND mf.kind = 'other'
AND mf.payee_name ~ '§ 31 Abs\. [0-9]+ ORF-G';
DELETE FROM alias WHERE entity_type = 'organization'
AND entity_id IN (SELECT id FROM organization WHERE name ~ '^(Programmentgelt|Abgeltung) gemäß § 31 Abs\. [0-9]+ ORF-G$');
DELETE FROM identifier WHERE entity_type = 'organization'
AND entity_id IN (SELECT id FROM organization WHERE name ~ '^(Programmentgelt|Abgeltung) gemäß § 31 Abs\. [0-9]+ ORF-G$');
DELETE FROM organization o
WHERE o.name ~ '^(Programmentgelt|Abgeltung) gemäß § 31 Abs\. [0-9]+ ORF-G$'
AND NOT EXISTS (SELECT 1 FROM claim c WHERE c.organization_id = o.id OR c.counterpart_org_id = o.id)
AND NOT EXISTS (SELECT 1 FROM money_flow m WHERE m.payer_org_id = o.id OR m.payee_org_id = o.id);
-- 2. enrich.legal read "Einstellung der Ermittlungen" (proceedings dropped) as an investigation. Drop those unreviewed
-- proposals and let the enricher look at the headlines again.
DELETE FROM claim c
WHERE c.created_by = 'enrich.legal' AND c.review_status = 'pending'
AND EXISTS (SELECT 1 FROM claim_evidence e JOIN document d ON d.id = e.document_id
WHERE e.claim_id = c.id AND d.title ~* 'Einstellung(en)?\M.{0,40}(Verfahren|Ermittlung)');
UPDATE claim c SET data = c.data - 'legal_checked'
WHERE c.claim_type = 'media_mention' AND c.data ? 'legal_checked'
AND EXISTS (SELECT 1 FROM claim_evidence e JOIN document d ON d.id = e.document_id
WHERE e.claim_id = c.id AND d.title ~* 'Einstellung(en)?\M.{0,40}(Verfahren|Ermittlung)');