Skip to content

Commit

Permalink
chore: set config analysis status to closed for old non observed ones
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra authored and moshloop committed Oct 7, 2024
1 parent 546a3f0 commit 45aa3d8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions jobs/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"time"

"github.com/flanksource/commons/properties"
v1 "github.com/flanksource/config-db/api/v1"
"github.com/flanksource/config-db/scrapers"
"github.com/flanksource/duty/db"
Expand Down Expand Up @@ -45,6 +46,14 @@ var CleanupConfigAnalysis = &job.Job{
ConfigAnalysisRetentionDays = DefaultConfigAnalysisRetentionDays
}

if err := ctx.DB().Exec(`
UPDATE config_analysis
SET status = 'closed'
WHERE (NOW() - last_observed) > INTERVAL '1 day' * ?
`, properties.Int(7, "config_analysis.set_status_closed_days")).Error; err != nil {
return err
}

tx := ctx.DB().Exec(`
DELETE FROM config_analysis
WHERE
Expand Down

0 comments on commit 45aa3d8

Please sign in to comment.