class Michael::Services::Github::PullRequests
Public Instance Methods
search(org_repo, state: 'open')
click to toggle source
# File lib/michael/services/github/pull_requests.rb, line 12 def search(org_repo, state: 'open') octokit .pull_requests(org_repo, state: state) .map { |pr| process(org_repo, pr) } rescue Octokit::InvalidRepository, Octokit::NotFound nil end
Private Instance Methods
process(org_repo, pull_request)
click to toggle source
# File lib/michael/services/github/pull_requests.rb, line 22 def process(org_repo, pull_request) pr = Michael::Models::PullRequest.new(pull_request) pr.statuses = statuses(org_repo, pr.head_sha) pr.reviews = reviews(org_repo, pr.number) pr end
reviews(org_repo, pr_number)
click to toggle source
# File lib/michael/services/github/pull_requests.rb, line 36 def reviews(org_repo, pr_number) octokit .pull_request_reviews(org_repo, pr_number) .map { |review| Michael::Models::Review.new(review) } .group_by(&:author).to_a .map { |_author, reviews| reviews.sort_by(&:submitted_at).pop } end
statuses(org_repo, sha)
click to toggle source
# File lib/michael/services/github/pull_requests.rb, line 31 def statuses(org_repo, sha) statuses = octokit.combined_status(org_repo, sha)[:statuses] statuses.map { |s| Michael::Models::Status.new(s) } end