Skip to content

Commit 68c2131

Browse files
committed
More verfications. Needed to mark the source for the follower class
1 parent b9cfba8 commit 68c2131

File tree

3 files changed

+83
-14
lines changed

3 files changed

+83
-14
lines changed

Rakefile

Lines changed: 74 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ namespace :team do
3636
ap ex.backtrace
3737
puts
3838
puts '*'*80
39+
3940
require 'pry'; binding.pry
4041
end
4142

@@ -48,7 +49,10 @@ namespace :team do
4849
# Ignoring:
4950
# - updated_at
5051

51-
# Team
52+
puts '----------------------------------------------------------------------------------------------------'
53+
puts 'TEAM'
54+
puts '----------------------------------------------------------------------------------------------------'
55+
5256
%i(median score total slug mean pending_join_requests).each do |attr|
5357
neq(attr, pg_team, mongo_team, false)
5458
end
@@ -78,15 +82,79 @@ namespace :team do
7882
end
7983
end
8084

81-
# TODO: Locations
8285

83-
# TODO: Links
86+
puts '----------------------------------------------------------------------------------------------------'
87+
puts 'LOCATIONS'
88+
puts '----------------------------------------------------------------------------------------------------'
89+
90+
pg_team_locations = pg_team.locations
91+
mongo_team_locations = mongo_team.team_locations
92+
93+
if mongo_team_locations.count != pg_team_locations.count
94+
puts "locations | pg:#{pg_team.id} | mongo:#{mongo_team.id}| #{mongo_team_locations.count} != #{pg_team_locations.count}"
95+
end
96+
97+
# Ignoring:
98+
# - points_of_interest
99+
pg_team.locations.each do |pg_team_location|
100+
mongo_team_location = mongo_team.team_locations.select { |tl| tl.name == pg_team_location.name }.first
101+
102+
%i(address city country description name state_code).each do |attr|
103+
neq(attr, pg_team_location, mongo_team_location, false)
104+
end
105+
end
106+
107+
108+
puts '----------------------------------------------------------------------------------------------------'
109+
puts 'LINKS'
110+
puts '----------------------------------------------------------------------------------------------------'
111+
112+
pg_team_links = pg_team.links
113+
mongo_team_links = mongo_team.featured_links
114+
115+
if mongo_team_links.count != pg_team_links.count
116+
puts "links | pg:#{pg_team.id} | mongo:#{mongo_team.id}| #{mongo_team_links.count} != #{pg_team_links.count}"
117+
end
118+
119+
pg_team_links.each do |pg_team_link|
120+
mongo_team_link = mongo_team_links.select { |tl| tl.name == pg_team_link.name }.first
121+
122+
%i(url name).each do |attr|
123+
neq(attr, pg_team_link, mongo_team_link, false)
124+
end
125+
end
126+
127+
puts '----------------------------------------------------------------------------------------------------'
128+
puts 'MEMBERS'
129+
puts '----------------------------------------------------------------------------------------------------'
130+
131+
if pg_team.members.count != mongo_team.team_members.count
132+
puts "members | pg:#{pg_team.id} | mongo:#{mongo_team.id}| #{mongo_team.team_members.count} != #{pg_team.members.count}"
133+
end
134+
84135

85-
# TODO: Members
136+
puts '----------------------------------------------------------------------------------------------------'
137+
puts 'JOBS'
138+
puts '----------------------------------------------------------------------------------------------------'
86139

87-
# TODO: Jobs
140+
pg_team.jobs.each do |pg_team_job|
141+
mongo_team_job = Team.where(id: pg_team_job.team_document_id.to_s).first
142+
143+
neq(:name, pg_team_job, mongo_team_job, false)
144+
end
88145

89-
# TODO: Followers
146+
puts '----------------------------------------------------------------------------------------------------'
147+
puts 'FOLLOWERS'
148+
puts '----------------------------------------------------------------------------------------------------'
149+
150+
pg_team.followers.each do |pg_team_follower|
151+
mongo_team_follower = Team.where(id: pg_team_follower.mongo_id.to_s).first
152+
# admins
153+
# 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|
155+
neq(attr, pg_team_follower, mongo_team_follower, false)
156+
end
157+
end
90158

91159
# TODO: Pending Requests
92160

app/jobs/team_migrator_job.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,14 @@ def extract_locations(pgteam, team)
136136
return unless locations.any?
137137
return if pgteam.locations.any?
138138
locations.each do |location|
139-
pgteam.locations.create! name: location.name,
139+
pgteam.locations.create!(
140+
name: location.name,
140141
description: location.description,
141-
address: location.address,
142-
city: location.city,
143-
state_code: location.state_code,
144-
country: location.country
145-
142+
address: location.address,
143+
city: location.city,
144+
state_code: location.state_code,
145+
country: location.country
146+
)
146147
end
147148
end
148149

app/models/pg_team.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ class PgTeam < ActiveRecord::Base
1212
has_many :locations, class_name: 'Teams::Location', foreign_key: 'team_id', dependent: :delete_all
1313
has_many :jobs, class_name: 'Opportunity', foreign_key: 'team_id', dependent: :destroy
1414

15-
has_many :follows , class_name: 'FollowedTeam', foreign_key: 'team_id', dependent: :destroy
16-
has_many :followers, through: :follows
15+
has_many :follows, class_name: 'FollowedTeam', foreign_key: 'team_id', dependent: :destroy
16+
has_many :followers, through: :follows, source: :team
1717

1818
accepts_nested_attributes_for :locations, :links, allow_destroy: true, reject_if: :all_blank
1919

0 commit comments

Comments
 (0)