Sha256: ff99cc29a1672802e0a27fe0a59a84a91d0bee63f979b3e6d90b37aa42122188
Contents?: true
Size: 1.5 KB
Versions: 7
Compression:
Stored size: 1.5 KB
Contents
# frozen_string_literal: true require_relative "base" module Decidim module GithubManager module Querier # Makes a GET request for the related issues of an Issue or Pull Request in GitHub # Uses the Timeline events API endpoint # # @see https://docs.github.com/en/rest/issues/timeline?apiVersion=2022-11-28 GitHub API documentation class RelatedIssues < Decidim::GithubManager::Querier::Base def initialize(issue_id:, token:) @issue_id = issue_id @token = token end # Makes the GET request and parses the response of an Issue or Pull Request in GitHub # # @return [Hash] def call parse(json_response("https://api.github.com/repos/decidim/decidim/issues/#{@issue_id}/timeline")) end private def headers { per_page: 100 } end # Parses the response of an Issue or Pull Request in GitHub # # @return [Hash] def parse(metadata) references = metadata.select do |item| item["event"] == "cross-referenced" && item["source"]["issue"]["repository"]["full_name"] == "decidim/decidim" end references.map do |item| issue = item["source"]["issue"] { id: issue["number"], title: issue["title"].strip, state: issue.dig("pull_request", "merged_at").nil? ? issue["state"] : "merged" } end end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems