exclude 'lists' too if we exclude CAPI (#2474)
This commit is contained in:
parent
d5b6f2974b
commit
4c08e1e68c
|
@ -28,10 +28,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
paginationSize = 100 // used to queryAlert to avoid 'too many SQL variable'
|
paginationSize = 100 // used to queryAlert to avoid 'too many SQL variable'
|
||||||
defaultLimit = 100 // default limit of element to returns when query alerts
|
defaultLimit = 100 // default limit of element to returns when query alerts
|
||||||
bulkSize = 50 // bulk size when create alerts
|
bulkSize = 50 // bulk size when create alerts
|
||||||
maxLockRetries = 10 // how many times to retry a bulk operation when sqlite3.ErrBusy is encountered
|
maxLockRetries = 10 // how many times to retry a bulk operation when sqlite3.ErrBusy is encountered
|
||||||
)
|
)
|
||||||
|
|
||||||
func formatAlertCN(source models.Source) string {
|
func formatAlertCN(source models.Source) string {
|
||||||
|
@ -485,7 +485,6 @@ func (c *Client) UpdateCommunityBlocklist(alertItem *models.Alert) (int, int, in
|
||||||
return alertRef.ID, inserted, deleted, nil
|
return alertRef.ID, inserted, deleted, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (c *Client) createDecisionChunk(simulated bool, stopAtTime time.Time, decisions []*models.Decision) ([]*ent.Decision, error) {
|
func (c *Client) createDecisionChunk(simulated bool, stopAtTime time.Time, decisions []*models.Decision) ([]*ent.Decision, error) {
|
||||||
decisionCreate := make([]*ent.DecisionCreate, len(decisions))
|
decisionCreate := make([]*ent.DecisionCreate, len(decisions))
|
||||||
|
|
||||||
|
@ -532,7 +531,6 @@ func (c *Client) createDecisionChunk(simulated bool, stopAtTime time.Time, decis
|
||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (c *Client) createAlertChunk(machineID string, owner *ent.Machine, alerts []*models.Alert) ([]string, error) {
|
func (c *Client) createAlertChunk(machineID string, owner *ent.Machine, alerts []*models.Alert) ([]string, error) {
|
||||||
alertBuilders := make([]*ent.AlertCreate, len(alerts))
|
alertBuilders := make([]*ent.AlertCreate, len(alerts))
|
||||||
alertDecisions := make([][]*ent.Decision, len(alerts))
|
alertDecisions := make([][]*ent.Decision, len(alerts))
|
||||||
|
@ -737,7 +735,6 @@ func (c *Client) createAlertChunk(machineID string, owner *ent.Machine, alerts [
|
||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (c *Client) CreateAlert(machineID string, alertList []*models.Alert) ([]string, error) {
|
func (c *Client) CreateAlert(machineID string, alertList []*models.Alert) ([]string, error) {
|
||||||
var owner *ent.Machine
|
var owner *ent.Machine
|
||||||
var err error
|
var err error
|
||||||
|
@ -863,6 +860,8 @@ func AlertPredicatesFromFilter(filter map[string][]string) ([]predicate.Alert, e
|
||||||
case "include_capi": //allows to exclude one or more specific origins
|
case "include_capi": //allows to exclude one or more specific origins
|
||||||
if value[0] == "false" {
|
if value[0] == "false" {
|
||||||
predicates = append(predicates, alert.Not(alert.HasDecisionsWith(decision.OriginEQ(types.CAPIOrigin))))
|
predicates = append(predicates, alert.Not(alert.HasDecisionsWith(decision.OriginEQ(types.CAPIOrigin))))
|
||||||
|
predicates = append(predicates, alert.Not(alert.HasDecisionsWith(decision.OriginEQ(types.ListOrigin))))
|
||||||
|
|
||||||
} else if value[0] != "true" {
|
} else if value[0] != "true" {
|
||||||
log.Errorf("Invalid bool '%s' for include_capi", value[0])
|
log.Errorf("Invalid bool '%s' for include_capi", value[0])
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue