Skip to content

Commit d54428b

Browse files
committed
Fix daily forecast UV lookup.
Signed-off-by: Katharine Berry <[email protected]>
1 parent f0297d9 commit d54428b

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

service/assistant/functions/weather.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,10 @@ func processDailyForecast(ctx context.Context, lat, lon float64, units string) a
139139
if i == 0 {
140140
day += " (Today)"
141141
}
142-
dayPart := forecast.DayParts[i*2]
143-
if dayPart == nil {
144-
dayPart = forecast.DayParts[i*2+1]
142+
dayParts := forecast.DayParts[0]
143+
uvIndex := dayParts.UvIndex[i*2]
144+
if uvIndex == nil {
145+
uvIndex = dayParts.UvIndex[i*2+1]
145146
}
146147
response[day] = map[string]any{
147148
"high": forecast.CalendarDayTemperatureMax[i],
@@ -154,7 +155,7 @@ func processDailyForecast(ctx context.Context, lat, lon float64, units string) a
154155
//"moon_phase": forecast.MoonPhase[i],
155156
"qpf": forecast.Qpf[i],
156157
"qpf_snow": forecast.QpfSnow[i],
157-
"uv_index": dayPart.UvIndex,
158+
"uv_index": uvIndex,
158159
}
159160
}
160161
response["temperatureUnit"] = forecast.TemperatureUnit

service/assistant/util/weather/weather.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -124,22 +124,22 @@ func GetHourlyForecast(ctx context.Context, lat, lon float64, units string) (*Ho
124124
}
125125

126126
type Forecast struct {
127-
CalendarDayTemperatureMax []int `json:"calendarDayTemperatureMax"`
128-
CalendarDayTemperatureMin []int `json:"calendarDayTemperatureMin"`
129-
DayOfWeek []string `json:"dayOfWeek"`
130-
MoonPhaseCode []string `json:"moonPhaseCode"`
131-
MoonPhase []string `json:"moonPhase"`
132-
MoonPhaseDay []int `json:"moonPhaseDay"`
133-
Narrative []string `json:"narrative"`
134-
SunriseTimeLocal []string `json:"sunriseTimeLocal"`
135-
SunsetTimeLocal []string `json:"sunsetTimeLocal"`
136-
MoonriseTimeLocal []string `json:"moonriseTimeLocal"`
137-
MoonsetTimeLocal []string `json:"moonsetTimeLocal"`
138-
Qpf []float32 `json:"qpf"`
139-
QpfSnow []float32 `json:"qpfSnow"`
140-
DayParts []*ForecastDayPart `json:"daypart"`
141-
WindSpeedUnit string `json:"windSpeedUnit"`
142-
TemperatureUnit string `json:"temperatureUnit"`
127+
CalendarDayTemperatureMax []int `json:"calendarDayTemperatureMax"`
128+
CalendarDayTemperatureMin []int `json:"calendarDayTemperatureMin"`
129+
DayOfWeek []string `json:"dayOfWeek"`
130+
MoonPhaseCode []string `json:"moonPhaseCode"`
131+
MoonPhase []string `json:"moonPhase"`
132+
MoonPhaseDay []int `json:"moonPhaseDay"`
133+
Narrative []string `json:"narrative"`
134+
SunriseTimeLocal []string `json:"sunriseTimeLocal"`
135+
SunsetTimeLocal []string `json:"sunsetTimeLocal"`
136+
MoonriseTimeLocal []string `json:"moonriseTimeLocal"`
137+
MoonsetTimeLocal []string `json:"moonsetTimeLocal"`
138+
Qpf []float32 `json:"qpf"`
139+
QpfSnow []float32 `json:"qpfSnow"`
140+
DayParts []ForecastDayPart `json:"daypart"`
141+
WindSpeedUnit string `json:"windSpeedUnit"`
142+
TemperatureUnit string `json:"temperatureUnit"`
143143
}
144144

145145
type ForecastDayPart struct {

0 commit comments

Comments
 (0)