Skip to content

Commit ae1ee05

Browse files
committed
Job boards are working again.
1 parent f43eaec commit ae1ee05

26 files changed

+207
-1351
lines changed

app/controllers/opportunities_controller.rb

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,15 @@ def apply
2121
end
2222

2323
def new
24-
team_id = params.permit(:team_id)[:team_id]
25-
@job = Opportunity.new(team_document_id: team_id)
24+
team_id = params[:team_id]
25+
@job = Opportunity.new(team_id: team_id)
2626
end
2727

2828
def edit
29-
3029
end
3130

3231
def create
33-
opportunity_create_params = params.require(:opportunity).permit(:name, :team_document_id, :opportunity_type, :description, :tags, :location, :link, :salary, :apply)
32+
opportunity_create_params = params.require(:opportunity).permit(:name, :team_id, :opportunity_type, :description, :tags, :location, :link, :salary, :apply)
3433
@job = Opportunity.new(opportunity_create_params)
3534
respond_to do |format|
3635
if @job.save
@@ -43,7 +42,7 @@ def create
4342
end
4443

4544
def update
46-
opportunity_update_params = params.require(:opportunity).permit(:id, :name, :team_document_id, :opportunity_type, :description, :tags, :location, :link, :salary, :apply)
45+
opportunity_update_params = params.require(:opportunity).permit(:id, :name, :team_id, :opportunity_type, :description, :tags, :location, :link, :salary, :apply)
4746
respond_to do |format|
4847
if @job.update_attributes(opportunity_update_params)
4948
format.html { redirect_to teamname_path(@team.slug), notice: "#{@job.name} updated" }
@@ -73,22 +72,30 @@ def visit
7372

7473
def index
7574
current_user.seen(:jobs) if signed_in?
76-
store_location! if !signed_in?
75+
store_location! unless signed_in?
7776
chosen_location = (params[:location] || closest_to_user(current_user)).try(:titleize)
78-
chosen_location = nil if chosen_location == "Worldwide"
79-
@page = params[:page].try(:to_i) || 1
80-
tag = params[:skill].gsub(/\-/, ' ').downcase unless params[:skill].nil?
81-
@jobs = get_jobs_for(chosen_location, tag, @page)
82-
@jobs_left = @jobs.count
83-
@jobs = @jobs.limit(20)
84-
chosen_location = "Worldwide" if chosen_location.nil?
85-
@locations = Rails.cache.fetch("job_locations_#{params[:location]}_#{params[:skill]}", expires_in: 1.hour) { Opportunity.by_tag(tag).map(&:locations).flatten.reject { |loc| loc == "Worldwide" }.push("Worldwide").uniq.compact }
77+
chosen_location = nil if chosen_location == 'Worldwide'
78+
79+
@page = params[:page].try(:to_i) || 1
80+
tag = params[:skill].gsub(/\-/, ' ').downcase unless params[:skill].nil?
81+
82+
83+
@jobs = get_jobs_for(chosen_location, tag, @page)
84+
@jobs_left = @jobs.count
85+
@jobs = @jobs.limit(20)
86+
87+
88+
89+
chosen_location = 'Worldwide' if chosen_location.nil?
90+
@locations = Rails.cache.fetch("job_locations_#{params[:location]}_#{params[:skill]}", expires_in: 1.hour) do
91+
Opportunity.by_tag(tag).map(&:locations).flatten.reject { |loc| loc == "Worldwide" }.push("Worldwide").uniq.compact
92+
end
8693
@locations.delete(chosen_location) unless @locations.frozen?
8794
params[:location] = chosen_location
88-
@lat, @lng = geocode_location(chosen_location)
95+
@lat, @lng = geocode_location(chosen_location)
8996

9097
respond_to do |format|
91-
format.html { render layout: "jobs" }
98+
format.html { render layout: 'jobs' }
9299
format.json { render json: @jobs.map(&:to_public_hash).to_json }
93100
format.js
94101
end
@@ -97,10 +104,11 @@ def index
97104

98105
def map
99106
@job_locations = all_job_locations
100-
@job_skills = all_job_skills
107+
@job_skills = all_job_skills
101108
end
102109

