From c4107490dfe933a86d86911a26f4653d918d313e Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Fri, 12 Jun 2026 17:42:49 +0000 Subject: [PATCH] Add near-term report config overrides --- docs/config.md | 6 ++-- internal/config/config_test.go | 62 ++++++++++++++++++++++++++++++++++ internal/config/reports.go | 2 ++ 3 files changed, 67 insertions(+), 3 deletions(-) diff --git a/docs/config.md b/docs/config.md index ae5c852..0cc0122 100644 --- a/docs/config.md +++ b/docs/config.md @@ -181,9 +181,9 @@ snapshot exists and a threshold is crossed. `reports` optionally overrides the ordered deterministic modules declared by report definitions. Omit a report entry to use its default module order. -Supported report keys are `daily`, `tomorrow`, `three_day`, `weekend`, and -`storm`. Canonical report IDs such as `daily_today` and `daily_tomorrow` are -also accepted. +Supported report keys are `daily`, `tomorrow`, `near_term`, `near-term`, +`three_day`, `weekend`, and `storm`. Canonical report IDs such as +`daily_today` and `daily_tomorrow` are also accepted. Each report entry supports: diff --git a/internal/config/config_test.go b/internal/config/config_test.go index ad07fa1..7db698a 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -161,6 +161,45 @@ reports: } } +func TestLoadNearTermReportModuleOverrides(t *testing.T) { + tests := []struct { + name string + key string + }{ + {name: "UnderscoreAlias", key: "near_term"}, + {name: "HyphenAlias", key: "near-term"}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + path := writeConfig(t, ` +reports: + `+tt.key+`: + deterministic_modules: + - metadata + - hourly_forecast + - precip_timing + - alert_digest +`) + + cfg, err := LoadFile(path) + if err != nil { + t.Fatalf("LoadFile() error = %v", err) + } + overrides := cfg.ReportModuleOverrides() + items := overrides[report.NearTerm] + if len(items) != 4 { + t.Fatalf("near-term override length = %d, want 4", len(items)) + } + if items[0].ID != module.Metadata || + items[1].ID != module.HourlyForecast || + items[2].ID != module.PrecipTiming || + items[3].ID != module.AlertDigest { + t.Fatalf("near-term override = %#v, want configured module order", items) + } + }) + } +} + func TestReportModuleOverrideValidation(t *testing.T) { tests := []struct { name string @@ -244,6 +283,29 @@ reports: `, wantErr: "duplicates report override", }, + { + name: "DuplicateNearTermAlias", + yaml: ` +reports: + near_term: + deterministic_modules: + - metadata + near-term: + deterministic_modules: + - current_conditions +`, + wantErr: "duplicates report override", + }, + { + name: "NearTermIncompatibleDailyModule", + yaml: ` +reports: + near_term: + deterministic_modules: + - derived_daily_summary +`, + wantErr: `not compatible with report "near_term"`, + }, { name: "UnknownReportField", yaml: ` diff --git a/internal/config/reports.go b/internal/config/reports.go index d3a15b7..0e3500b 100644 --- a/internal/config/reports.go +++ b/internal/config/reports.go @@ -113,6 +113,8 @@ func reportIDForConfigKey(key string) (report.ID, error) { return report.DailyToday, nil case "tomorrow", "daily_tomorrow": return report.DailyTomorrow, nil + case "near_term": + return report.NearTerm, nil case "three_day", "three_day_outlook": return report.ThreeDay, nil case "weekend", "weekend_outlook":