diff --git a/Gemfile.lock b/Gemfile.lock index 86823ac28..101ed56f9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -145,7 +145,7 @@ GEM erubis (2.7.0) eventmachine (1.2.7) excon (0.102.0) - execjs (2.8.1) + execjs (2.9.0) faraday (2.0.1) faraday-net_http (~> 2.0) ruby2_keywords (>= 0.0.4) @@ -238,6 +238,8 @@ GEM netrc (0.11.0) newrelic_rpm (9.4.2) nio4r (2.5.9) + nokogiri (1.15.4-x86_64-darwin) + racc (~> 1.4) nokogiri (1.15.4-x86_64-linux) racc (~> 1.4) oj (3.16.1) @@ -328,7 +330,7 @@ GEM rspec-mocks (~> 3.12) rspec-support (~> 3.12) rspec-support (3.12.1) - rubocop (1.56.2) + rubocop (1.56.3) base64 (~> 0.1.1) json (~> 2.3) language_server-protocol (>= 3.17.0) @@ -426,6 +428,7 @@ GEM zeitwerk (2.6.11) PLATFORMS + x86_64-darwin-21 x86_64-linux DEPENDENCIES diff --git a/app/services/issue_creator_service.rb b/app/services/issue_creator_service.rb index ee1b0b593..6af9a2eae 100644 --- a/app/services/issue_creator_service.rb +++ b/app/services/issue_creator_service.rb @@ -3,7 +3,16 @@ class IssueCreatorService < ApplicationService class QueryError < StandardError; end - FindRepoQuery = GitHub::Client.parse <<-'GRAPHQL' + + def initialize(params) + @title = params[:content][:title] + @body = params[:content][:body] + @repo = Rails.configuration.change_request.dig(:ontologies, params[:ont_acronym].to_sym, :repository) + end + + def call + + findRepoQuery = GitHub::Client.parse <<-'GRAPHQL' query ($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { id @@ -11,7 +20,7 @@ class QueryError < StandardError; end } GRAPHQL - CreateIssueMutation = GitHub::Client.parse <<-'GRAPHQL' + createIssueMutation = GitHub::Client.parse <<-'GRAPHQL' mutation ($repositoryId: ID!, $title: String!, $body: String) { createIssue(input: {repositoryId: $repositoryId, title: $title, body: $body}) { issue { @@ -28,16 +37,8 @@ class QueryError < StandardError; end } } GRAPHQL - - def initialize(params) - @title = params[:content][:title] - @body = params[:content][:body] - @repo = Rails.configuration.change_request.dig(:ontologies, params[:ont_acronym].to_sym, :repository) - end - - def call - data = query(FindRepoQuery, variables: { owner: repo_owner, name: repo_name }) - data = query(CreateIssueMutation, variables: { repositoryId: data.repository.id, title: @title, body: @body }) + data = query(findRepoQuery, variables: { owner: repo_owner, name: repo_name }) + data = query(createIssueMutation, variables: { repositoryId: data.repository.id, title: @title, body: @body }) data.to_h.dig('createIssue', 'issue') end