Skip to content

Commit 27798b2

Browse files
hc-sousacursoragent
andcommitted
fix(news): use working Azores RSS feeds and poll by island_key
Replace 404/DNS-dead seed URLs with ALRA/JORAA feeds; allow manual poll for a specific island even when is_live is false on staging. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 19700f0 commit 27798b2

3 files changed

Lines changed: 63 additions & 6 deletions

File tree

src/news/migrations/0002_seed_sources_and_beat.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
DEFAULT_SOURCES = (
66
{
7-
'name': 'Açoriano Oriental',
8-
'rss_url': 'https://www.acorianooriental.pt/rss/',
7+
'name': 'ALRA (Açores)',
8+
'rss_url': 'https://xn--aores-yra.net/rss/alra.xml',
99
'language': 'pt',
1010
},
1111
{
12-
'name': 'Jornal dos Açores',
13-
'rss_url': 'https://www.jornaldosacores.com/feed/',
12+
'name': 'JORAA (Açores)',
13+
'rss_url': 'https://xn--aores-yra.net/rss/joraa.xml',
1414
'language': 'pt',
1515
},
1616
)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
"""Replace broken seed RSS URLs with working Azores feeds."""
2+
3+
from django.db import migrations
4+
5+
# Verified 2026-06: alra/joraa return 200 + entries; old AO/jornaldosacores URLs were 404/DNS fail.
6+
SOURCE_UPDATES = (
7+
{
8+
'old_url': 'https://www.acorianooriental.pt/rss/',
9+
'rss_url': 'https://xn--aores-yra.net/rss/alra.xml',
10+
'name': 'ALRA (Açores)',
11+
'language': 'pt',
12+
},
13+
{
14+
'old_url': 'https://www.jornaldosacores.com/feed/',
15+
'rss_url': 'https://xn--aores-yra.net/rss/joraa.xml',
16+
'name': 'JORAA (Açores)',
17+
'language': 'pt',
18+
},
19+
)
20+
21+
22+
def fix_feed_urls(apps, schema_editor):
23+
Island = apps.get_model('tenancy', 'Island')
24+
NewsSource = apps.get_model('news', 'NewsSource')
25+
26+
island = Island.objects.filter(key='sao-miguel').first()
27+
if not island:
28+
return
29+
30+
for row in SOURCE_UPDATES:
31+
updated = NewsSource.objects.filter(island=island, rss_url=row['old_url']).update(
32+
rss_url=row['rss_url'],
33+
name=row['name'],
34+
language=row['language'],
35+
active=True,
36+
)
37+
if not updated:
38+
NewsSource.objects.update_or_create(
39+
island=island,
40+
rss_url=row['rss_url'],
41+
defaults={
42+
'name': row['name'],
43+
'language': row['language'],
44+
'active': True,
45+
},
46+
)
47+
48+
49+
class Migration(migrations.Migration):
50+
dependencies = [
51+
('news', '0002_seed_sources_and_beat'),
52+
]
53+
54+
operations = [
55+
migrations.RunPython(fix_feed_urls, migrations.RunPython.noop),
56+
]

src/news/services.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,10 @@ def poll_source(source: NewsSource) -> tuple[int, int]:
103103

104104
def poll_all_sources(*, island_key: str | None = None) -> dict[str, int]:
105105
"""Poll active RSS sources. Returns aggregate counts."""
106-
islands = Island.objects.filter(is_live=True)
107106
if island_key:
108-
islands = islands.filter(key=island_key)
107+
islands = Island.objects.filter(key=island_key)
108+
else:
109+
islands = Island.objects.filter(is_live=True)
109110

110111
totals = {'sources': 0, 'created': 0, 'skipped': 0}
111112
for island in islands:

0 commit comments

Comments
 (0)