dev-cmd/contributions: Avoid the /users/#{user}/events API call

- This is wasteful when we can just catch the `ValidationFailedError`
  from the GitHub API from the search query.
This commit is contained in:
Issy Long 2023-03-15 12:59:21 +00:00
parent 0a804e1b38
commit b6198cdd07
No known key found for this signature in database
GPG Key ID: 8247C390DADC67D4

View File

@ -207,9 +207,8 @@ module Homebrew
sig { params(repo_full_name: String, person: String, args: Homebrew::CLI::Args).returns(Integer) }
def count_reviews(repo_full_name, person, args)
# Users who have made their contributions private are not searchable to determine counts.
return 0 if GitHub::API.open_rest("https://api.github.com/users/#{person}/events").empty?
GitHub.count_issues("", is: "pr", repo: repo_full_name, reviewed_by: person, review: "approved", args: args)
rescue GitHub::API::ValidationFailedError
0 # Users who have made their contributions private are not searchable to determine counts.
end
end