Skip to content

Commit 6c0c979

Browse files
committed
papi: attach decisions to alert during creation
1 parent 2da8406 commit 6c0c979

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

pkg/database/alerts.go

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,8 @@ func (c *Client) CreateOrUpdateAlert(ctx context.Context, machineID string, aler
164164
SetScope(*decisionItem.Scope).
165165
SetOrigin(*decisionItem.Origin).
166166
SetSimulated(*alertItem.Simulated).
167-
SetUUID(decisionItem.UUID)
168-
// XXX: can we attach the alert here and remove the second call to Batch() ?
169-
// SetOwnerID(foundAlert.ID)
167+
SetUUID(decisionItem.UUID).
168+
SetOwnerID(foundAlert.ID)
170169

171170
decisionBuilders = append(decisionBuilders, decisionBuilder)
172171
}
@@ -185,17 +184,6 @@ func (c *Client) CreateOrUpdateAlert(ctx context.Context, machineID string, aler
185184
return "", err
186185
}
187186

188-
// attach decisions to alert in batches
189-
190-
if err := slicetools.Batch(ctx, decisions, c.decisionBulkSize, func(ctx context.Context, d []*ent.Decision) error {
191-
if err := c.Ent.Alert.Update().Where(alert.UUID(alertItem.UUID)).AddDecisions(d...).Exec(ctx); err != nil {
192-
return fmt.Errorf("updating alert %s: %w", alertItem.UUID, err)
193-
}
194-
return nil
195-
}); err != nil {
196-
return "", err
197-
}
198-
199187
return "", nil
200188
}
201189

0 commit comments

Comments
 (0)