Skip to content

Commit 0a84019

Browse files
committed
hash json to generate the config key
1 parent e08e0eb commit 0a84019

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

bin/populate_configs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
STDOUT.sync = true
44

5+
require 'active_record'
56
require 'digest/sha1'
7+
require 'json'
68
require 'erb'
79
require 'optparse'
810
require 'yaml'
9-
require 'active_record'
1011

1112
config = YAML.load(ERB.new(File.read('config/database.yml')).result)
1213
ActiveRecord::Base.establish_connection(config[ENV['RAILS_ENV'] || 'test'])
@@ -45,7 +46,7 @@ configs = {}
4546

4647
scope.find_each do |obj|
4748
next unless obj.config
48-
key = Digest::MD5.hexdigest(obj.config.inspect)
49+
key = Digest::MD5.hexdigest(JSON.dump(obj.config))
4950

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

5758
sleep pause if pause
5859
end
60+

0 commit comments

Comments
 (0)