Skip to content

Commit 4c08e1e

Browse files
authored
exclude 'lists' too if we exclude CAPI (#2474)
1 parent d5b6f29 commit 4c08e1e

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

pkg/database/alerts.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ import (
2828
)
2929

3030
const (
31-
paginationSize = 100 // used to queryAlert to avoid 'too many SQL variable'
32-
defaultLimit = 100 // default limit of element to returns when query alerts
33-
bulkSize = 50 // bulk size when create alerts
34-
maxLockRetries = 10 // how many times to retry a bulk operation when sqlite3.ErrBusy is encountered
31+
paginationSize = 100 // used to queryAlert to avoid 'too many SQL variable'
32+
defaultLimit = 100 // default limit of element to returns when query alerts
33+
bulkSize = 50 // bulk size when create alerts
34+
maxLockRetries = 10 // how many times to retry a bulk operation when sqlite3.ErrBusy is encountered
3535
)
3636

3737
func formatAlertCN(source models.Source) string {
@@ -485,7 +485,6 @@ func (c *Client) UpdateCommunityBlocklist(alertItem *models.Alert) (int, int, in
485485
return alertRef.ID, inserted, deleted, nil
486486
}
487487

488-
489488
func (c *Client) createDecisionChunk(simulated bool, stopAtTime time.Time, decisions []*models.Decision) ([]*ent.Decision, error) {
490489
decisionCreate := make([]*ent.DecisionCreate, len(decisions))
491490

@@ -532,7 +531,6 @@ func (c *Client) createDecisionChunk(simulated bool, stopAtTime time.Time, decis
532531
return ret, nil
533532
}
534533

535-
536534
func (c *Client) createAlertChunk(machineID string, owner *ent.Machine, alerts []*models.Alert) ([]string, error) {
537535
alertBuilders := make([]*ent.AlertCreate, len(alerts))
538536
alertDecisions := make([][]*ent.Decision, len(alerts))
@@ -737,7 +735,6 @@ func (c *Client) createAlertChunk(machineID string, owner *ent.Machine, alerts [
737735
return ret, nil
738736
}
739737

740-
741738
func (c *Client) CreateAlert(machineID string, alertList []*models.Alert) ([]string, error) {
742739
var owner *ent.Machine
743740
var err error
@@ -863,6 +860,8 @@ func AlertPredicatesFromFilter(filter map[string][]string) ([]predicate.Alert, e
863860
case "include_capi": //allows to exclude one or more specific origins
864861
if value[0] == "false" {
865862
predicates = append(predicates, alert.Not(alert.HasDecisionsWith(decision.OriginEQ(types.CAPIOrigin))))
863+
predicates = append(predicates, alert.Not(alert.HasDecisionsWith(decision.OriginEQ(types.ListOrigin))))
864+
866865
} else if value[0] != "true" {
867866
log.Errorf("Invalid bool '%s' for include_capi", value[0])
868867
}

0 commit comments

Comments
 (0)