Skip to content

Conversation

@matveynator
Copy link
Owner

Motivation

  • Provide an optional country-level overlay that shades each country by cancer deaths under age 50 so the map can show population health context alongside radiation data.
  • Use WHO GHO as the source and keep polling/cache logic off the request path so UI remains responsive.

Description

  • Add a new backend package pkg/cancerstats that polls a WHO GHO endpoint (default: GHECAUSES filter for "Malignant neoplasms" and age 0-49 years), parses the payload and exposes a cached Snapshot via a channel-based Service API.
  • Add CLI flags -cancer-under-50 and -cancer-under-50-source to enable the overlay and optionally override the WHO endpoint URL, and wire the service lifecycle into main().
  • Register a new HTTP endpoint /api/cancer_under_50 that returns the latest cached snapshot in JSON from the cancerstats service.
  • Integrate frontend support in public_html/map.html: expose window.cancerUnder50Enabled and window.cancerUnder50Source, add a Leaflet overlay layer with a legend, country shading (green→yellow→red) using the embedded Natural Earth GeoJSON (/static/geojson/ne_10m_admin_0_countries.geojson), tooltips, and helper functions for color blending and labels.
  • Add UI translation keys to public_html/translations.json and a documentation file docs/cancer-under-50.md describing flags and data source.

Files changed/added (high level):

  • Added: pkg/cancerstats/service.go
  • Added: docs/cancer-under-50.md
  • Modified: chicha-isotope-map.go (flags, template data, service startup, API route)
  • Modified: public_html/map.html (UI wiring, overlay, legend, JS helpers)
  • Modified: public_html/translations.json (new translation keys)

Testing

  • Formatted sources with gofmt and ensured the code builds; gofmt -w ran on modified files without error.
  • Started the server locally with go run . -port 8765 -cancer-under-50 and verified the root page is reachable (curl to / returned OK).
  • Exercised the UI end-to-end via an automated Playwright script that loaded the page, toggled the new overlay control and produced a screenshot artifact (artifacts/cancer-under-50-overlay.png), confirming the new layer and legend render in the browser.
  • Note: direct access to the WHO GHO API from this sandbox may be blocked (observed 403/tunnel errors when fetching GHO during investigation), so background fetches can fail in this environment; the service will surface errors in logs and the frontend gracefully shows "No data" when the snapshot is empty. Please test WHO connectivity in a networked environment to validate live updates.

Codex Task

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7fddf168f0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +299 to +300
if tok, err := decoder.Token(); err != nil || tok.(json.Delim).String() != "[" {
return errors.New("expected value array")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Guard JSON delimiters to avoid panic on WHO errors

If the WHO endpoint returns a 200 response whose value field is not a JSON array (e.g., a transient error payload, null, or a different schema), the type assertion tok.(json.Delim) will panic instead of returning a parse error. In Go, an unrecovered panic inside the fetch goroutine will crash the whole process, taking the server down. Consider checking the type assertion result (as you already do at the top of decodeWHO) before calling .String() so malformed but successful responses only surface as errors and don’t terminate the service.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant