writeActivity updates the PR's activity sequence number (using the optimistic locking mechanism), sets the correct Order value and writes the activity to the database. Even if the writing fails, the updating of the sequence number can succeed.
(ctx context.Context, pr *types.PullReq, act *types.PullReqActivity)
| 276 | // sets the correct Order value and writes the activity to the database. |
| 277 | // Even if the writing fails, the updating of the sequence number can succeed. |
| 278 | func (c *Controller) writeActivity(ctx context.Context, pr *types.PullReq, act *types.PullReqActivity) error { |
| 279 | prUpd, err := c.pullreqStore.UpdateActivitySeq(ctx, pr) |
| 280 | if err != nil { |
| 281 | return fmt.Errorf("failed to get pull request activity number: %w", err) |
| 282 | } |
| 283 | |
| 284 | *pr = *prUpd // update the pull request object |
| 285 | |
| 286 | act.Order = prUpd.ActivitySeq |
| 287 | |
| 288 | err = c.activityStore.Create(ctx, act) |
| 289 | if err != nil { |
| 290 | return fmt.Errorf("failed to create pull request activity: %w", err) |
| 291 | } |
| 292 | |
| 293 | return nil |
| 294 | } |
| 295 | |
| 296 | // writeReplyActivity updates the parent activity's reply sequence number (using the optimistic locking mechanism), |
| 297 | // sets the correct Order and SubOrder values and writes the activity to the database. |
no test coverage detected