@@ -8,7 +8,21 @@ task default: :spec
8
8
9
9
namespace :team do
10
10
task migrate : :environment do
11
- TeamMigratorBatchJob . new . perform
11
+ puts '--- Beginning team migration ---'
12
+ success = true
13
+ begin
14
+ Team . each do |team |
15
+ begin
16
+ puts ">>> Migrating #{ team . id } "
17
+ TeamMigratorJob . new . perform ( team . id . to_s )
18
+ rescue => ex
19
+ success = false
20
+ puts "[#{ team . id . to_s } ] #{ ex } >>\n #{ ex . backtrace . join ( "\n " ) } "
21
+ end
22
+ end
23
+ ensure
24
+ puts "--- #{ success ? 'Successful' : 'Unsuccessful' } team migration ---"
25
+ end
12
26
end
13
27
14
28
#
@@ -40,6 +54,32 @@ namespace :team do
40
54
require 'pry' ; binding . pry
41
55
end
42
56
57
+ def neq_dec ( attr , pg , mongo , fail_if_neq = true )
58
+ scale = 7
59
+ left = pg . send ( attr ) . to_d . round ( scale )
60
+ right = mongo . send ( attr ) . to_d . round ( scale )
61
+
62
+
63
+ if left != right
64
+ puts "#{ attr } | pg:#{ pg . id } | mongo:#{ mongo . id } | #{ left } != #{ right } "
65
+ true
66
+ else
67
+ false
68
+ end
69
+ rescue => ex
70
+ puts '*' *80
71
+ puts
72
+ puts ex
73
+ puts
74
+ puts '-' *80
75
+ puts
76
+ ap ex . backtrace
77
+ puts
78
+ puts '*' *80
79
+
80
+ require 'pry' ; binding . pry
81
+ end
82
+
43
83
task verify : :environment do
44
84
PgTeam . find_each ( batch_size : 100 ) do |pg_team |
45
85
begin
@@ -49,14 +89,18 @@ namespace :team do
49
89
# Ignoring:
50
90
# - updated_at
51
91
52
- puts '----------------------------------------------------------------------------------------------------'
53
- puts 'TEAM'
54
- puts '----------------------------------------------------------------------------------------------------'
92
+ # puts '----------------------------------------------------------------------------------------------------'
93
+ # puts 'TEAM'
94
+ # puts '----------------------------------------------------------------------------------------------------'
55
95
56
- %i( median score total slug mean pending_join_requests ) . each do |attr |
96
+ %i( slug pending_join_requests ) . each do |attr |
57
97
neq ( attr , pg_team , mongo_team , false )
58
98
end
59
99
100
+ %i( score size total mean median ) . each do |attr |
101
+ neq_dec ( attr , pg_team , mongo_team , false )
102
+ end
103
+
60
104
%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 |
61
105
neq ( attr , pg_team , mongo_team )
62
106
end
@@ -83,9 +127,9 @@ namespace :team do
83
127
end
84
128
85
129
86
- puts '----------------------------------------------------------------------------------------------------'
87
- puts 'LOCATIONS'
88
- puts '----------------------------------------------------------------------------------------------------'
130
+ # puts '----------------------------------------------------------------------------------------------------'
131
+ # puts 'LOCATIONS'
132
+ # puts '----------------------------------------------------------------------------------------------------'
89
133
90
134
pg_team_locations = pg_team . locations
91
135
mongo_team_locations = mongo_team . team_locations
@@ -105,9 +149,9 @@ namespace :team do
105
149
end
106
150
107
151
108
- puts '----------------------------------------------------------------------------------------------------'
109
- puts 'LINKS'
110
- puts '----------------------------------------------------------------------------------------------------'
152
+ # puts '----------------------------------------------------------------------------------------------------'
153
+ # puts 'LINKS'
154
+ # puts '----------------------------------------------------------------------------------------------------'
111
155
112
156
pg_team_links = pg_team . links
113
157
mongo_team_links = mongo_team . featured_links
@@ -124,38 +168,101 @@ namespace :team do
124
168
end
125
169
end
126
170
127
- puts '----------------------------------------------------------------------------------------------------'
128
- puts 'MEMBERS'
129
- puts '----------------------------------------------------------------------------------------------------'
171
+ # puts '----------------------------------------------------------------------------------------------------'
172
+ # puts 'MEMBERS'
173
+ # puts '----------------------------------------------------------------------------------------------------'
130
174
131
175
if pg_team . members . count != mongo_team . team_members . count
132
176
puts "members | pg:#{ pg_team . id } | mongo:#{ mongo_team . id } | #{ mongo_team . team_members . count } != #{ pg_team . members . count } "
133
177
end
134
178
135
179
136
- puts '----------------------------------------------------------------------------------------------------'
137
- puts 'JOBS'
138
- puts '----------------------------------------------------------------------------------------------------'
180
+ # puts '----------------------------------------------------------------------------------------------------'
181
+ # puts 'JOBS'
182
+ # puts '----------------------------------------------------------------------------------------------------'
139
183
140
184
pg_team . jobs . each do |pg_team_job |
141
185
mongo_team_job = Team . where ( id : pg_team_job . team_document_id . to_s ) . first
142
186
143
187
neq ( :name , pg_team_job , mongo_team_job , false )
144
188
end
145
189
146
- puts '----------------------------------------------------------------------------------------------------'
147
- puts 'FOLLOWERS'
148
- puts '----------------------------------------------------------------------------------------------------'
190
+ # puts '----------------------------------------------------------------------------------------------------'
191
+ # puts 'FOLLOWERS'
192
+ # puts '----------------------------------------------------------------------------------------------------'
149
193
150
194
pg_team . followers . each do |pg_team_follower |
151
195
mongo_team_follower = Team . where ( id : pg_team_follower . mongo_id . to_s ) . first
152
196
# admins
153
197
# editors
154
- %i( about achievement_count analytics avatar 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_organization_name headline hide_from_featured highlight_tags hiring_tagline interview_steps invited_emails link_to_careers_page location mean median monthly_subscription name number_of_jobs_to_show office_photos organization_way organization_way_name organization_way_photo our_challenge paid_job_posts pending_join_requests premium preview_code reason_description_1 reason_description_2 reason_description_3 reason_name_1 reason_name_2 reason_name_3 score size slug stack_list total twitter upcoming_events updated_at upgraded_at valid_jobs website why_work_image your_impact youtube_url ) . each do |attr |
198
+ %i(
199
+ about
200
+ achievement_count
201
+ analytics
202
+ avatar
203
+ benefit_description_1
204
+ benefit_description_2
205
+ benefit_description_3
206
+ benefit_name_1
207
+ benefit_name_2
208
+ benefit_name_3
209
+ big_image
210
+ big_quote
211
+ blog_feed
212
+ branding
213
+ country_id
214
+ created_at
215
+ endorsement_count
216
+ facebook
217
+ featured_banner_image
218
+ featured_links_title
219
+ github_organization_name
220
+ headline
221
+ hide_from_featured
222
+ highlight_tags
223
+ hiring_tagline
224
+ interview_steps
225
+ invited_emails
226
+ link_to_careers_page
227
+ location
228
+ monthly_subscription
229
+ name
230
+ number_of_jobs_to_show
231
+ office_photos
232
+ organization_way
233
+ organization_way_name
234
+ organization_way_photo
235
+ our_challenge
236
+ paid_job_posts
237
+ pending_join_requests
238
+ premium
239
+ preview_code
240
+ reason_description_1
241
+ reason_description_2
242
+ reason_description_3
243
+ reason_name_1
244
+ reason_name_2
245
+ reason_name_3
246
+ slug
247
+ stack_list
248
+ twitter
249
+ upcoming_events
250
+ upgraded_at
251
+ valid_jobs
252
+ website
253
+ why_work_image
254
+ your_impact
255
+ youtube_url
256
+ ) . each do |attr |
155
257
neq ( attr , pg_team_follower , mongo_team_follower , false )
156
258
end
259
+
260
+ %i( score size total mean median ) . each do |attr |
261
+ neq_dec ( attr , pg_team_follower , mongo_team_follower , false )
262
+ end
157
263
end
158
264
265
+
159
266
# TODO: Pending Requests
160
267
end
161
268
end
0 commit comments