MCPcopy
hub / github.com/harness/harness / ActivityList

Method ActivityList

app/api/controller/pullreq/activity_list.go:28–63  ·  view source on GitHub ↗

ActivityList returns a list of pull request activities from the provided repository and pull request number.

(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	prNum int64,
	filter *types.PullReqActivityFilter,
)

Source from the content-addressed store, hash-verified

26// ActivityList returns a list of pull request activities
27// from the provided repository and pull request number.
28func (c *Controller) ActivityList(
29 ctx context.Context,
30 session *auth.Session,
31 repoRef string,
32 prNum int64,
33 filter *types.PullReqActivityFilter,
34) ([]*types.PullReqActivity, error) {
35 repo, err := c.getRepoCheckAccess(ctx, session, repoRef, enum.PermissionRepoView)
36 if err != nil {
37 return nil, fmt.Errorf("failed to acquire access to repo: %w", err)
38 }
39
40 pr, err := c.pullreqStore.FindByNumber(ctx, repo.ID, prNum)
41 if err != nil {
42 return nil, fmt.Errorf("failed to find pull request by number: %w", err)
43 }
44
45 list, err := c.activityStore.List(ctx, pr.ID, filter)
46 if err != nil {
47 return nil, fmt.Errorf("failed to list pull requests activities: %w", err)
48 }
49
50 for _, act := range list {
51 if act.Metadata != nil && act.Metadata.Mentions != nil {
52 mentions, err := c.principalInfoCache.Map(ctx, act.Metadata.Mentions.IDs)
53 if err != nil {
54 return nil, fmt.Errorf("failed to fetch activity mentions from principalInfoView: %w", err)
55 }
56 act.Mentions = mentions
57 }
58 }
59
60 list = removeDeletedComments(list)
61
62 return list, nil
63}
64
65func allCommentsDeleted(comments []*types.PullReqActivity) bool {
66 for _, comment := range comments {

Callers 1

HandleListActivitiesFunction · 0.80

Calls 6

getRepoCheckAccessMethod · 0.95
removeDeletedCommentsFunction · 0.85
FindByNumberMethod · 0.65
ListMethod · 0.65
MapMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected