Write reports to operator-selected outputs

This commit is contained in:
2026-08-01 19:33:12 +00:00
parent ac8d618111
commit 62a12dd661
17 changed files with 393 additions and 94 deletions

View File

@@ -11,8 +11,7 @@ import (
)
type plannedBatchReport struct {
Resolved report.Resolved
OutputCopyName string
Resolved report.Resolved
}
func planBatchRun(req BatchRequest, now time.Time, collection collect.Result) ([]plannedBatchReport, error) {
@@ -36,16 +35,16 @@ func planBatchRun(req BatchRequest, now time.Time, collection collect.Result) ([
var planned []plannedBatchReport
switch batch {
case report.Morning:
planned, err = appendPlannedReport(planned, registry, report.Today, resolveReq, "")
planned, err = appendPlannedReport(planned, registry, report.Today, resolveReq)
if err != nil {
return nil, err
}
planned, err = appendPlannedReport(planned, registry, report.Tomorrow, resolveReq, "")
planned, err = appendPlannedReport(planned, registry, report.Tomorrow, resolveReq)
if err != nil {
return nil, err
}
case report.Evening:
planned, err = appendPlannedReport(planned, registry, report.Tomorrow, resolveReq, "")
planned, err = appendPlannedReport(planned, registry, report.Tomorrow, resolveReq)
if err != nil {
return nil, err
}
@@ -60,8 +59,7 @@ func planBatchRun(req BatchRequest, now time.Time, collection collect.Result) ([
for _, date := range eligibleDailyDates(hourly, now, location) {
dailyReq := resolveReq
dailyReq.Date = date
outputCopyName := "daily-" + date.In(location).Format(timeutil.DateLayout) + ".md"
planned, err = appendPlannedReport(planned, registry, report.Daily, dailyReq, outputCopyName)
planned, err = appendPlannedReport(planned, registry, report.Daily, dailyReq)
if err != nil {
return nil, err
}
@@ -69,15 +67,12 @@ func planBatchRun(req BatchRequest, now time.Time, collection collect.Result) ([
return planned, nil
}
func appendPlannedReport(planned []plannedBatchReport, registry report.Registry, id report.ID, req report.ResolveRequest, outputCopyName string) ([]plannedBatchReport, error) {
func appendPlannedReport(planned []plannedBatchReport, registry report.Registry, id report.ID, req report.ResolveRequest) ([]plannedBatchReport, error) {
resolved, err := registry.Resolve(id, req)
if err != nil {
return nil, err
}
return append(planned, plannedBatchReport{
Resolved: resolved,
OutputCopyName: outputCopyName,
}), nil
return append(planned, plannedBatchReport{Resolved: resolved}), nil
}
func eligibleDailyDates(hourly *weatherdata.ForecastRun, now time.Time, location *time.Location) []time.Time {