Implemented NWS weather stories support
All checks were successful
ci/woodpecker/push/build-image Pipeline was successful
All checks were successful
ci/woodpecker/push/build-image Pipeline was successful
This commit is contained in:
@@ -8,11 +8,15 @@
|
||||
// Canonical input schemas:
|
||||
// - weather.observation.v1 -> model.WeatherObservation
|
||||
// - weather.forecast.v1 -> model.WeatherForecastRun
|
||||
// - weather.forecast_discussion.v1 -> model.WeatherForecastDiscussion
|
||||
// - weather.weather_story.v1 -> model.WeatherStoryRun
|
||||
// - weather.alert.v1 -> model.WeatherAlertRun
|
||||
//
|
||||
// Parent/child relationships:
|
||||
// - observations.event_id -> observation_present_weather.event_id
|
||||
// - forecasts.event_id -> forecast_periods.run_event_id
|
||||
// - forecast_discussions.event_id -> forecast_discussion_key_messages.run_event_id
|
||||
// - weather_story_runs.event_id -> weather_stories.run_event_id
|
||||
// - alert_runs.event_id -> alerts.run_event_id
|
||||
// - alerts.(run_event_id, alert_index) -> alert_references.(run_event_id, alert_index)
|
||||
//
|
||||
@@ -24,13 +28,18 @@
|
||||
// - observation_present_weather.observed_at
|
||||
// - forecasts.issued_at
|
||||
// - forecast_periods.issued_at
|
||||
// - forecast_discussions.issued_at
|
||||
// - forecast_discussion_key_messages.issued_at
|
||||
// - weather_story_runs.as_of
|
||||
// - weather_stories.as_of
|
||||
// - alert_runs.as_of
|
||||
// - alerts.as_of
|
||||
// - alert_references.as_of
|
||||
//
|
||||
// Envelope field mapping (shared parent columns)
|
||||
//
|
||||
// These columns exist on observations, forecasts, and alert_runs:
|
||||
// These columns exist on parent tables such as observations, forecasts,
|
||||
// forecast_discussions, weather_story_runs, and alert_runs:
|
||||
// - event_id TEXT -> event.id
|
||||
// - event_kind TEXT -> event.kind
|
||||
// - event_source TEXT -> event.source
|
||||
@@ -120,7 +129,35 @@
|
||||
// - snowfall_depth_mm DOUBLE PRECISION NULL -> payload.periods[i].snowfallDepthMm
|
||||
// - uv_index DOUBLE PRECISION NULL -> payload.periods[i].uvIndex
|
||||
//
|
||||
// 5. alert_runs (PK: event_id)
|
||||
// 5. weather_story_runs (PK: event_id)
|
||||
//
|
||||
// - event_id TEXT -> event.id
|
||||
// - event_kind TEXT -> event.kind
|
||||
// - event_source TEXT -> event.source
|
||||
// - event_schema TEXT -> event.schema
|
||||
// - event_emitted_at TIMESTAMPTZ -> event.emitted_at
|
||||
// - event_effective_at TIMESTAMPTZ NULL -> event.effective_at
|
||||
// - office_id TEXT NULL -> payload.officeId
|
||||
// - as_of TIMESTAMPTZ -> payload.asOf
|
||||
// - story_count INTEGER -> len(payload.stories)
|
||||
//
|
||||
// 6. weather_stories (PK: run_event_id, story_index)
|
||||
//
|
||||
// - run_event_id TEXT -> weather_story_runs.event_id / payload.stories[i]
|
||||
// - story_index INTEGER -> i (array position in payload.stories)
|
||||
// - as_of TIMESTAMPTZ -> payload.asOf (copied from parent)
|
||||
// - office_id TEXT NULL -> payload.stories[i].officeId
|
||||
// - start_time TIMESTAMPTZ -> payload.stories[i].startTime
|
||||
// - end_time TIMESTAMPTZ -> payload.stories[i].endTime
|
||||
// - updated_at TIMESTAMPTZ -> payload.stories[i].updatedAt
|
||||
// - title TEXT NULL -> payload.stories[i].title
|
||||
// - description TEXT NULL -> payload.stories[i].description
|
||||
// - alt_text TEXT NULL -> payload.stories[i].altText
|
||||
// - priority BOOLEAN -> payload.stories[i].priority
|
||||
// - story_order INTEGER -> payload.stories[i].order
|
||||
// - download_url TEXT NULL -> payload.stories[i].downloadUrl
|
||||
//
|
||||
// 7. alert_runs (PK: event_id)
|
||||
//
|
||||
// - event_id TEXT -> event.id
|
||||
// - event_kind TEXT -> event.kind
|
||||
@@ -135,7 +172,7 @@
|
||||
// - longitude DOUBLE PRECISION NULL -> payload.longitude
|
||||
// - alert_count INTEGER -> len(payload.alerts)
|
||||
//
|
||||
// 6. alerts (PK: run_event_id, alert_index)
|
||||
// 8. alerts (PK: run_event_id, alert_index)
|
||||
//
|
||||
// - run_event_id TEXT -> alert_runs.event_id / payload.alerts[i]
|
||||
// - alert_index INTEGER -> i (array position in payload.alerts)
|
||||
@@ -160,7 +197,7 @@
|
||||
// - sender_name TEXT NULL -> payload.alerts[i].senderName
|
||||
// - reference_count INTEGER -> len(payload.alerts[i].references)
|
||||
//
|
||||
// 7. alert_references (PK: run_event_id, alert_index, reference_index)
|
||||
// 9. alert_references (PK: run_event_id, alert_index, reference_index)
|
||||
//
|
||||
// - run_event_id TEXT -> alert_runs.event_id / payload.alerts[i].references[j]
|
||||
// - alert_index INTEGER -> i (array position in payload.alerts)
|
||||
@@ -181,6 +218,10 @@
|
||||
// read one row from forecasts, then join forecast_periods by run_event_id
|
||||
// ordered by period_index to rebuild periods.
|
||||
//
|
||||
// - WeatherStoryRun:
|
||||
// read one row from weather_story_runs, then join weather_stories by
|
||||
// run_event_id ordered by story_index to rebuild stories.
|
||||
//
|
||||
// - WeatherAlertRun:
|
||||
// read one row from alert_runs, join alerts by run_event_id ordered by
|
||||
// alert_index, then join alert_references by (run_event_id, alert_index)
|
||||
|
||||
Reference in New Issue
Block a user