Skip to content

Commit

Permalink
Standardrb
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffmcfadden committed May 17, 2024
1 parent 96f3ee5 commit e709445
Show file tree
Hide file tree
Showing 13 changed files with 310 additions and 318 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

source "https://rubygems.org"

gemspec
gemspec
2 changes: 1 addition & 1 deletion ghx.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ Gem::Specification.new do |s|
s.add_development_dependency "standardrb"
s.add_development_dependency "debug"
s.add_development_dependency "minitest"
end
end
24 changes: 11 additions & 13 deletions lib/ghx.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
require 'time'
require 'net/http'
require 'json'
require 'octokit'
require "time"
require "net/http"
require "json"
require "octokit"

require_relative "version"
require_relative 'ghx/graphql_client'
require_relative 'ghx/rest_client'
require_relative 'ghx/dependabot'
require_relative 'ghx/issue'
require_relative 'ghx/project'
require_relative 'ghx/project_item'
require_relative "ghx/graphql_client"
require_relative "ghx/rest_client"
require_relative "ghx/dependabot"
require_relative "ghx/issue"
require_relative "ghx/project"
require_relative "ghx/project_item"

# GitHub eXtended API Interface
#
Expand Down Expand Up @@ -47,6 +47,4 @@ def self.rest_client
def self.rest_client=(rest_client)
@rest_client = rest_client
end


end
end
6 changes: 3 additions & 3 deletions lib/ghx/dependabot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ def self.get_alerts(owner:, repo:)
end
end

require_relative 'dependabot/alert'
require_relative 'dependabot/package'
require_relative 'dependabot/security_vulnerability'
require_relative "dependabot/alert"
require_relative "dependabot/package"
require_relative "dependabot/security_vulnerability"
14 changes: 11 additions & 3 deletions lib/ghx/dependabot/alert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,17 @@ def initialize(json_data)
@security_vulnerability = SecurityVulnerability.new(json_data["security_vulnerability"])
@url = json_data["url"]
@html_url = json_data["html_url"]
@created_at = Time.parse(json_data["created_at"]) rescue nil
@updated_at = Time.parse(json_data["updated_at"]) rescue nil
@created_at = begin
Time.parse(json_data["created_at"])
rescue
nil
end
@updated_at = begin
Time.parse(json_data["updated_at"])
rescue
nil
end
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/ghx/dependabot/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ def initialize(json_data)
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/ghx/dependabot/security_vulnerability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ def initialize(json_data)
end
end
end
end
end
69 changes: 33 additions & 36 deletions lib/ghx/graphql_client.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module GHX
class GraphqlClient

def initialize(api_key)
@api_key = api_key
end
Expand All @@ -20,52 +19,50 @@ def query(query)
# @param [String] project_id
# @param [GithubProjectItem] project_item
# @param [DateTime] reported_at
def update_project_item_reported_at(project_id: GithubProject::MAIN_GH_PROJECT_ID, project_item_id:, reported_at:)
def update_project_item_reported_at(project_item_id:, reported_at:, project_id: GithubProject::MAIN_GH_PROJECT_ID)
field_id = "PVTF_lADOALH_aM4Ac-_zzgSzAZs" # project_item.field_map["Reported At"]

gql_query = <<~GQL
mutation {
updateProjectV2ItemFieldValue(input: {
fieldId: "#{field_id}",
itemId: "#{project_item_id}",
projectId: "#{project_id}",
value: {
date: "#{reported_at.to_date.to_s}"
}
}) {
projectV2Item {
id
mutation {
updateProjectV2ItemFieldValue(input: {
fieldId: "#{field_id}",
itemId: "#{project_item_id}",
projectId: "#{project_id}",
value: {
date: "#{reported_at.to_date}"
}
}) {
projectV2Item {
id
}
}
}
}
}
GQL
GQL

res = query(gql_query)
query(gql_query)
end

def update_project_item_reported_by(project_id: GithubProject::MAIN_GH_PROJECT_ID, project_item_id:, reported_by:)
def update_project_item_reported_by(project_item_id:, reported_by:, project_id: GithubProject::MAIN_GH_PROJECT_ID)
field_id = "PVTF_lADOALH_aM4Ac-_zzgSzBcc" # project_item.field_map["Reporter"]

gql_query = <<~GQL
mutation {
updateProjectV2ItemFieldValue(input: {
fieldId: "#{field_id}",
itemId: "#{project_item_id}",
projectId: "#{project_id}",
value: {
text: "#{reported_by}"
}
}) {
projectV2Item {
id
mutation {
updateProjectV2ItemFieldValue(input: {
fieldId: "#{field_id}",
itemId: "#{project_item_id}",
projectId: "#{project_id}",
value: {
text: "#{reported_by}"
}
}) {
projectV2Item {
id
}
}
}
}
}
GQL
GQL

res = query(gql_query)
query(gql_query)
end

end

end
end
3 changes: 1 addition & 2 deletions lib/ghx/issue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,5 @@ def update_attributes(hash)
self.milestone = hash["milestone"]
self.assignees = hash["assignees"]
end

end
end
end
Loading

0 comments on commit e709445

Please sign in to comment.