| 425 | } |
| 426 | |
| 427 | func (a *apic) CAPIPullIsOld(ctx context.Context) (bool, error) { |
| 428 | /*only pull community blocklist if it's older than 1h30 */ |
| 429 | alerts := a.dbClient.Ent.Alert.Query() |
| 430 | |
| 431 | alerts = alerts.Where(alert.HasDecisionsWith(decision.OriginEQ(database.CapiMachineID))) |
| 432 | alerts = alerts.Where(alert.CreatedAtGTE(time.Now().UTC().Add(-time.Duration(1*time.Hour + 30*time.Minute)))) //nolint:unconvert |
| 433 | |
| 434 | count, err := alerts.Count(ctx) |
| 435 | if err != nil { |
| 436 | return false, fmt.Errorf("while looking for CAPI alert: %w", err) |
| 437 | } |
| 438 | |
| 439 | if count > 0 { |
| 440 | log.Info("last CAPI pull is newer than 1h30, skip.") |
| 441 | return false, nil |
| 442 | } |
| 443 | |
| 444 | return true, nil |
| 445 | } |
| 446 | |
| 447 | func (a *apic) HandleDeletedDecisionsV3(ctx context.Context, deletedDecisions []*modelscapi.GetDecisionsStreamResponseDeletedItem, deleteCounters map[string]map[string]int) (int, error) { |
| 448 | var nbDeleted int |