Skip to content

Add NWAC weather station data pages#1145

Draft
rchlfryn wants to merge 18 commits into
mainfrom
feat/weather-station-tables
Draft

Add NWAC weather station data pages#1145
rchlfryn wants to merge 18 commits into
mainfrom
feat/weather-station-tables

Conversation

@rchlfryn

@rchlfryn rchlfryn commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Description

Adds native weather-station data pages to AvyWeb for NWAC, recreating the nwac.us /weatherdata/<station>/now/ tables (currently a WordPress plugin). Data-first React tables backed by SnowObs, fetched server-side so the API token never reaches the browser.

Related Issues

N/A

Key Changes

  • SnowObs service (src/services/snowobs): server-side wx/v1/station/data/timeseries fetch (token via SNOWOBS_TOKEN env), zod-validated response, and a pure transform → render-ready tables — cumulative precip, cross-station full-outer-join on timestamp, UTC→America/Vancouver, short sensor/unit labels. Unit-tested.
  • Station registry (src/constants/weatherStations.ts): 32 station groups ported from the legacy station_group_tables_configslug, legacySlug (for future redirects), region, stids, columns. Integrity-tested.
  • Detail route /weather/stations/[station]: ISR (10-min revalidate), 24h / 7-day range toggle, latest-observation timestamp + stale flag (>2h), per-station error isolation, notFound() for centers without the stations platform.
  • Index /weather/stations: region-grouped directory (up to 4 columns) + station picker.
  • StationNowTable: shadcn table — zebra rows, sticky time column, tightened/centered columns, stacked label/unit/elevation headers.
  • NWAC-only "Weather Data" nav item in the Weather dropdown (seed + provisioning + migration).

How to test

  • pnpm dev, then load nwac.localhost:3000/weather/stations and /weather/stations/hurricane-ridge.
  • Toggle Last 24 Hours / Last 7 Days; spot-check values against nwac.us.
  • Confirm other centers (dvac/sac/snfac) 404 on these routes.
  • pnpm test — covers the SnowObs transform and the registry.

Screenshots / Demo video

TODO: add a screenshot of the Hurricane Ridge table.

Migration Explanation

src/migrations/20260707_180000_add_nwac_weather_data_nav.ts adds the NWAC-only "Weather Data" built-in page (/weather/stations) and a Weather-dropdown nav item to the existing NWAC tenant. It is scoped to NWAC (no-op for other tenants), idempotent, and uses raw SQL for the nav update, mirroring the existing backfill_nav_builtin_pages migration.

Future enhancements / Questions

  • SnowObs token: currently read from env with a public fallback token committed (the same one nwac.us already serves in client HTML). Consider dropping the fallback and requiring the env var to keep secret scanners happy.
  • Region "area" pages with historical date-range browsing (prototyped separately, deferred).
  • Data Portal graphs (legacy D3 → React charts).
  • nwac.us cutover: redirects from /weatherdata/<slug>/now/ → new URLs (deferred; legacySlug is stored for this).

🤖 Generated with Claude Code


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Migration Safety Check

Found 1 potential issue:

20260707_180000_add_nwac_weather_data_nav.ts

Warning (line 96): DELETE keyword detected - review for data loss

await db.run(sql`DELETE FROM _navigations_v WHERE parent_id = ${navId}`)

Review these patterns and add backup/restore logic if needed. See docs/migration-safety.md for guidance.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Preview deployment: https://featxweather-station-tables.preview.avy-fx.org

@rchlfryn rchlfryn marked this pull request as draft July 8, 2026 22:11
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