Refactored the application structure to better separate concerns between files and packages
Some checks failed
ci/woodpecker/push/build-image Pipeline failed
Some checks failed
ci/woodpecker/push/build-image Pipeline failed
This commit is contained in:
30
internal/adapters/outbound/postgres/conditions_mapper.go
Normal file
30
internal/adapters/outbound/postgres/conditions_mapper.go
Normal file
@@ -0,0 +1,30 @@
|
||||
// conditions_mapper.go maps current-conditions DB rows into app models.
|
||||
// Layer: adapters/outbound/postgres conditions feature.
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"gitea.maximumdirect.net/ejr/weatherapi/internal/app"
|
||||
"gitea.maximumdirect.net/ejr/weatherfeeder/model"
|
||||
)
|
||||
|
||||
func mapCurrentConditionsRow(row currentConditionsRow) *app.CurrentConditions {
|
||||
if row.SampleCount == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
conditionCode := model.WMOUnknown
|
||||
if row.ConditionCode.Valid {
|
||||
conditionCode = model.WMOCode(row.ConditionCode.Int64)
|
||||
}
|
||||
|
||||
return &app.CurrentConditions{
|
||||
TemperatureC: float64Ptr(row.TemperatureC),
|
||||
ApparentTemperatureC: float64Ptr(row.ApparentTemperatureC),
|
||||
DewpointC: float64Ptr(row.DewpointC),
|
||||
RelativeHumidityPercent: float64Ptr(row.RelativeHumidityPercent),
|
||||
WindSpeedKmh: float64Ptr(row.WindSpeedKmh),
|
||||
WindDirectionDegrees: float64Ptr(row.WindDirectionDegrees),
|
||||
ConditionCode: conditionCode,
|
||||
IsDay: boolPtr(row.IsDay),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user