Add Daily recent changes comparison
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"gitea.maximumdirect.net/eric/weatherreporter/internal/briefing"
|
||||
"gitea.maximumdirect.net/eric/weatherreporter/internal/changes"
|
||||
"gitea.maximumdirect.net/eric/weatherreporter/internal/forecast"
|
||||
"gitea.maximumdirect.net/eric/weatherreporter/internal/report"
|
||||
"gitea.maximumdirect.net/eric/weatherreporter/internal/timeutil"
|
||||
@@ -35,15 +36,19 @@ type Report struct {
|
||||
}
|
||||
|
||||
type RecentChanges struct {
|
||||
Items []Change `json:"items"`
|
||||
}
|
||||
|
||||
type Change struct {
|
||||
Type string `json:"type"`
|
||||
Message string `json:"message"`
|
||||
Items []changes.Change `json:"items"`
|
||||
}
|
||||
|
||||
func Build(briefingPackage briefing.Package) (Package, error) {
|
||||
return BuildWithRecentChanges(briefingPackage, nil)
|
||||
}
|
||||
|
||||
func BuildWithRecentChanges(briefingPackage briefing.Package, recentChanges []changes.Change) (Package, error) {
|
||||
items := make([]changes.Change, len(recentChanges))
|
||||
copy(items, recentChanges)
|
||||
if items == nil {
|
||||
items = []changes.Change{}
|
||||
}
|
||||
pkg := Package{
|
||||
SchemaVersion: SchemaVersion,
|
||||
RunID: briefingPackage.Metadata.RunID,
|
||||
@@ -56,7 +61,7 @@ func Build(briefingPackage briefing.Package) (Package, error) {
|
||||
ValidPeriod: briefingPackage.Metadata.ValidPeriod,
|
||||
},
|
||||
Briefing: briefingPackage,
|
||||
RecentChanges: RecentChanges{Items: []Change{}},
|
||||
RecentChanges: RecentChanges{Items: items},
|
||||
SourceWarnings: briefingPackage.Metadata.SourceWarnings,
|
||||
}
|
||||
if err := Validate(pkg); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user