Implemented weather stories support
All checks were successful
ci/woodpecker/push/build-image Pipeline was successful
All checks were successful
ci/woodpecker/push/build-image Pipeline was successful
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
// weatherstories.go presents weather story payloads.
|
||||
// Layer: adapters/inbound/httpapi/presenter weather stories payload mapping.
|
||||
package presenter
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gitea.maximumdirect.net/ejr/weatherfeeder/model"
|
||||
)
|
||||
|
||||
func WeatherStoryRunPayload(run *model.WeatherStoryRun, _ Units, tz *time.Location) any {
|
||||
if run == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
out := model.WeatherStoryRun{
|
||||
OfficeID: run.OfficeID,
|
||||
AsOf: inLocationTime(run.AsOf, tz),
|
||||
Stories: make([]model.WeatherStory, 0, len(run.Stories)),
|
||||
}
|
||||
for _, story := range run.Stories {
|
||||
out.Stories = append(out.Stories, copyWeatherStory(story, tz))
|
||||
}
|
||||
return &out
|
||||
}
|
||||
|
||||
func WeatherStoryPayload(story *model.WeatherStory, _ Units, tz *time.Location) any {
|
||||
if story == nil {
|
||||
return nil
|
||||
}
|
||||
out := copyWeatherStory(*story, tz)
|
||||
return &out
|
||||
}
|
||||
|
||||
func copyWeatherStory(story model.WeatherStory, tz *time.Location) model.WeatherStory {
|
||||
return model.WeatherStory{
|
||||
OfficeID: story.OfficeID,
|
||||
StartTime: inLocationTime(story.StartTime, tz),
|
||||
EndTime: inLocationTime(story.EndTime, tz),
|
||||
UpdatedAt: inLocationTime(story.UpdatedAt, tz),
|
||||
Title: story.Title,
|
||||
Description: story.Description,
|
||||
AltText: story.AltText,
|
||||
Priority: story.Priority,
|
||||
Order: story.Order,
|
||||
DownloadURL: story.DownloadURL,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user