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

feat(scm): pull request file issues API #74352

Closed
wants to merge 3 commits into from

Conversation

cathteng
Copy link
Member

@cathteng cathteng commented Jul 16, 2024

API for users to upload their PR file information (filename, patch) to find issues associated with those files. This API can fetch issues for a single file.

This expands the scope of open PR issue comments beyond GitHub, and people can hit the API in their custom flows as well.

The API supports the ability to set a max limit on the number of issues to return, open PR comments only fetches a max of 5 per file -- using that as the default here.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 16, 2024
Copy link

codecov bot commented Jul 16, 2024

❌ 12 Tests Failed:

Tests completed Failed Passed Skipped
114 12 102 1
View the top 3 failed tests by shortest run time
 tests.sentry.api.endpoints.test_system_options
Stack Traces | 0s run time
No failure message available
 tests.sentry.hybridcloud.apigateway.test_apigateway
Stack Traces | 0s run time
No failure message available
 tests.sentry.middleware.integrations.parsers.test_github_enterprise
Stack Traces | 0s run time
No failure message available

To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard

@cathteng cathteng marked this pull request as ready for review August 5, 2024 22:06
@cathteng cathteng requested review from a team as code owners August 5, 2024 22:06
@cathteng cathteng requested a review from a team August 5, 2024 22:42
]
pr_file_issues.sort(key=lambda k: k.get("event_count", 0), reverse=True)

return Response(pr_file_issues)
Copy link
Member

Choose a reason for hiding this comment

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

nit - if the end goal is for others to use this api, i would use a serializer here to return to make life less painful when ur documenting the endpoint. or u can just kick the can when u get there.

Copy link
Member

Choose a reason for hiding this comment

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

Use a serializer everywhere actually even if it's not going to be publicly documented. It's more typed and readable.

@iamrajjoshi iamrajjoshi requested a review from a team August 5, 2024 22:52
@getsantry
Copy link
Contributor

getsantry bot commented Aug 27, 2024

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you add the label WIP, I will leave it alone unless WIP is removed ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

]
pr_file_issues.sort(key=lambda k: k.get("event_count", 0), reverse=True)

return Response(pr_file_issues)
Copy link
Member

Choose a reason for hiding this comment

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

Use a serializer everywhere actually even if it's not going to be publicly documented. It's more typed and readable.

)


class PullRequestFileSerializer(serializers.Serializer):
Copy link
Member

Choose a reason for hiding this comment

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

How is this gets related to a PR? Is it by patch? Or I can pass any file and get issues for it regardless of PR?

return value

def validate_limit(self, value):
if value and value < 1 or value > 100:
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be if value is not None? It looks like this won't raise an error on an int value of 0.

Also, nit: value < 1 or value > 100 can be written as not (1 <= value <= 100).

org_id=organization.id, repo_name=repo_name, pr_filename=filename
)

if not len(projects) or not len(sentry_filenames):
Copy link
Contributor

Choose a reason for hiding this comment

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

Style nit: empty collections are falsy, so you don't need len. Just if not projects or not sentry_filenames will work.

I'd also consider writing if not (projects and sentry_filenames), but that's a matter of taste.

group_id_to_info = {}
for issue in top_issues:
group_id = issue["group_id"]
group_id_to_info[group_id] = dict(filter(lambda k: k[0] != "group_id", issue.items()))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
group_id_to_info[group_id] = dict(filter(lambda k: k[0] != "group_id", issue.items()))
group_id_to_info[group_id] = {k: v for (k, v) in issue.items() if k != "group_id"}

@getsantry
Copy link
Contributor

getsantry bot commented Sep 27, 2024

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you add the label WIP, I will leave it alone unless WIP is removed ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added Stale and removed Stale labels Sep 27, 2024
@getsantry
Copy link
Contributor

getsantry bot commented Oct 23, 2024

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you add the label WIP, I will leave it alone unless WIP is removed ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added the Stale label Oct 23, 2024
@getsantry getsantry bot closed this Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants