fix for expired jobs

This commit is contained in:
Bomrah Harry 2018-07-18 18:47:40 +08:00
parent e7ee67fead
commit a41a1fabf9
2 changed files with 2 additions and 2 deletions

View File

@ -83,7 +83,7 @@ class RecruitmentsController < PseudoSessionController
rjobs = RecruitmentJob.where(:post_type => type).not_filled
end
if !rjobs.nil? && !rjobs.is_a?(Array)
rjobs = rjobs.excluded_expired.desc(:created_at).page(OrbitHelper.page_number).per(OrbitHelper.page_data_count)
rjobs = rjobs.not_expired.desc(:created_at).page(OrbitHelper.page_number).per(OrbitHelper.page_data_count)
total_pages = rjobs.total_pages
else
rjobs = []

View File

@ -50,7 +50,7 @@ class RecruitmentJob
scope :jobs, ->{where(:post_type => "type1")}
scope :internships, ->{where(:post_type => "type2")}
scope :exchanges, ->{where(:post_type => "type3")}
scope :excluded_expired, ->{any_of({:expiry_date.gte => Time.now}, {:expiry_date => nil})}
scope :not_expired, ->{any_of({:expiry_date.lte => Time.now}, {:expiry_date => nil})}
def get_category
RecruitmentCategory.find(self.category).job_category rescue ""