From ac92b58c4a42e9efe058bf8d268286ed5c89d74c Mon Sep 17 00:00:00 2001 From: Bomrah Harry Date: Wed, 18 Jul 2018 19:42:46 +0800 Subject: [PATCH] added candidates search --- app/controllers/recruitments_controller.rb | 21 ++++++++++++++++++- .../recruitments/_employee_dashboard.html.erb | 2 +- config/locales/en.yml | 1 + config/locales/zh_tw.yml | 1 + 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/controllers/recruitments_controller.rb b/app/controllers/recruitments_controller.rb index ea69339..fbfa481 100644 --- a/app/controllers/recruitments_controller.rb +++ b/app/controllers/recruitments_controller.rb @@ -31,7 +31,7 @@ class RecruitmentsController < PseudoSessionController candidates = EmployeeProfile.job_seekers end if !candidates.nil? && !candidates.is_a?(Array) - candidates = candidates.desc(:updated_at).page(OrbitHelper.page_number).per(OrbitHelper.page_data_count) + candidates = candidates.job_seekers.desc(:updated_at).page(OrbitHelper.page_number).per(OrbitHelper.page_data_count) total_pages = candidates.total_pages else candidates = [] @@ -693,6 +693,25 @@ class RecruitmentsController < PseudoSessionController end def filter_candidates + candidates = [] + keywords = params[:q].split(",").collect{|s| /#{s.strip}/i} + names = RecruitProfile.any_of({:first_name.in => keywords}, {:last_name.in => keywords}).pluck(:id) + designations = EmployerProfile.where(:desired_job_title.in => keywords) + skills = EmployerProfile.where(:skills.in => keywords) + query = [] + if names.count > 0 + query << {:recruit_profile_id.in => names} + end + if skills.count > 0 + query << {:skills.in => keywords} + end + if designations.count > 0 + query << {:desired_job_title.in => keywords} + end + if !query.empty? + candidates = EmployerProfile.any_of(query) + end + candidates end def advanced_filter_candidates diff --git a/app/views/recruitments/_employee_dashboard.html.erb b/app/views/recruitments/_employee_dashboard.html.erb index 836b8b3..6d1e985 100644 --- a/app/views/recruitments/_employee_dashboard.html.erb +++ b/app/views/recruitments/_employee_dashboard.html.erb @@ -9,7 +9,7 @@ <% if @applications.blank? %> - <%= t("recruitment.no_jobs_found") %> + <%= t("recruitment.no_jobs_applied") %> <% else %> <% @applications.each do |app| %> <% job = app.get_job %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 73a6ae4..53db64c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -158,6 +158,7 @@ en: company_name: Company Name applied_date: Application Date no_jobs_found: No Jobs Posted. + no_jobs_applied: No Jobs Applied. emp_personal_profile: Employee / Fresher Personal Profile dob: Date of birth country_code: Country Code diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index f789ff8..db9ea7b 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -160,6 +160,7 @@ zh_tw: company_name: 公司名稱 applied_date: 應徵日期 no_jobs_found: 無相關工作 + no_jobs_applied: 沒有工作申請 emp_personal_profile: 應徵者個人資料 dob: 生日 country_code: 國籍