Skip to content
This repository was archived by the owner on Mar 23, 2023. It is now read-only.

Commit 182c220

Browse files
Reduce code complexity that was recently introduced
1 parent 6db61d5 commit 182c220

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

app/controllers/jobs_controller.rb

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,20 +146,17 @@ def set_job
146146
end
147147

148148
def filter_by_params(user = nil)
149-
if user.nil?
150-
user_jobs = Job.all
151-
else
152-
user_jobs = Job.user_jobs(user)
153-
end
149+
user_jobs = user.nil? ? Job.all : Job.user_jobs(user)
154150
state_params = params[:state]
155151

156-
if state_params == 'user'
152+
case state_params
153+
when 'user'
157154
@jobs = user_jobs
158-
elsif state_params == 'draft'
155+
when 'draft'
159156
@jobs = user_jobs.draft_jobs
160-
elsif state_params == 'pending'
157+
when 'pending'
161158
@jobs = user_jobs.pending_jobs
162-
elsif state_params == 'expired'
159+
when 'expired'
163160
@jobs = user_jobs.expired_jobs
164161
end
165162
end

app/models/job.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,15 +211,14 @@ def to_text_for_social_media
211211
text = "#{self.company_name.titleize} is looking to hire a #{self.title}"
212212
text += " in #{self.location_name}" unless self.location_name.blank?
213213
text += ". More information here https://#{AppSettings.application_host}/jobs/#{self.to_param}"
214+
214215
return text
215216
end
216217

217218
def to_text_for_twitter
218219
text = "text=#{self.company_name.titleize} is looking to hire a #{self.title}"
219220
text += " in #{self.location_name}" unless self.location_name.blank?
220-
text += ". More information here"
221-
text += "&url=https://#{AppSettings.application_host}/jobs/#{self.to_param}"
222-
text += "&hashtags=#{self.location_name}"
221+
text += ". More information here&url=https://#{AppSettings.application_host}/jobs/#{self.to_param}&hashtags=#{self.location_name}"
223222
if !self.twitter_handle.blank?
224223
if self.twitter_handle.start_with?('@')
225224
text += (" " + self.twitter_handle)

0 commit comments

Comments
 (0)