feat: add rain data audit and prediction scripts
This commit is contained in:
@@ -84,6 +84,34 @@ SELECT create_hypertable('forecast_openmeteo_hourly', 'ts', if_not_exists => TRU
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_forecast_openmeteo_site_ts ON forecast_openmeteo_hourly(site, ts DESC);
|
||||
|
||||
-- Rain model predictions (next 1h)
|
||||
CREATE TABLE IF NOT EXISTS predictions_rain_1h (
|
||||
ts TIMESTAMPTZ NOT NULL,
|
||||
generated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
site TEXT NOT NULL,
|
||||
model_name TEXT NOT NULL,
|
||||
model_version TEXT NOT NULL,
|
||||
threshold DOUBLE PRECISION NOT NULL,
|
||||
probability DOUBLE PRECISION NOT NULL,
|
||||
predict_rain BOOLEAN NOT NULL,
|
||||
|
||||
rain_next_1h_mm_actual DOUBLE PRECISION,
|
||||
rain_next_1h_actual BOOLEAN,
|
||||
evaluated_at TIMESTAMPTZ,
|
||||
|
||||
metadata JSONB,
|
||||
|
||||
PRIMARY KEY (site, model_name, model_version, ts)
|
||||
);
|
||||
|
||||
SELECT create_hypertable('predictions_rain_1h', 'ts', if_not_exists => TRUE);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_predictions_rain_1h_site_ts
|
||||
ON predictions_rain_1h(site, ts DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_predictions_rain_1h_pending_eval
|
||||
ON predictions_rain_1h(site, evaluated_at, ts DESC);
|
||||
|
||||
-- Raw retention: 90 days
|
||||
DO $$
|
||||
BEGIN
|
||||
|
||||
Reference in New Issue
Block a user