ExpireDecisions sets the expiration of a list of decisions to now(), in multiple operations if len(decisions) > decisionDeleteBulkSize. It returns the number of impacted decisions for the CAPI/PAPI, even in case of error.
(ctx context.Context, decisions []*ent.Decision)
| 326 | // in multiple operations if len(decisions) > decisionDeleteBulkSize. |
| 327 | // It returns the number of impacted decisions for the CAPI/PAPI, even in case of error. |
| 328 | func (c *Client) ExpireDecisions(ctx context.Context, decisions []*ent.Decision) (int, error) { |
| 329 | if len(decisions) == 0 { |
| 330 | return 0, nil |
| 331 | } |
| 332 | |
| 333 | now := time.Now().UTC() |
| 334 | |
| 335 | total := 0 |
| 336 | err := slicetools.Batch(ctx, decisions, decisionDeleteBulkSize, func(ctx context.Context, batch []*ent.Decision) error { |
| 337 | rows, err := c.expireDecisionBatch(ctx, batch, now) |
| 338 | if err != nil { |
| 339 | return err |
| 340 | } |
| 341 | total += rows |
| 342 | return nil |
| 343 | }) |
| 344 | |
| 345 | return total, err |
| 346 | } |
| 347 | |
| 348 | // deleteDecisionBatch removes the decisions as a single operation. |
| 349 | func (c *Client) deleteDecisionBatch(ctx context.Context, batch []*ent.Decision) (int, error) { |
no test coverage detected