Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ GEM
arel (6.0.4)
builder (3.2.3)
concurrent-ruby (1.0.5)
crass (1.0.3)
crass (1.0.4)
data_migrations (0.0.1)
activerecord
rake
Expand All @@ -39,7 +39,7 @@ GEM
i18n (0.9.3)
concurrent-ruby (~> 1.0)
json (1.8.6)
loofah (2.1.1)
loofah (2.2.2)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
micro_migrations (0.0.2)
Expand Down
10 changes: 5 additions & 5 deletions bin/populate_configs
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@

STDOUT.sync = true

require 'active_record'
require 'digest/sha1'
require 'json'
require 'erb'
require 'optparse'
require 'yaml'
require 'active_record'

config = YAML.load(ERB.new(File.read('config/database.yml')).result)
ActiveRecord::Base.establish_connection(config[ENV['RAILS_ENV'] || 'test'])

start = 0
batch = 100_000
total = 1_000_000
count = 1_000_000
pause = nil

ARGV.options do |o|
o.on("-s", "--start=START", Integer) { |v| start = v }
o.on('-b', "--batch=BATCH", Integer) { |v| batch = v }
o.on('-c', "--count=COUNT", Integer) { |v| count = v }
o.on("-p", "--pause=PAUSE", Integer) { |v| pause = v.to_f / 1000 }
o.parse!
Expand All @@ -45,7 +44,7 @@ configs = {}

scope.find_each do |obj|
next unless obj.config
key = Digest::MD5.hexdigest(obj.config.inspect)
key = Digest::MD5.hexdigest(JSON.dump(obj.config))

config = configs[key]
config ||= Config.where(repository_id: obj.repository_id, key: key).select(:id).first
Expand All @@ -56,3 +55,4 @@ scope.find_each do |obj|

sleep pause if pause
end