-- RSS focus: alleen kant-en-klaar maaltijden & supermarkten (geen algemeen nieuws)

UPDATE rss_feeds SET is_active = FALSE WHERE name IN ('Nu.nl Economie', 'Foodlog NL', 'VMT Food');

UPDATE rss_feeds SET
  url = 'https://news.google.com/rss/search?q=kant+en+klaar+maaltijd+supermarkt+nederland&hl=nl&gl=NL&ceid=NL:nl',
  category = 'kant-en-klaar',
  is_active = TRUE
WHERE name = 'Google Halal Food NL';

UPDATE rss_feeds SET name = 'Google Kant-en-klaar NL' WHERE name = 'Google Halal Food NL';

UPDATE rss_feeds SET category = 'supermarkt', is_active = TRUE WHERE name = 'RetailDetail';

INSERT INTO rss_feeds (name, url, category, is_active) VALUES
  ('Google Supermarkt Retail NL', 'https://news.google.com/rss/search?q=supermarkt+retail+nederland+maaltijd&hl=nl&gl=NL&ceid=NL:nl', 'supermarkt', true),
  ('Google Ready Meals NL', 'https://news.google.com/rss/search?q=ready+meal+supermarket+netherlands+halal&hl=nl&gl=NL&ceid=NL:nl', 'kant-en-klaar', true),
  ('Google AH Jumbo NL', 'https://news.google.com/rss/search?q=Albert+Heijn+OR+Jumbo+kant+en+klaar+schap&hl=nl&gl=NL&ceid=NL:nl', 'supermarkt', true)
ON CONFLICT (name) DO UPDATE SET url = EXCLUDED.url, category = EXCLUDED.category, is_active = true;

-- Verwijder irrelevante items (algemeen nieuws)
DELETE FROM rss_items WHERE feed_id IN (SELECT id FROM rss_feeds WHERE is_active = FALSE);

DELETE FROM rss_items WHERE
  title NOT ILIKE ANY (ARRAY[
    '%kant%klaa%', '%maaltijd%', '%meal%', '%supermarkt%', '%supermarket%',
    '%retail%', '%jumbo%', '%albert heijn%', '%ah %', '%plus %', '%lidl%',
    '%aldi%', '%dirk%', '%halal%', '%convenience%', '%schap%', '%filiaal%',
    '%food%', '%grocery%', '%vers%', '%ready%', '%horeca%', '%foodservice%'
  ])
  AND COALESCE(summary, '') NOT ILIKE ANY (ARRAY[
    '%kant%klaa%', '%maaltijd%', '%meal%', '%supermarkt%', '%supermarket%',
    '%retail%', '%jumbo%', '%albert heijn%', '%halal%', '%food%'
  ]);
