Historical weather popups read Fahrenheit and mph for a metric visitor #57

Open
opened 2026-11-03 18:52:30 +00:00 by skippy-bot · 0 comments

Problem

Markers whose data comes from a historical batch build their popup with hard-coded imperial units, while a live packet for the same station goes through the locale conversion. A visitor on the de, es or fr locale reads Temperature: 72°F, Wind: 10 mph, Rain 0.0 in on a historical marker, then sees the same marker switch to 22.2°C, 16.1 km/h and 0.0 mm as soon as one packet arrives.

Evidence

At 2f150f66:

  • lib/aprsme_web/live/map_live/data_builder.ex:208 sets "temp_unit" => "°F", :212 "wind_unit" => "mph" and :219 "rain_1h_unit" => "in" in build_lazy_popup_data/2, which never receives a locale.
  • lib/aprsme_web/live/map_live/data_builder.ex:239 and :243 hard-code the same units in build_simple_popup_data/1, the popup path used for the current marker of a historical batch.
  • lib/aprsme_web/live/map_live/data_builder.ex:394 shows the conversion lives in build_weather_popup_html/3, reached only for live packets.
  • lib/aprsme_web/weather_units.ex:82 defines the metric converter the historical path never calls.

Expected

Every weather popup respects the visitor's locale, so a metric visitor never sees Fahrenheit, mph or inches on the map.

How to verify

In IEx, build a packet data list through AprsmeWeb.MapLive.DataBuilder.build_packet_data_list/1 with a weather packet and inspect temp_unit: it is °F with no locale consulted. A test asserting °C for locale de fails today.

Acceptance criteria

  • Historical and live popups for the same packet report the same units for one locale.
  • The unit conversion is applied in one place both paths use.
  • Tests cover a metric and an imperial locale on the historical path.

Effort: S
Lens: product

## Problem Markers whose data comes from a historical batch build their popup with hard-coded imperial units, while a live packet for the same station goes through the locale conversion. A visitor on the de, es or fr locale reads `Temperature: 72°F, Wind: 10 mph, Rain 0.0 in` on a historical marker, then sees the same marker switch to 22.2°C, 16.1 km/h and 0.0 mm as soon as one packet arrives. ## Evidence At `2f150f66`: - `lib/aprsme_web/live/map_live/data_builder.ex:208` sets `"temp_unit" => "°F"`, `:212` `"wind_unit" => "mph"` and `:219` `"rain_1h_unit" => "in"` in `build_lazy_popup_data/2`, which never receives a locale. - `lib/aprsme_web/live/map_live/data_builder.ex:239` and `:243` hard-code the same units in `build_simple_popup_data/1`, the popup path used for the current marker of a historical batch. - `lib/aprsme_web/live/map_live/data_builder.ex:394` shows the conversion lives in `build_weather_popup_html/3`, reached only for live packets. - `lib/aprsme_web/weather_units.ex:82` defines the metric converter the historical path never calls. ## Expected Every weather popup respects the visitor's locale, so a metric visitor never sees Fahrenheit, mph or inches on the map. ## How to verify In IEx, build a packet data list through `AprsmeWeb.MapLive.DataBuilder.build_packet_data_list/1` with a weather packet and inspect `temp_unit`: it is `°F` with no locale consulted. A test asserting `°C` for locale `de` fails today. ## Acceptance criteria - [ ] Historical and live popups for the same packet report the same units for one locale. - [ ] The unit conversion is applied in one place both paths use. - [ ] Tests cover a metric and an imperial locale on the historical path. **Effort:** S **Lens:** product
Sign in to join this conversation.
No description provided.