Add 3-Day Outlook generation
This commit is contained in:
@@ -151,7 +151,11 @@ func (s *FilesystemStore) SaveMetadata(_ context.Context, metadata Metadata) (st
|
||||
return path, nil
|
||||
}
|
||||
|
||||
func (s *FilesystemStore) FindPriorDailySnapshot(_ context.Context, resolved report.Resolved) (*PriorSnapshot, error) {
|
||||
func (s *FilesystemStore) FindPriorDailySnapshot(ctx context.Context, resolved report.Resolved) (*PriorSnapshot, error) {
|
||||
return s.FindPriorSnapshot(ctx, resolved)
|
||||
}
|
||||
|
||||
func (s *FilesystemStore) FindPriorSnapshot(_ context.Context, resolved report.Resolved) (*PriorSnapshot, error) {
|
||||
if resolved.Definition.ComparisonStrategy != report.CompareSameValidDate {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -159,9 +163,6 @@ func (s *FilesystemStore) FindPriorDailySnapshot(_ context.Context, resolved rep
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if group != "daily" {
|
||||
return nil, nil
|
||||
}
|
||||
paths, err := s.Paths(resolved)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -188,7 +189,7 @@ func (s *FilesystemStore) FindPriorDailySnapshot(_ context.Context, resolved rep
|
||||
if metadata.RunID == resolved.Metadata().RunID {
|
||||
continue
|
||||
}
|
||||
if metadata.ReportID != report.DailyToday && metadata.ReportID != report.DailyTomorrow {
|
||||
if !compatiblePriorReport(group, metadata.ReportID, resolved.Definition.ID) {
|
||||
continue
|
||||
}
|
||||
if !sameValidDate(metadata, resolved) {
|
||||
@@ -211,6 +212,17 @@ func (s *FilesystemStore) FindPriorDailySnapshot(_ context.Context, resolved rep
|
||||
}, nil
|
||||
}
|
||||
|
||||
func compatiblePriorReport(group string, prior report.ID, current report.ID) bool {
|
||||
switch group {
|
||||
case "daily":
|
||||
return prior == report.DailyToday || prior == report.DailyTomorrow
|
||||
case "three-day":
|
||||
return prior == report.ThreeDay && current == report.ThreeDay
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func (s *FilesystemStore) join(parts ...string) string {
|
||||
all := append([]string{s.root}, parts...)
|
||||
return filepath.Join(all...)
|
||||
|
||||
Reference in New Issue
Block a user