Skip to content

Commit

Permalink
chore: add refresh catalog job for 3d view (#1488)
Browse files Browse the repository at this point in the history
* chore: add refresh catalog job for 3d view

* Update jobs/catalog.go

---------

Co-authored-by: Moshe Immerman <moshe@flanksource.com>
  • Loading branch information
yashmehrotra and moshloop authored Oct 2, 2024
1 parent 8ac102b commit 0c87165
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
30 changes: 24 additions & 6 deletions jobs/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
2 changes: 1 addition & 1 deletion jobs/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 0c87165

Please sign in to comment.