diff --git a/internal/adapters/httpapi/server_test.go b/internal/adapters/httpapi/server_test.go index 9fa80ee..a9c742e 100644 --- a/internal/adapters/httpapi/server_test.go +++ b/internal/adapters/httpapi/server_test.go @@ -142,12 +142,21 @@ func TestObservationsCurrentReturnsUSUnits(t *testing.T) { if _, exists := summary["temperatureC"]; exists { t.Fatalf("did not expect metric key temperatureC in US response") } + if _, exists := summary["windowMinutes"]; exists { + t.Fatalf("did not expect deprecated key windowMinutes in observations summary") + } conditions := payload["conditions"].([]any) first := conditions[0].(map[string]any) if got := first["temperatureF"].(float64); got != 50.0 { t.Fatalf("expected conditions[0].temperatureF=50.0, got %v", got) } + if _, exists := first["providerRawDescription"]; exists { + t.Fatalf("did not expect deprecated key providerRawDescription in observations condition") + } + if _, exists := first["conditionText"]; exists { + t.Fatalf("did not expect deprecated key conditionText in observations condition") + } if obsRepo.summaryWin != constants.ObservationWindow || obsRepo.conditionsWin != constants.ObservationWindow || obsRepo.precipWin != constants.ObservationWindow { t.Fatalf("expected observation window %s to be used", constants.ObservationWindow) @@ -273,6 +282,9 @@ func TestNullFieldsAreOmittedFromJSON(t *testing.T) { if _, exists := summary["temperatureF"]; exists { t.Fatalf("expected summary.temperatureF to be omitted when nil") } + if _, exists := summary["windowMinutes"]; exists { + t.Fatalf("expected summary.windowMinutes to be omitted") + } conditions := obsPayload["conditions"].([]any) firstCond := conditions[0].(map[string]any) diff --git a/internal/application/observations/service.go b/internal/application/observations/service.go index 2c9633d..2814370 100644 --- a/internal/application/observations/service.go +++ b/internal/application/observations/service.go @@ -28,16 +28,13 @@ type CurrentResponse struct { type SummaryResponse struct { TemperatureF *float64 `json:"temperatureF,omitempty"` ApparentTemperatureF *float64 `json:"apparentTemperatureF,omitempty"` - WindowMinutes int `json:"windowMinutes"` } type ConditionResponse struct { - StationID *string `json:"stationId,omitempty"` - ObservedAt time.Time `json:"observedAt"` - TemperatureF *float64 `json:"temperatureF,omitempty"` - TextDescription *string `json:"textDescription,omitempty"` - ProviderRawDescription *string `json:"providerRawDescription,omitempty"` - ConditionText *string `json:"conditionText,omitempty"` + StationID *string `json:"stationId,omitempty"` + ObservedAt time.Time `json:"observedAt"` + TemperatureF *float64 `json:"temperatureF,omitempty"` + TextDescription *string `json:"textDescription,omitempty"` } func (s *Service) GetCurrent(ctx context.Context) (CurrentResponse, error) { @@ -63,12 +60,10 @@ func (s *Service) GetCurrent(ctx context.Context) (CurrentResponse, error) { conditions := make([]ConditionResponse, 0, len(conditionsMetric)) for _, c := range conditionsMetric { conditions = append(conditions, ConditionResponse{ - StationID: c.StationID, - ObservedAt: c.ObservedAt, - TemperatureF: s.converter.TemperatureCToOutput(c.TemperatureC), - TextDescription: c.TextDescription, - ProviderRawDescription: c.ProviderRawDescription, - ConditionText: c.ConditionText, + StationID: c.StationID, + ObservedAt: c.ObservedAt, + TemperatureF: s.converter.TemperatureCToOutput(c.TemperatureC), + TextDescription: c.TextDescription, }) } @@ -76,7 +71,6 @@ func (s *Service) GetCurrent(ctx context.Context) (CurrentResponse, error) { Summary: SummaryResponse{ TemperatureF: s.converter.TemperatureCToOutput(summary.TemperatureC), ApparentTemperatureF: s.converter.TemperatureCToOutput(summary.ApparentTemperatureC), - WindowMinutes: int(s.window / time.Minute), }, Conditions: conditions, PrecipitationEvents: precip,