(ctx context.Context, alertItems []*ent.Alert)
| 890 | } |
| 891 | |
| 892 | func (c *Client) DeleteAlertGraphBatch(ctx context.Context, alertItems []*ent.Alert) (int, error) { |
| 893 | idList := make([]int, 0) |
| 894 | for _, alert := range alertItems { |
| 895 | idList = append(idList, alert.ID) |
| 896 | } |
| 897 | |
| 898 | _, err := c.Ent.Event.Delete(). |
| 899 | Where(event.HasOwnerWith(alert.IDIn(idList...))).Exec(ctx) |
| 900 | if err != nil { |
| 901 | c.Log.Warningf("DeleteAlertGraphBatch : %s", err) |
| 902 | return 0, fmt.Errorf("alert graph delete batch events: %w", DeleteFail) |
| 903 | } |
| 904 | |
| 905 | _, err = c.Ent.Meta.Delete(). |
| 906 | Where(meta.HasOwnerWith(alert.IDIn(idList...))).Exec(ctx) |
| 907 | if err != nil { |
| 908 | c.Log.Warningf("DeleteAlertGraphBatch : %s", err) |
| 909 | return 0, fmt.Errorf("alert graph delete batch meta: %w", DeleteFail) |
| 910 | } |
| 911 | |
| 912 | _, err = c.Ent.Decision.Delete(). |
| 913 | Where(decision.HasOwnerWith(alert.IDIn(idList...))).Exec(ctx) |
| 914 | if err != nil { |
| 915 | c.Log.Warningf("DeleteAlertGraphBatch : %s", err) |
| 916 | return 0, fmt.Errorf("alert graph delete batch decisions: %w", DeleteFail) |
| 917 | } |
| 918 | |
| 919 | deleted, err := c.Ent.Alert.Delete(). |
| 920 | Where(alert.IDIn(idList...)).Exec(ctx) |
| 921 | if err != nil { |
| 922 | c.Log.Warningf("DeleteAlertGraphBatch : %s", err) |
| 923 | return deleted, fmt.Errorf("alert graph delete batch: %w", DeleteFail) |
| 924 | } |
| 925 | |
| 926 | c.Log.Debug("Done batch delete alerts") |
| 927 | |
| 928 | return deleted, nil |
| 929 | } |
| 930 | |
| 931 | func (c *Client) DeleteAlertGraph(ctx context.Context, alertItem *ent.Alert) error { |
| 932 | // delete the associated events |
nothing calls this directly
no test coverage detected