Skip to content

Commit

Permalink
Return empty array if skipping downloading reviews (#1928)
Browse files Browse the repository at this point in the history
* More nil checks before downloading reviews

* Return empty array if skipping downloading reviews

* Similar fix for review comments
  • Loading branch information
andrew committed Jul 11, 2019
1 parent ef22e3b commit 0da7f73
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/models/subject.rb
Expand Up @@ -205,7 +205,7 @@ def download_comments

#example https://api.github.com/repos/octobox/octobox/pulls/1141/reviews
def download_reviews
return unless github_client && pull_request?
return [] unless github_client && pull_request?
reviews = github_client.get(url + '/reviews', since: comments.order('created_at ASC').last.try(:created_at))
reviews.map { |review|
if review[:state] == "COMMENTED"
Expand All @@ -220,15 +220,15 @@ def download_reviews

#example https://api.github.com/repos/octobox/octobox/pulls/1141/reviews/172586974/comments
def download_comments_for_review(review)
return unless github_client
return [] unless github_client
reviews = github_client.get(review['pull_request_url'] + '/reviews/' + review['id'].to_s + '/comments', since: comments.order('created_at ASC').last.try(:created_at))
rescue Octokit::ClientError => e
[]
end

#example https://api.github.com/repos/octobox/octobox/pulls/1141/comments
def download_review_comments
return unless github_client && pull_request?
return [] unless github_client && pull_request?
github_client.get(url + '/comments', since: comments.order('created_at ASC').last.try(:created_at))
rescue Octokit::ClientError => e
[]
Expand Down

0 comments on commit 0da7f73

Please sign in to comment.