103110
private
111+
104112
def validate_permissions
105113
redirect_to :back unless team_admin?
106114
end
@@ -160,6 +168,8 @@ def get_jobs_for(chosen_location, tag, page)
160168
scope = Opportunity
161169
scope = scope.by_city(chosen_location) unless chosen_location.nil?
162170
scope = scope.by_tag(tag) unless tag.nil?
171+
# TODO: Verify that there are no unmigrated teams
172+
scope = scope.where('team_id is not null')
163173
scope.offset((page-1) * 20)
164174
end
165175
end

app/controllers/teams_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def page_based_on_rank(rank)
289289
end
290290

291291
def job_public_ids
292-
Rails.cache.fetch('all-jobs-public-ids', :expires_in => 1.hour) { Opportunity.select(:public_id).group('team_document_id, created_at, public_id').map(&:public_id) }
292+
Rails.cache.fetch('all-jobs-public-ids', :expires_in => 1.hour) { Opportunity.select(:public_id).group('team_id, created_at, public_id').map(&:public_id) }
293293
end
294294

295295
def next_job(job)

app/helpers/premium_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def default_job
185185
cached_tags: 'Skilled, Awesome',
186186
tags: 'Java, TDD, Heroku',
187187
location_city: 'San Francisco, CA',
188-
team_document_id: @team.id || Team.featured.first.id
188+
team_id: @team.id || Team.featured.first.id
189189
)
190190
end
191191

@@ -220,7 +220,7 @@ def reason_description_1_or_default(team)
220220
end
221221

222222
def job_visited(job)
223-
visit_team_opportunity_path(job.team_document_id, job.id) unless job.new_record?
223+
visit_team_opportunity_path(job.team_id, job.id) unless job.new_record?
224224
end
225225

226226
def link_to_add_fields(name, f, association)

app/mailers/protip_mailer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def self.get_team_and_job_for(user)
9292
else
9393
teams = teams_for_user(user)
9494
teams.each do |team|
95-
best_job = team.best_positions_for(user).detect{|job| (job.team_document_id == user.team_document_id) or !already_sent?(job, user)}
95+
best_job = team.best_positions_for(user).detect{|job| (job.team_id == user.team_id) or !already_sent?(job, user)}
9696
return [team, best_job] unless best_job.nil?
9797
end
9898
end

app/mailers/weekly_digest_mailer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def get_team_and_job_for(user)
136136
else
137137
teams = teams_for_user(user)
138138
teams.each do |team|
139-
best_job = team.best_positions_for(user).detect { |job| (job.team_document_id == user.team_document_id) or !already_sent?(job, user) }
139+
best_job = team.best_positions_for(user).detect { |job| (job.team_id == user.team_id) or !already_sent?(job, user) }
140140
return [team, best_job] unless best_job.nil?
141141
end
142142
end

app/models/concerns/team_mapping.rb

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,6 @@ module TeamMapping
22
extend ActiveSupport::Concern
33

44
included do
5-
mapping team: {
6-
properties: {
7-
id: { type: 'string', index: 'not_analyzed' },
8-
slug: { type: 'string', index: 'not_analyzed' },
9-
name: { type: 'string', boost: 100, analyzer: 'snowball' },
10-
score: { type: 'float', index: 'not_analyzed' },
11-
size: { type: 'integer', index: 'not_analyzed' },
12-
avatar: { type: 'string', index: 'not_analyzed' },
13-
country: { type: 'string', boost: 50, analyzer: 'snowball' },
14-
url: { type: 'string', index: 'not_analyzed' },
15-
follow_path: { type: 'string', index: 'not_analyzed' },
16-
hiring: { type: 'boolean', index: 'not_analyzed' },
17-
total_member_count: { type: 'integer', index: 'not_analyzed' },
18-
completed_sections: { type: 'integer', index: 'not_analyzed' },
19-
team_members: { type: 'multi_field', fields: {
20-
username: { type: 'string', index: 'not_analyzed' },
21-
profile_url: { type: 'string', index: 'not_analyzed' },
22-
avatar: { type: 'string', index: 'not_analyzed' }
23-
} }
24-
}
25-
}
265

276
end
28-
end
7+
end

app/models/concerns/team_search.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module TeamSearch
22
extend ActiveSupport::Concern
3+
34
included do
45
include Elasticsearch::Model
56

app/models/deprecated/account.rb

Lines changed: 0 additions & 158 deletions
This file was deleted.

0 commit comments

Comments
 (0)