Made forecast-period conditionCode optional
This commit is contained in:
@@ -2,7 +2,11 @@
|
||||
// Layer: adapters/outbound/postgres forecast feature.
|
||||
package postgres
|
||||
|
||||
import "gitea.maximumdirect.net/ejr/weatherfeeder/model"
|
||||
import (
|
||||
"database/sql"
|
||||
|
||||
"gitea.maximumdirect.net/ejr/weatherfeeder/model"
|
||||
)
|
||||
|
||||
func mapForecastParentRow(row forecastParentRow) model.WeatherForecastRun {
|
||||
return model.WeatherForecastRun{
|
||||
@@ -23,7 +27,7 @@ func mapForecastPeriodRow(row forecastPeriodRow) model.WeatherForecastPeriod {
|
||||
EndTime: row.EndTime.UTC(),
|
||||
Name: stringValue(row.Name),
|
||||
IsDay: boolPtr(row.IsDay),
|
||||
ConditionCode: model.WMOCode(row.ConditionCode),
|
||||
ConditionCode: wmoCodePtr(row.ConditionCode),
|
||||
TextDescription: stringValue(row.TextDescription),
|
||||
TemperatureC: float64Ptr(row.TemperatureC),
|
||||
TemperatureCMin: float64Ptr(row.TemperatureCMin),
|
||||
@@ -43,3 +47,11 @@ func mapForecastPeriodRow(row forecastPeriodRow) model.WeatherForecastPeriod {
|
||||
UVIndex: float64Ptr(row.UVIndex),
|
||||
}
|
||||
}
|
||||
|
||||
func wmoCodePtr(v sql.NullInt64) *model.WMOCode {
|
||||
if !v.Valid {
|
||||
return nil
|
||||
}
|
||||
out := model.WMOCode(v.Int64)
|
||||
return &out
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user