Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GH-613]:Fixed issue "API rate limit exceeded for user ID". #626

Merged
merged 20 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1abdab2
[MI-2481]:Fixed issue #613 on github (#12)
Kshitij-Katiyar Dec 30, 2022
7ab3af2
[MI-2547]:Fixed review fixes for Github issue 613 and PR 626 (#14)
Kshitij-Katiyar Jan 6, 2023
862efaa
[MI-2582]:Fixed review comments for github issue #613 (#15)
Kshitij-Katiyar Jan 9, 2023
daeb982
Merge branch 'master' of github.com:mattermost/mattermost-plugin-gith…
Kshitij-Katiyar Jan 10, 2023
c792d99
Merge branch 'MM-613' of github.com:Brightscout/mattermost-plugin-git…
Kshitij-Katiyar Jan 10, 2023
6c80325
[MM-613]:Fixed review comments
Kshitij-Katiyar Feb 16, 2023
9388908
Merge branch 'master' of github.com:mattermost/mattermost-plugin-gith…
Kshitij-Katiyar Feb 22, 2023
3f9db5f
Merge branch 'master' of github.com:mattermost/mattermost-plugin-gith…
Kshitij-Katiyar Feb 28, 2023
9fa4533
[GH-613]:Fixed review comments
Kshitij-Katiyar May 8, 2023
c30c813
[MI-3072]:Converted the LHS APIs into GraphQL (#32)
Kshitij-Katiyar May 26, 2023
1210de0
[MM-613]:Changed namings
Kshitij-Katiyar May 26, 2023
609c781
[MM-613]:Fixed review comments
Kshitij-Katiyar May 31, 2023
5e3ca85
[MM-613]:Fixed review comments
Kshitij-Katiyar Jun 1, 2023
935d917
Merge branch 'master' of github.com:mattermost/mattermost-plugin-gith…
Kshitij-Katiyar Jun 30, 2023
7815f49
[MM-613]:Fixed panic error
Kshitij-Katiyar Jun 30, 2023
2571bb1
[MM-613]:Fixed review comments
Kshitij-Katiyar Jul 5, 2023
e8695ee
[MM-613]:Fixed lint errors
Kshitij-Katiyar Jul 5, 2023
3eec349
[MM-613]:Fixed review comment
Kshitij-Katiyar Jul 5, 2023
55cae89
[MM-613]:Fixed review comments
Kshitij-Katiyar Jul 10, 2023
772c8c3
[MM-613]:Fixed review comments
Kshitij-Katiyar Jul 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions server/plugin/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -950,15 +950,15 @@ func (p *Plugin) getLHSData(c *UserContext) (reviewResp []*github.Issue, assignm
}

func (p *Plugin) getSidebarData(c *UserContext) (*SidebarContent, error) {
reviweResp, assignmentResp, openPRResp, err := p.getLHSData(c)
reviewResp, assignmentResp, openPRResp, err := p.getLHSData(c)
if err != nil {
return nil, err
}

return &SidebarContent{
PRs: openPRResp,
Assignments: assignmentResp,
Reviews: reviweResp,
Reviews: reviewResp,
Unreads: p.getUnreadsData(c),
}, nil
}
Expand Down
22 changes: 11 additions & 11 deletions server/plugin/graphql/lhs_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

const (
queryParamReviewCursor = "reviewCursor"
queryParamReviewsCursor = "reviewsCursor"
queryParamAssignmentsCursor = "assignmentsCursor"
queryParamOpenPRsCursor = "openPrsCursor"

Expand All @@ -24,7 +24,7 @@ func (c *Client) GetLHSData(ctx context.Context) ([]*github.Issue, []*github.Iss
queryParamOpenPRQueryArg: githubv4.String(fmt.Sprintf("author:%s is:pr is:%s archived:false", c.username, githubv4.PullRequestStateOpen)),
queryParamReviewPRQueryArg: githubv4.String(fmt.Sprintf("review-requested:%s is:pr is:%s archived:false", c.username, githubv4.PullRequestStateOpen)),
queryParamAssigneeQueryArg: githubv4.String(fmt.Sprintf("assignee:%s is:%s archived:false", c.username, githubv4.PullRequestStateOpen)),
queryParamReviewCursor: (*githubv4.String)(nil),
queryParamReviewsCursor: (*githubv4.String)(nil),
queryParamAssignmentsCursor: (*githubv4.String)(nil),
queryParamOpenPRsCursor: (*githubv4.String)(nil),
}
Expand All @@ -36,54 +36,54 @@ func (c *Client) GetLHSData(ctx context.Context) ([]*github.Issue, []*github.Iss
}

var resultPR, resultAssignee, resultOpenPR []*github.Issue
flagPR, flagAssignee, flagOpenPR := false, false, false
allPRsFetched, allAssigneesFetched, allopenPRsFetched := false, false, false
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved

for {
if flagPR && flagAssignee && flagOpenPR {
if allPRsFetched && allAssigneesFetched && allopenPRsFetched {
break
}

if err := c.executeQuery(ctx, &mainQuery, params); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we ever fetching duplicate data here? e.g. If flagOpenPR is true, do we still request some PR data from GitHub?

Copy link
Contributor Author

@Kshitij-Katiyar Kshitij-Katiyar Jul 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There could be a time when one of the 3 is nil but other entry still have some data to fetch. In that case we still need to call the API as we want to get the other part of the data and there is only 1 API call and a single query happening here. @mickmister

return nil, nil, nil, errors.Wrap(err, "Not able to excute the query")
}

if !flagPR {
if !allPRsFetched {
for i := range mainQuery.PullRequest.Nodes {
resp := mainQuery.PullRequest.Nodes[i]
pr := getPR(&resp)
resultPR = append(resultPR, pr)
}

if !mainQuery.PullRequest.PageInfo.HasNextPage {
flagPR = true
allPRsFetched = true
}

params[queryParamReviewCursor] = githubv4.NewString(mainQuery.PullRequest.PageInfo.EndCursor)
params[queryParamReviewsCursor] = githubv4.NewString(mainQuery.PullRequest.PageInfo.EndCursor)
}

if !flagAssignee {
if !allAssigneesFetched {
for i := range mainQuery.Assignee.Nodes {
resp := mainQuery.Assignee.Nodes[i]
issue := getIssue(&resp)
resultAssignee = append(resultAssignee, issue)
}

if !mainQuery.Assignee.PageInfo.HasNextPage {
flagAssignee = true
allAssigneesFetched = true
}

params[queryParamAssignmentsCursor] = githubv4.NewString(mainQuery.Assignee.PageInfo.EndCursor)
}

if !flagOpenPR {
if !allopenPRsFetched {
for i := range mainQuery.OpenPullRequest.Nodes {
resp := mainQuery.OpenPullRequest.Nodes[i]
pr := getPR(&resp)
resultOpenPR = append(resultOpenPR, pr)
}

if !mainQuery.OpenPullRequest.PageInfo.HasNextPage {
flagOpenPR = true
allopenPRsFetched = true
}

params[queryParamOpenPRsCursor] = githubv4.NewString(mainQuery.OpenPullRequest.PageInfo.EndCursor)
Expand Down