Skip to content

Commit

Permalink
db: force decisions to have an expiration timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
mmetc committed Aug 22, 2024
1 parent 429418f commit 04729ae
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 67 deletions.
2 changes: 1 addition & 1 deletion pkg/apiserver/apic.go
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ func (a *apic) ShouldForcePullBlocklist(blocklist *modelscapi.BlocklistLink) (bo
return false, fmt.Errorf("while getting decision: %w", err)
}

if firstDecision == nil || firstDecision.Until == nil || firstDecision.Until.Sub(time.Now().UTC()) < (a.pullInterval+15*time.Minute) {
if firstDecision == nil || firstDecision.Until.Sub(time.Now().UTC()) < (a.pullInterval+15*time.Minute) {

Check warning on line 817 in pkg/apiserver/apic.go

View check run for this annotation

Codecov / codecov/patch

pkg/apiserver/apic.go#L817

Added line #L817 was not covered by tests
log.Debugf("at least one decision found for %s, expire soon, force refresh", *blocklist.Name)
return true, nil
}
Expand Down
11 changes: 4 additions & 7 deletions pkg/database/ent/decision.go

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

10 changes: 0 additions & 10 deletions pkg/database/ent/decision/where.go

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

13 changes: 4 additions & 9 deletions pkg/database/ent/decision_create.go

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

18 changes: 0 additions & 18 deletions pkg/database/ent/decision_update.go

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

2 changes: 1 addition & 1 deletion pkg/database/ent/migrate/schema.go

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

21 changes: 1 addition & 20 deletions pkg/database/ent/mutation.go

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

2 changes: 1 addition & 1 deletion pkg/database/ent/schema/decision.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (Decision) Fields() []ent.Field {
field.Time("updated_at").
Default(types.UtcNow).
UpdateDefault(types.UtcNow),
field.Time("until").Nillable().Optional().SchemaType(map[string]string{
field.Time("until").SchemaType(map[string]string{
dialect.MySQL: "datetime",
}),
field.String("scenario").Immutable(),
Expand Down

0 comments on commit 04729ae

Please sign in to comment.