Skip to content

Commit

Permalink
fix: check cleanup range interval
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra committed Feb 1, 2024
1 parent 75a5da8 commit 5fc0663
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/topology/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ var CleanupChecks = &job.Job{
JobHistory: true,
Retention: job.Retention3Day,
Fn: func(ctx job.JobRuntime) error {
retention := ctx.Properties().Duration("check.retention.age", DefaultRetention)
tx := ctx.DB().Exec(`
DELETE FROM checks
WHERE
id NOT IN (SELECT check_id FROM evidences WHERE check_id IS NOT NULL) AND
(NOW() - deleted_at) > INTERVAL '1 day' * ?
`, ctx.Properties().Duration("check.retention.age", DefaultRetention))
(NOW() - deleted_at) > INTERVAL '1 second' * ?
`, int64(retention.Seconds()),
)

ctx.History.SuccessCount = int(tx.RowsAffected)
return tx.Error
Expand Down

0 comments on commit 5fc0663

Please sign in to comment.