Skip to content

Commit 201739f

Browse files
committed
WIP: Verifying that the teams are migrated correctly
1 parent fdc8c30 commit 201739f

File tree

8 files changed

+227
-109
lines changed

8 files changed

+227
-109
lines changed

Gemfile.lock

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
GIT
2-
remote: git://github.com/emberjs/ember-rails.git
3-
revision: 5e5a398f3c67c3a3b84b7513b93b22bf81055cc9
2+
remote: https://github.com/rebelidealist/stripe-ruby-mock
3+
revision: f4229cbe762bc2a5a302cdd83088c283881e9c5a
4+
branch: live-tests
45
specs:
5-
ember-rails (0.15.0)
6-
active_model_serializers
7-
barber (>= 0.4.1)
8-
ember-data-source (>= 1.0.0.beta.5)
9-
ember-source (>= 1.1.0)
10-
execjs (>= 1.2)
11-
handlebars-source (> 1.0.0)
12-
jquery-rails (>= 1.0.17)
13-
railties (>= 3.1)
6+
stripe-ruby-mock (1.10.1.7)
7+
dante (>= 0.2.0)
8+
jimson-temp
9+
stripe (>= 1.15.0)
1410

1511
GIT
1612
remote: git://github.com/nixme/jazz_hands.git
@@ -39,14 +35,18 @@ GIT
3935
rest-client (~> 1.4)
4036

4137
GIT
42-
remote: https://github.com/rebelidealist/stripe-ruby-mock
43-
revision: f4229cbe762bc2a5a302cdd83088c283881e9c5a
44-
branch: live-tests
38+
remote: git://github.com/emberjs/ember-rails.git
39+
revision: 5e5a398f3c67c3a3b84b7513b93b22bf81055cc9
4540
specs:
46-
stripe-ruby-mock (1.10.1.7)
47-
dante (>= 0.2.0)
48-
jimson-temp
49-
stripe (>= 1.15.0)
41+
ember-rails (0.15.0)
42+
active_model_serializers
43+
barber (>= 0.4.1)
44+
ember-data-source (>= 1.0.0.beta.5)
45+
ember-source (>= 1.1.0)
46+
execjs (>= 1.2)
47+
handlebars-source (> 1.0.0)
48+
jquery-rails (>= 1.0.17)
49+
railties (>= 3.1)
5050

5151
GEM
5252
remote: https://rubygems.org/

Rakefile

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,72 @@ require 'rake'
44
Coderwall::Application.load_tasks
55

66
task default: :spec
7+
8+
9+
namespace :team do
10+
task migrate: :environment do
11+
TeamMigratorBatchJob.new.perform
12+
end
13+
14+
#
15+
# IMPORTANT: pending_join_requests is a STRING array in Postgres but an INTEGER array in MongoDB.
16+
# IMPORTANT: pending_join_requests is an array of User#id values
17+
#
18+
19+
def neq(attr, pg, mongo, fail_if_neq=true)
20+
left = pg.send(attr)
21+
right = mongo.send(attr)
22+
23+
if left != right
24+
puts "#{attr} #{left} != #{right} (#{pg.id}|#{mongo.id})"
25+
26+
if fail_if_neq
27+
require 'pry'; binding.pry
28+
end
29+
end
30+
end
31+
32+
task verify: :environment do
33+
PgTeam.find_each(batch_size: 100) do |pg_team|
34+
begin
35+
mongo_id = pg_team.mongo_id
36+
mongo_team = Team.find(mongo_id)
37+
38+
39+
%i(updated_at median score total slug mean pending_join_requests).each do |attr|
40+
neq(attr, pg_team, mongo_team, false)
41+
end
42+
43+
44+
%i(about achievement_count analytics benefit_description_1 benefit_description_2 benefit_description_3 benefit_name_1 benefit_name_2 benefit_name_3 big_image big_quote blog_feed branding country_id created_at endorsement_count facebook featured_banner_image featured_links_title github github_organization_name headline hide_from_featured highlight_tags hiring_tagline interview_steps invited_emails link_to_careers_page location monthly_subscription name number_of_jobs_to_show office_photos organization_way organization_way_name organization_way_photo our_challenge paid_job_posts premium preview_code reason_description_1 reason_description_2 reason_description_3 reason_name_1 reason_name_2 reason_name_3 size stack_list twitter upcoming_events upgraded_at valid_jobs website why_work_image your_impact youtube_url).each do |attr|
45+
neq(attr, pg_team, mongo_team)
46+
end
47+
rescue => ex
48+
49+
ap ex
50+
51+
require 'pry'; binding.pry
52+
end
53+
end
54+
end
55+
56+
task counts: :environment do
57+
pg_team_count = PgTeam.count
58+
puts "PgTeam.count=#{pg_team_count}"
59+
team_count = Team.count
60+
puts "Team.count=#{team_count}"
61+
puts "Unmigrated teams count=#{(team_count - pg_team_count)}"
62+
end
63+
64+
65+
task unmigrated: :environment do
66+
unmigrated_teams = []
67+
68+
Team.all.each do |team|
69+
unmigrated_teams << team.id.to_s unless PgTeam.where(mongo_id: team.id.to_s).exists?
70+
end
71+
72+
puts "Unmigrated teams count=#{unmigrated_teams.count}"
73+
puts "Unmigrated Teams=%w(#{unmigrated_teams.join(' ')})"
74+
end
75+
end

Vagrantfile

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ puts custom_settings.inspect
1010

1111
VAGRANTFILE_API_VERSION = "2"
1212

13-
$box = 'coderwall'
14-
$box_url = 'https://s3.amazonaws.com/coderwall-assets-0/vagrant/coderwall.box' # The box is 1GB. Prepare your
15-
$provision = 'vagrant/bootstrap.sh'
13+
box = 'coderwall'
14+
#box_url = 'https://s3.amazonaws.com/coderwall-assets-0/vagrant/coderwall.box' # The box is 1GB. Prepare your
15+
provision = 'vagrant/bootstrap.sh'
1616

1717
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
1818

19-
config.vm.box = $box
20-
config.vm.box_url = $box_url
19+
config.vm.box = box
20+
#config.vm.box_url = box_url
2121
config.vm.provision :shell do |s|
22-
s.path = $provision
22+
s.path = provision
2323
end
2424

2525
config.ssh.keep_alive = true
@@ -62,6 +62,12 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
6262
else
6363
puts "Please install the 'vagrant-vbguest' plugin"
6464
end
65+
66+
#if Vagrant.has_plugin?('vagrant-cachier')
67+
#config.cache.scope = :box
68+
#else
69+
#puts "Please install the 'vagrant-cachier' plugin"
70+
#end
6571
end
6672

6773
def set_port_mapping_for(config, service, guest_port, settings, force = false)

app/jobs/team_migrator_batch_job.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ class TeamMigratorBatchJob
33
include Sidekiq::Worker
44

55
def perform
6-
Team.each do |team|
7-
TeamMigratorJob.perform_async(team.id.to_s)
6+
Team.each do |team|
7+
begin
8+
TeamMigratorJob.perform_async(team.id.to_s)
9+
rescue => ex
10+
Rails.logger.error("[#{team.id.to_s}] #{ex} >>\n#{ex.backtrace.join("\n ")}")
11+
end
812
end
913
end
1014
end

0 commit comments

Comments
 (0)