Skip to content

Commit

Permalink
chore: add catalog summary materialized view referesh jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra committed Sep 20, 2024
1 parent 8481e91 commit 5b3843a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
29 changes: 29 additions & 0 deletions jobs/catalog.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package jobs

import (
"github.com/flanksource/duty/job"
)

var RefreshCatalogAnaylsisChangeCount7dView = &job.Job{
Name: "RefreshCatalogAnaylsisChangeCount7dView",
Schedule: "@every 10m",
Retention: job.RetentionFew,
Singleton: true,
JobHistory: true,
RunNow: true,
Fn: func(ctx job.JobRuntime) error {
return job.RefreshConfigItemAnalysisChangeCount7d(ctx.Context)

Check failure on line 15 in jobs/catalog.go

View workflow job for this annotation

GitHub Actions / lint

undefined: job.RefreshConfigItemAnalysisChangeCount7d

Check failure on line 15 in jobs/catalog.go

View workflow job for this annotation

GitHub Actions / lint

undefined: job.RefreshConfigItemAnalysisChangeCount7d
},
}

var RefreshCatalogAnaylsisChangeCount30dView = &job.Job{
Name: "RefreshCatalogAnaylsisChangeCount30dView",
Schedule: "@every 1h",
Retention: job.RetentionFew,
Singleton: true,
JobHistory: true,
RunNow: true,
Fn: func(ctx job.JobRuntime) error {
return job.RefreshConfigItemAnalysisChangeCount30d(ctx.Context)

Check failure on line 27 in jobs/catalog.go

View workflow job for this annotation

GitHub Actions / lint

undefined: job.RefreshConfigItemAnalysisChangeCount30d (typecheck)

Check failure on line 27 in jobs/catalog.go

View workflow job for this annotation

GitHub Actions / lint

undefined: job.RefreshConfigItemAnalysisChangeCount30d) (typecheck)
},
}
8 changes: 8 additions & 0 deletions jobs/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ func Start(ctx context.Context) {
logger.Errorf("Failed to schedule job for syncing config cache: %v", err)
}

for _, job := range []*job.Job{RefreshCatalogAnaylsisChangeCount7dView, RefreshCatalogAnaylsisChangeCount30dView} {
j := job
j.Context = ctx
if err := j.AddToScheduler(FuncScheduler); err != nil {
logger.Errorf("Failed to schedule %s: %v", j, err)
}
}

if api.UpstreamConf.Valid() {
for _, job := range agentJobs {
j := job
Expand Down

0 comments on commit 5b3843a

Please sign in to comment.