Add Daily recent changes comparison

This commit is contained in:
2026-05-29 17:53:03 +00:00
parent b17a3591e0
commit 53a4abd508
12 changed files with 602 additions and 12 deletions

View File

@@ -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 {