diff --git a/jobs/catalog.go b/jobs/catalog.go index 9ac3e5a75..a54d1f634 100644 --- a/jobs/catalog.go +++ b/jobs/catalog.go @@ -4,26 +4,44 @@ import ( "github.com/flanksource/duty/job" ) -var RefreshCatalogAnaylsisChangeCount7dView = &job.Job{ - Name: "RefreshCatalogAnaylsisChangeCount7dView", +var RefreshConfigItemSummary3dView = &job.Job{ + Name: "RefreshConfigItemSummary3dView", Schedule: "@every 10m", Retention: job.RetentionFew, Singleton: true, JobHistory: true, RunNow: true, Fn: func(ctx job.JobRuntime) error { - return job.RefreshConfigItemAnalysisChangeCount7d(ctx.Context) + return job.RefreshConfigItemSummary3d(ctx.Context) }, } -var RefreshCatalogAnaylsisChangeCount30dView = &job.Job{ - Name: "RefreshCatalogAnaylsisChangeCount30dView", +var RefreshConfigItemSummary7dView = &job.Job{ + Name: "RefreshConfigItemSummary7dView", + Schedule: "@every 30m", + Retention: job.RetentionFew, + Singleton: true, + JobHistory: true, + RunNow: true, + Fn: func(ctx job.JobRuntime) error { + return job.RefreshConfigItemSummary7d(ctx.Context) + }, +} + +var RefreshConfigItemSummary30dView = &job.Job{ + Name: "RefreshConfigItemSummary30dView", Schedule: "@every 1h", Retention: job.RetentionFew, Singleton: true, JobHistory: true, RunNow: true, Fn: func(ctx job.JobRuntime) error { - return job.RefreshConfigItemAnalysisChangeCount30d(ctx.Context) + return job.RefreshConfigItemSummary30d(ctx.Context) }, } + +var CatalogRefreshJobs = []*job.Job{ + RefreshConfigItemSummary3dView, + RefreshConfigItemSummary7dView, + RefreshConfigItemSummary30dView, +} diff --git a/jobs/jobs.go b/jobs/jobs.go index fdf3f14da..9b7d75d76 100644 --- a/jobs/jobs.go +++ b/jobs/jobs.go @@ -69,7 +69,7 @@ func Start(ctx context.Context) { logger.Errorf("Failed to schedule job for syncing config cache: %v", err) } - for _, job := range []*job.Job{RefreshCatalogAnaylsisChangeCount7dView, RefreshCatalogAnaylsisChangeCount30dView} { + for _, job := range CatalogRefreshJobs { j := job j.Context = ctx if err := j.AddToScheduler(FuncScheduler); err != nil {