MCPcopy
hub / github.com/harness/harness / writeReplyActivity

Method writeReplyActivity

app/api/controller/pullreq/comment_create.go:299–319  ·  view source on GitHub ↗

writeReplyActivity updates the parent activity's reply sequence number (using the optimistic locking mechanism), sets the correct Order and SubOrder values and writes the activity to the database. Even if the writing fails, the updating of the sequence number can succeed.

(ctx context.Context, parent, act *types.PullReqActivity)

Source from the content-addressed store, hash-verified

297// sets the correct Order and SubOrder values and writes the activity to the database.
298// Even if the writing fails, the updating of the sequence number can succeed.
299func (c *Controller) writeReplyActivity(ctx context.Context, parent, act *types.PullReqActivity) error {
300 parentUpd, err := c.activityStore.UpdateOptLock(ctx, parent, func(act *types.PullReqActivity) error {
301 act.ReplySeq++
302 return nil
303 })
304 if err != nil {
305 return fmt.Errorf("failed to get pull request activity number: %w", err)
306 }
307
308 *parent = *parentUpd // update the parent pull request activity object
309
310 act.Order = parentUpd.Order
311 act.SubOrder = parentUpd.ReplySeq
312
313 err = c.activityStore.Create(ctx, act)
314 if err != nil {
315 return fmt.Errorf("failed to create pull request activity: %w", err)
316 }
317
318 return nil
319}
320
321func getCommentActivity(
322 session *auth.Session,

Callers 1

CommentCreateMethod · 0.95

Calls 3

UpdateOptLockMethod · 0.65
CreateMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected