Skip to content

Commit 6c6ea3d

Browse files
committed
WIP: Verifying that the teams are migrated correctly
1 parent 118c24b commit 6c6ea3d

File tree

8 files changed

+237
-98
lines changed

8 files changed

+237
-98
lines changed

Gemfile.lock

Lines changed: 21 additions & 11 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
@@ -38,6 +34,20 @@ GIT
3834
mime-types (>= 1.25, < 3.0)
3935
rest-client (~> 1.4)
4036

37+
GIT
38+
remote: git://github.com/emberjs/ember-rails.git
39+
revision: 5e5a398f3c67c3a3b84b7513b93b22bf81055cc9
40+
specs:
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)
50+
4151
GEM
4252
remote: https://rubygems.org/
4353
remote: https://rails-assets.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: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ $provision = 'vagrant/bootstrap.sh'
2626

2727
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
2828

29-
config.vm.box = $box
30-
config.vm.box_url = $box_url
29+
config.vm.box = box
30+
#config.vm.box_url = box_url
3131
config.vm.provision :shell do |s|
32-
s.path = $provision
32+
s.path = provision
3333
end
3434

3535
config.ssh.keep_alive = true
@@ -70,6 +70,12 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
7070
else
7171
puts "Please install the 'vagrant-vbguest' plugin"
7272
end
73+
74+
#if Vagrant.has_plugin?('vagrant-cachier')
75+
#config.cache.scope = :box
76+
#else
77+
#puts "Please install the 'vagrant-cachier' plugin"
78+
#end
7379
end
7480

7581
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)