From 8578db99b37e5985072e1e9b6dee6beaed994d8b Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Mon, 29 Jun 2026 12:03:57 +0000 Subject: [PATCH] Document current conditions consensus selection --- docs/api.md | 7 +++++-- docs/integrations/weatherfeeder-postgres.md | 15 +++++++++------ docs/internal/postgres-repository.md | 5 +++-- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/docs/api.md b/docs/api.md index 490ffdc..46f4bb2 100644 --- a/docs/api.md +++ b/docs/api.md @@ -162,8 +162,10 @@ GET /observations?units=us&precision=1 GET /conditions/current ``` -Returns current conditions aggregated from recent `observations` rows. The -implemented observation window is 30 minutes. +Returns current conditions from recent `observations` rows. Numeric fields are +aggregated over the implemented 30-minute observation window. `conditionCode` +is selected from the latest observation per source in that window by +source-balanced WMO family consensus. Query parameters: `format`, `units`, `precision`. @@ -171,6 +173,7 @@ Common `data` fields: | Field | Type | Notes | | --- | --- | --- | +| `conditionCode` | integer | WMO weather code selected by source-balanced family consensus | | `conditionText` | string | optional text derived from WMO code and day/night flag | | `isDay` | boolean | optional | | `relativeHumidityPercent` | number | optional | diff --git a/docs/integrations/weatherfeeder-postgres.md b/docs/integrations/weatherfeeder-postgres.md index 5910fce..630fb10 100644 --- a/docs/integrations/weatherfeeder-postgres.md +++ b/docs/integrations/weatherfeeder-postgres.md @@ -57,8 +57,10 @@ Latest parent resources use these ordering rules: story_order ASC, story_index ASC`. - convective outlook runs: `as_of DESC, event_emitted_at DESC`. -Current conditions aggregate `observations` rows where `observed_at` is inside -the application-provided observation window. +Current conditions aggregate numeric values from `observations` rows where +`observed_at` is inside the application-provided observation window. They also +use the latest row per `event_source` in that window to select `condition_code` +by source-balanced WMO family consensus. ## Child Ordering @@ -79,15 +81,16 @@ The repository reads only these columns. ### `observations` -`event_id`, `station_id`, `station_name`, `observed_at`, `condition_code`, -`is_day`, `text_description`, `temperature_c`, `dewpoint_c`, +`event_id`, `event_source`, `station_id`, `station_name`, `observed_at`, +`condition_code`, `is_day`, `text_description`, `temperature_c`, `dewpoint_c`, `wind_direction_degrees`, `wind_speed_kmh`, `wind_gust_kmh`, `barometric_pressure_pa`, `visibility_meters`, `relative_humidity_percent`, `apparent_temperature_c`, and `event_emitted_at`. -Current conditions additionally aggregate recent `observations` values for +Current conditions additionally read recent `observations` values for temperature, apparent temperature, dewpoint, humidity, wind speed, wind -direction, condition code, and latest `is_day`. +direction, latest `is_day`, and latest condition-code candidates per +`event_source`. ### `observation_present_weather` diff --git a/docs/internal/postgres-repository.md b/docs/internal/postgres-repository.md index 86dc7ba..af21655 100644 --- a/docs/internal/postgres-repository.md +++ b/docs/internal/postgres-repository.md @@ -76,8 +76,9 @@ successful responses with `data: null`. - `LatestObservation`: latest row from `observations`, then present-weather rows from `observation_present_weather`. -- `CurrentConditions`: aggregates recent rows from `observations` using the - application-provided observation window. +- `CurrentConditions`: reads an aggregate row from recent `observations` using + the application-provided observation window, then reads the latest + condition-code candidate per `event_source` in the same window. - `LatestAlertRun`: latest row from `alert_runs`, then child `alerts` and `alert_references`. This is the latest stored alert snapshot. The repository maps both `ends` and `expires`; active-time filtering is performed by the