Skip to content

fix(dashboard): reconstruct GDACS source links for reports without link field#54

Merged
nullhack merged 1 commit into
mainfrom
fix/gdacs-source-link-reconstruction
Jul 23, 2026
Merged

fix(dashboard): reconstruct GDACS source links for reports without link field#54
nullhack merged 1 commit into
mainfrom
fix/gdacs-source-link-reconstruction

Conversation

@nullhack

Copy link
Copy Markdown
Owner

Problem

Two GDACS incidents had empty source_link URLs in the dashboard JSON, causing the source-record links to redirect back to the dashboard itself when clicked:

Incident Report Why link was missing
20251221-XX-DR Drought Green c892ccdaf15e Degenerate RSS — only {alertlevel, severity, population, episodeid} in raw_fields
20260702-PT-WF Forest Fire Aveiro f3e5d132af05 Newer RSS shape — URL lives in raw_fields.url as a dict {geometry, report, details}

Root cause

scripts/generate_dashboard_data.py:494 read only rf.get('link', ''). Reports without a link field produced url='', which the frontend (app.js:820) rendered as href="" — the browser treats this as a link to the current page.

Fix

1. _resolve_gdacs_link(raw_fields, source_id, incident_type) — tries three sources in order:

  1. rf['link'] (43/45 GDACS reports — the normal case)
  2. rf['url']['report'] dict sub-key (the Portugal newer-RSS case)
  3. Construct from source_id + episodeid + eventtype code (derived from incident_type via _GDACS_EVENTTYPE_CODES reverse map) — the degenerate drought case. Verified manually: the constructed URL https://www.gdacs.org/report.aspx?eventid=1018332&episodeid=14&eventtype=DR opens the correct GDACS page ("Overall Orange Drought for Europe-2026").

2. app.js safety net — when L.url is empty, render a disabled <span> (⊘ icon) instead of <a href="">, so any future empty-URL case can't redirect to self.

Tests

5 new TestResolveGdacsLink covering all three fallback paths + the empty case. 256 tests pass, pyright 0 errors, ruff clean (4 pre-existing C901).

…nk field

Two GDACS reports in production had empty source_link URLs, causing the
dashboard to redirect back to itself when clicked:
  - 20251221-XX-DR Drought Green (degenerate RSS — only alertlevel/severity/
    population/episodeid in raw_fields; no link/eventid/eventtype)
  - 20260702-PT-WF Forest Fire Aveiro (newer RSS shape — URL lives in
    raw_fields.url as a dict {geometry, report, details}, not in a link field)

Root cause: generate_dashboard_data.py:494 read only rf.get('link', '').
Reports without a 'link' field produced url='' which the frontend rendered
as href='' (browser navigates to the current page).

Fix:
- _resolve_gdacs_link(raw_fields, source_id, incident_type) tries three
  sources in order: (1) rf['link'] (43/45 reports), (2) rf['url']['report']
  dict sub-key (Portugal case), (3) construct from source_id + episodeid +
  eventtype code derived from incident_type via _GDACS_EVENTTYPE_CODES
  reverse map (drought case — confirmed opens the correct GDACS page).
- app.js safety net: render a disabled <span> (⊘) instead of <a href=''>
  when L.url is empty, so any future empty-URL case can't redirect to self.

Tests: 5 new TestResolveGdacsLink covering all three fallback paths plus
the empty case. 256 tests pass, pyright 0 errors, ruff clean (4 pre-existing
C901).
@nullhack
nullhack merged commit 6936c9b into main Jul 23, 2026
1 check passed
@nullhack
nullhack deleted the fix/gdacs-source-link-reconstruction branch July 23, 2026 05:17
nullhack added a commit that referenced this pull request Jul 23, 2026
Regenerated dashboard JSON with _resolve_gdacs_link fallback chain
(rf.link → rf.url.report → constructed from source_id+episodeid+eventtype).
Fixes empty-URL source links that redirected back to the dashboard.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant