Skip to content

Commit

Permalink
Paginate check run refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
sjagoe committed Jan 29, 2024
1 parent 03a10e9 commit 900ef9e
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions app/models/shipit/commit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,26 @@ def create_status_from_github!(github_status)
end
end

def refresh_check_runs!
def paginated_check_runs
response = stack.handle_github_redirections do
stack.github_api.check_runs(github_repo_name, sha)
stack.github_api.check_runs(github_repo_name, sha, per_page: 100)
end

return response if stack.github_api.last_response.rels[:next].nil?

loop do
page = stack.handle_github_redirections do
stack.github_api.get(stack.github_api.last_response.rels[:next].href)
end
response.check_runs.concat(page.check_runs)
break if stack.github_api.last_response.rels[:next].nil?
end

response
end

def refresh_check_runs!
response = paginated_check_runs
response.check_runs.each do |check_run|
create_or_update_check_run_from_github!(check_run)
end
Expand Down

0 comments on commit 900ef9e

Please sign in to comment.