class HornOfPlenty::Adapters::Github::Collections::Card

Protected Instance Methods

transform(raw_item) click to toggle source

rubocop:disable Metrics/AbcSize

Calls superclass method HornOfPlenty::Collection#transform
# File lib/horn_of_plenty/adapters/github/collections/card.rb, line 14
def transform(raw_item)
  card = super

  if %w{Issue PullRequest}.include? card.content_type
    issues = Repositories::Issue.fetch(
               repository: card.repository,
               query:      { id: card.content_id },
    )

    card.content_type = issues.first.has_pull_request? ? 'PullRequest' : 'Issue'
    card.title        = issues.first.title
    card.description  = issues.first.description
    card.labels       = issues.first.labels
    card.status       = issues.first.status

    if issues.first.has_pull_request?
      pull_requests = Repositories::PullRequest.fetch(
                        repository: card.repository,
                        query:      { id: card.content_id },
      )

      card.status = pull_requests.first.status if pull_requests.first
    end
  end

  card
end