Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type hint in delete history by ids statement. #5249

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions cmd/server/app/history_purge.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
_ "github.com/golang-migrate/migrate/v4/database/postgres" // nolint
_ "github.com/golang-migrate/migrate/v4/source/file" // nolint
"github.com/google/uuid"
"github.com/rs/zerolog"
"github.com/spf13/cobra"
"github.com/spf13/viper"

Expand Down Expand Up @@ -53,9 +54,9 @@ func historyPurgeCommand(cmd *cobra.Command, _ []string) error {
// We maintain up to 30 days of history, plus any record
// that's the latest for any entity/rule pair.
threshold := time.Now().UTC().AddDate(0, 0, -30)
cmd.Printf("Calculated threshold is %s", threshold)
zerolog.Ctx(ctx).Info().Msgf("Calculated threshold is %s", threshold)

if err := purgeLoop(ctx, store, threshold, batchSize, dryRun, cmd.Printf); err != nil {
if err := purgeLoop(ctx, store, threshold, batchSize, dryRun); err != nil {
cliErrorf(cmd, "failed purging evaluation log: %s", err)
}

Expand Down Expand Up @@ -88,7 +89,6 @@ func purgeLoop(
threshold time.Time,
batchSize uint,
dryRun bool,
printf func(format string, a ...any),
) error {
deleted := 0

Expand All @@ -107,7 +107,7 @@ func purgeLoop(
}

if len(records) == 0 {
printf("No records to delete\n")
zerolog.Ctx(ctx).Info().Msg("No records to delete\n")
return nil
}

Expand All @@ -124,7 +124,7 @@ func purgeLoop(
}
}

printf("Done purging history, deleted %d records\n",
zerolog.Ctx(ctx).Info().Msgf("Done purging history, deleted %d records",
deleted,
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/server/app/history_purge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func TestPurgeLoop(t *testing.T) {
store = tt.dbSetup(ctrl)
}

err := purgeLoop(ctx, store, tt.threshold, tt.size, tt.dryRun, t.Logf)
err := purgeLoop(ctx, store, tt.threshold, tt.size, tt.dryRun)
if tt.err {
require.Error(t, err)
return
Expand Down
2 changes: 1 addition & 1 deletion database/query/eval_history.sql
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,4 @@ SELECT s.evaluation_time,

-- name: DeleteEvaluationHistoryByIDs :execrows
DELETE FROM evaluation_statuses s
WHERE s.id = ANY(sqlc.slice(evaluationIds));
WHERE s.id = ANY(sqlc.slice(evaluationIds)::uuid[]);
15 changes: 2 additions & 13 deletions internal/db/eval_history.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading