← all branches

feat/atlas-clima

needs attention
dea660c · fullPR #315reviewed 2026-07-16 05:16 UTC1H · 6M · 5L · 4I
The branch
Purpose
Atlas is Batu's public grid-intelligence map at batuenergy.com/atlas, showing Mexico's live electrical demand, solar generation, and MDA prices. Clima × Demanda Fase 1 adds weather context to the demand curve.
Goal
Add an hourly temperature overlay on the CENACE live demand chart so users can visually correlate grid demand with temperature in real time.
Sub-goals
  • SG-1: Fetch Open-Meteo hourly temp per CENACE control region (lazy, on region-open)
  • SG-2: Join temp to demand curve by hora via horaIdx helper
  • SG-3: Render orange polyline on a secondary right-hand °C axis
  • SG-4: Show/hide legend item and source attribution dynamically
The changes (whole branch)
What
apps/web/public/atlas/index.html: added DEM_TEMP region→coordinates lookup, fetchRegionTemp async helper with session-scoped cache, horaIdx join function, temperature polyline + axis rendering in buildDemandChart, tooltip augmentation in onDMove, and legend/attribution updates.
Why
Give solar operators and energy managers weather context alongside real-time demand to support load/generation correlation — differentiating the Atlas from raw CENACE dashboards.
Areas
apps/web/public/atlas/index.html+435
Blast
1 file, +43/−5. Static HTML/JS only — no TypeScript build, no domain logic, no database changes. Browser-only side effects.
open-meteo-license-violation stale-cache-past-midnight async-layout-jump
typecheck· static HTML, no TS buildtests· no test infrastructure for atlas/index.htmlci· no CI status accessible for this PRcoderabbit· no .coderabbit.yaml

Findings · 17

correctness4

medium

Axis tick labels render without polyline when only one temp slot exists

apps/web/public/atlas/index.html:618

Three °C labels are emitted inside if(fin.length) but the polyline requires tp.length>=2. Early in the day with one point, labels appear with no curve.

low

forecast_days=1 date misalignment if DEM is stale from yesterday

apps/web/public/atlas/index.html:413

low

Permanent no-retry on failure with no user-visible indicator

apps/web/public/atlas/index.html:410

info

horaIdx mapping confirmed correct — no off-by-one

apps/web/public/atlas/index.html:422

security2

low

Open-Meteo response values not validated as finite numbers before storage

apps/web/public/atlas/index.html

info

CSP must allow connect-src https://api.open-meteo.com

apps/web/public/atlas/index.html

conventions3

high

Open-Meteo non-commercial license active in a commercial product

apps/web/public/atlas/index.html:404

Free Open-Meteo tier is CC-BY non-commercial; atlas runs on batuenergy.com. Comment acknowledges this as a pre-production TODO but the fetch is already live. Must resolve before merge: commercial plan or server-side proxy in atlas-sen.

medium

#about overlay missing Open-Meteo attribution (CC-BY requirement)

apps/web/public/atlas/index.html:135

Map control and chart footer updated; the static Fuentes de datos list in the #about overlay was not. CC-BY requires reasonably prominent attribution.

info

ADR-016 / FCIS patterns correctly not applied to static HTML

apps/web/public/atlas/index.html

tests3

medium

horaIdx has no unit test despite prior off-by-one bug

apps/web/public/atlas/index.html:424

The formula was wrong before (fixed in 1e550764). A two-line Vitest test (horaIdx(1)===0, horaIdx(24)===23) would guard against regression.

medium

tempFor cache-state logic untested despite two post-landing fixes

apps/web/public/atlas/index.html:422

The four-state guard (absent/pending/null/object) was patched post-landing. Trivially testable in isolation.

low

No Playwright smoke test verifies the atlas page loads without JS errors

apps/web/public/atlas/index.html

improvement4

medium

Visible layout jump on first open: mR shifts 14→32 when temp loads async

apps/web/public/atlas/index.html:607

Chart renders without temp (mR=14) then re-renders with temp (mR=32), shrinking the plot area visibly. Fix: use mR=32 unconditionally for regions in DEM_TEMP.

medium

Stale cache past midnight — forecast_days=1 gives today only, no TTL

apps/web/public/atlas/index.html:408

Page open past midnight serves yesterday's temperatures against new-day demand. Fix: include date in cache key.

low

No UX feedback while temperature is loading (pending state invisible)

apps/web/public/atlas/index.html:618

low

Axis tick labels can crowd when temperature range is narrow (< 4°)

apps/web/public/atlas/index.html:623

seo1

info

No SEO-relevant changes

apps/web/public/atlas/index.html

History · 2 commits

  1. dea660cneeds attentionfull1H · 6M · 5L2026-07-16 05:16current
  2. ec02a4dneeds attentionincremental0H · 3M · 4L2026-07-16 05:05