Consider GitHub PR review comments#465
Open
pcahyna wants to merge 2 commits into
Open
Conversation
| # pr_dict is a small dict that contains the actual pull request URL. | ||
| # print(f"URL: {pr_dict['url']}") | ||
| response = self.request(pr_dict['url']) | ||
| # the full PR dict, contains different fields than the issue dict |
Check notice
Code scanning / CodeQL
Unused local variable Note
c69f0d1 to
18adbef
Compare
18adbef to
0b7a04c
Compare
Factor out code that checks whether an issue given as an URL has comments by a user in a given date range.
Review comments on GitHub PR diffs are different from ordinary comments in the discussion. The latter can be fetched for PRs just as for issues, as every PR is also an issue. But review comments on diffs need to be fetched in a different way - by requesting them from the PR endpoint like https://api.github.com/repos/OWNER/REPO/pulls/PULL_NUMBER/comments not from the issue endpoint like https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER/comments . The current code has been doing only the latter and not the former, missing review comments on diffs in the GitHub activity report. Fix that.
0b7a04c to
9cf41ed
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Review comments on GitHub PR diffs are different from ordinary comments in the discussion. The latter can be fetched for PRs just as for issues, as every PR is also an issue. But review comments on diffs need to be fetched in a different way - by requesting them from the PR endpoint like
https://api.github.com/repos/OWNER/REPO/pulls/PULL_NUMBER/comments, not from the issue endpoint likehttps://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER/comments. See the API documentation: https://docs.github.com/en/rest/pulls/comments?apiVersion=2026-03-10The current code has been doing only the latter and not the former, missing review comments on diffs in the GitHub activity report. Fix that.
As an example, consider this repo : https://github.com/pcahyna/filter_test. PRs pcahyna/filter_test#1 and pcahyna/filter_test#2 have review comments (the former from jridky and pcahyna, the latter from pcahyna). But the reports produced by the commands
and
contain only nothing and
respectively (the latter PR because it was commented by jridky in the discussion).
This PR fixes that, the outputs are now
and
respectively.
Note that the review comment appear among "Pull requests commented on github", not "Pull requests reviewed on github" and it is possible that some of them will also appear duplicate in the "Pull requests reviewed on github" section. I decided to include them in the "commented" section, because the filter that produces the "reviewed" section is quite restrictive, as it is of the type:
https://api.github.com/search/issues?q=reviewed-by:pcahyna+-author:pcahyna+closed:2026-03-27..2026-03-30+type:pr+repo:pcahyna/filter_test&per_page=100Note that it includes only PRs that were not just reviewed but actually closed (this was noted in issue #370) and excludes reviews by the PR authors (which perhaps makes sense for reviews like approvals, but IMO not for review comments on code diffs, as the latter are discussions and should count as activity). I did not want to touch these design choices.
Note also that according to #325 (comment) it is unnecessary to use the PR comments endpoint, as PullRequestsReviewed has a very solid query. I disagree, because of the reasons above - the query is too restrictive.