-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Conversation
❌ 12 Tests Failed:
View the top 3 failed tests by shortest run time
To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard |
8d48f2b
to
9a59982
Compare
] | ||
pr_file_issues.sort(key=lambda k: k.get("event_count", 0), reverse=True) | ||
|
||
return Response(pr_file_issues) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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 "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) |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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"} |
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 "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
9a59982
to
ca48219
Compare
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 "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
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.