MCPcopy Index your code
hub / github.com/harness/harness / writeActivity

Method writeActivity

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

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)

Source from the content-addressed store, hash-verified

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.
278func (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.

Callers 1

CommentCreateMethod · 0.95

Calls 3

UpdateActivitySeqMethod · 0.65
CreateMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected