added faktory
This commit is contained in:
parent
5e3e210f41
commit
449301ff58
7 changed files with 40 additions and 16 deletions
2
Gemfile
2
Gemfile
|
@ -14,8 +14,10 @@ gem 'tweetkit', github: 'julianfssen/tweetkit' # for twitter v2 api support
|
||||||
gem 'nokogiri'
|
gem 'nokogiri'
|
||||||
gem 'graphql'
|
gem 'graphql'
|
||||||
gem 'graphql-client'
|
gem 'graphql-client'
|
||||||
|
gem 'retryable'
|
||||||
gem 'rubocop'
|
gem 'rubocop'
|
||||||
gem 'rubocop-rails'
|
gem 'rubocop-rails'
|
||||||
|
gem 'faktory_worker_ruby'
|
||||||
|
|
||||||
# Use postgres as the database for Active Record
|
# Use postgres as the database for Active Record
|
||||||
gem 'pg'
|
gem 'pg'
|
||||||
|
|
|
@ -111,6 +111,7 @@ GEM
|
||||||
execjs
|
execjs
|
||||||
coffee-script-source (1.12.2)
|
coffee-script-source (1.12.2)
|
||||||
concurrent-ruby (1.1.10)
|
concurrent-ruby (1.1.10)
|
||||||
|
connection_pool (2.2.5)
|
||||||
crass (1.0.6)
|
crass (1.0.6)
|
||||||
digest (3.1.0)
|
digest (3.1.0)
|
||||||
domain_name (0.5.20190701)
|
domain_name (0.5.20190701)
|
||||||
|
@ -118,6 +119,8 @@ GEM
|
||||||
equalizer (0.0.11)
|
equalizer (0.0.11)
|
||||||
erubi (1.10.0)
|
erubi (1.10.0)
|
||||||
execjs (2.8.1)
|
execjs (2.8.1)
|
||||||
|
faktory_worker_ruby (1.1.1)
|
||||||
|
connection_pool (~> 2.2, >= 2.2.2)
|
||||||
faraday (1.9.3)
|
faraday (1.9.3)
|
||||||
faraday-em_http (~> 1.0)
|
faraday-em_http (~> 1.0)
|
||||||
faraday-em_synchrony (~> 1.0)
|
faraday-em_synchrony (~> 1.0)
|
||||||
|
@ -280,6 +283,7 @@ GEM
|
||||||
http-cookie (>= 1.0.2, < 2.0)
|
http-cookie (>= 1.0.2, < 2.0)
|
||||||
mime-types (>= 1.16, < 4.0)
|
mime-types (>= 1.16, < 4.0)
|
||||||
netrc (~> 0.8)
|
netrc (~> 0.8)
|
||||||
|
retryable (3.0.5)
|
||||||
rexml (3.2.5)
|
rexml (3.2.5)
|
||||||
rubocop (1.27.0)
|
rubocop (1.27.0)
|
||||||
parallel (~> 1.10)
|
parallel (~> 1.10)
|
||||||
|
@ -380,6 +384,7 @@ DEPENDENCIES
|
||||||
capybara (>= 2.15)
|
capybara (>= 2.15)
|
||||||
chromedriver-helper
|
chromedriver-helper
|
||||||
coffee-rails (~> 4.2)
|
coffee-rails (~> 4.2)
|
||||||
|
faktory_worker_ruby
|
||||||
git
|
git
|
||||||
graphql
|
graphql
|
||||||
graphql-client
|
graphql-client
|
||||||
|
@ -397,6 +402,7 @@ DEPENDENCIES
|
||||||
rails (~> 7.0.0)
|
rails (~> 7.0.0)
|
||||||
railties
|
railties
|
||||||
rest-client
|
rest-client
|
||||||
|
retryable
|
||||||
rubocop
|
rubocop
|
||||||
rubocop-rails
|
rubocop-rails
|
||||||
sass-rails
|
sass-rails
|
||||||
|
|
|
@ -17,4 +17,12 @@ services:
|
||||||
- "3000:3000"
|
- "3000:3000"
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
|
faktory:
|
||||||
|
image: contribsys/faktory:latest
|
||||||
|
ports:
|
||||||
|
- "7419:7419"
|
||||||
|
- "7420:7420"
|
||||||
|
volumes:
|
||||||
|
- ./tmp/faktory:/var/lib/faktory
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -56,12 +56,14 @@ module GithubApi
|
||||||
GRAPHQL
|
GRAPHQL
|
||||||
|
|
||||||
def self.find(username)
|
def self.find(username)
|
||||||
response = GithubApi::Client.query(OwnerReposQuery, variables: { owner: username })
|
#Retryable.retryable(tries: 3, on: QueryExecutionError, sleep: lambda { |n| 4**n } ) do
|
||||||
if response.errors.any?
|
response = GithubApi::Client.query(OwnerReposQuery, variables: { owner: username })
|
||||||
raise QueryExecutionError.new(response.errors[:data].join(", "))
|
if response.errors.any?
|
||||||
else
|
raise QueryExecutionError.new(response.errors[:data].join(", "))
|
||||||
response.data.repository_owner.repositories.nodes.map(&:to_h)
|
else
|
||||||
end
|
response.data.repository_owner.repositories.nodes.map(&:to_h)
|
||||||
|
end
|
||||||
|
#end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -45,12 +45,14 @@ class SecurityAdvisory
|
||||||
GRAPHQL
|
GRAPHQL
|
||||||
|
|
||||||
def self.find(ghsa_id)
|
def self.find(ghsa_id)
|
||||||
response = GithubApi::Client.query(SecurityAdvisoryQuery, variables: { ghsa_id: ghsa_id })
|
#Retryable.retryable(tries: 3, on: QueryExecutionError, sleep: lambda { |n| 4**n } ) do
|
||||||
if response.errors.any?
|
response = GithubApi::Client.query(SecurityAdvisoryQuery, variables: { ghsa_id: ghsa_id })
|
||||||
raise QueryExecutionError.new(response.errors[:data].join(", "))
|
if response.errors.any?
|
||||||
else
|
raise QueryExecutionError.new(response.errors[:data].join(", "))
|
||||||
response.data.security_advisory
|
else
|
||||||
end
|
response.data.security_advisory
|
||||||
|
end
|
||||||
|
#end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,12 +16,14 @@ class User
|
||||||
GRAPHQL
|
GRAPHQL
|
||||||
|
|
||||||
def self.find(username)
|
def self.find(username)
|
||||||
|
#Retryable.retryable(tries: 3, on: QueryExecutionError, sleep: lambda { |n| 4**n } ) do
|
||||||
response = GithubApi::Client.query(UserProfileQuery, variables: { username: username })
|
response = GithubApi::Client.query(UserProfileQuery, variables: { username: username })
|
||||||
if response.errors.any?
|
if response.errors.any?
|
||||||
raise QueryExecutionError.new(response.errors[:data].join(", "))
|
raise QueryExecutionError.new(response.errors[:data].join(", "))
|
||||||
else
|
else
|
||||||
response.data.user
|
response.data.user
|
||||||
end
|
end
|
||||||
|
#end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,10 +10,12 @@ class GithubUserImporter
|
||||||
|
|
||||||
def username_hashes
|
def username_hashes
|
||||||
usernames.map do |username|
|
usernames.map do |username|
|
||||||
username_response = GithubApi::User.find(username)
|
Retryable.retryable(tries: 3, on: QueryExecutionError, sleep: lambda { |n| 4**n } ) do
|
||||||
username_repos = GithubApi::OwnerRepos.find(username)
|
username_response = GithubApi::User.find(username)
|
||||||
repos_hash = { 'repositories' => username_repos }
|
username_repos = GithubApi::OwnerRepos.find(username)
|
||||||
username_response.to_h.merge(repos_hash)
|
repos_hash = { 'repositories' => username_repos }
|
||||||
|
username_response.to_h.merge(repos_hash)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue