Commit d9883a12 by Thanh Hung Pham

Resolve path

parent 246f2c6b
...@@ -5,24 +5,6 @@ class JobsController < ApplicationController ...@@ -5,24 +5,6 @@ class JobsController < ApplicationController
@applied_jobs = Apply.where(user_id: current_user.id) @applied_jobs = Apply.where(user_id: current_user.id)
end end
def search
@search_conditions = params[:text_search]
rsolr = RSolr.connect url: 'http://localhost:8983/solr/veNJOBDATA/'
response = rsolr.get 'select', params: {
q: @search_conditions.gsub(/\s[^0-9a-z ]/i, '')
}
@job_ids = []
response['response']['docs'].each do |doc|
@job_ids.push(doc['job_id'])
end
@job_ids = Job.limit(20).ids if @job_ids.length.zero?
redirect_to jobs_show_path(job_ids: @job_ids, search_conditions: @search_conditions)
end
def detail def detail
@job = Job.find(params[:id]) @job = Job.find(params[:id])
History.new(user: current_user, job: @job).save if History.where(user: current_user, job: @job).blank? History.new(user: current_user, job: @job).save if History.where(user: current_user, job: @job).blank?
...@@ -68,11 +50,26 @@ class JobsController < ApplicationController ...@@ -68,11 +50,26 @@ class JobsController < ApplicationController
@search_conditions = "All jobs in #{Company.find(params[:company_id]).name}" @search_conditions = "All jobs in #{Company.find(params[:company_id]).name}"
end end
unless params[:job_ids].nil? unless params[:text_search].nil?
@job_count = Job.where(id: params[:job_ids]).count @search_text = params[:text_search]
@jobs = Job.where(id: params[:job_ids]).page params[:page]
rsolr = RSolr.connect url: 'http://localhost:8983/solr/veNJOBDATA/'
response = rsolr.get 'select', params: {
q: @search_text.gsub(/\s[^0-9a-z ]/i, ''),
start: 0,
rows: 100_000_000
}
@job_ids = []
response['response']['docs'].each do |doc|
@job_ids.push(doc['job_id'])
end
@job_ids = Job.limit(20).ids if @job_ids.length.zero?
@job_count = Job.where(id: @job_ids).count
@jobs = Job.where(id: @job_ids).page params[:page]
@search_conditions = "All jobs in #{params[:search_conditions]}" @search_conditions = "All jobs in #{params[:search_conditions]}"
@search_text = params[:search_conditions]
end end
end end
......
<%= form_tag jobs_search_path do %> <%= form_tag jobs_show_path do %>
<div class="row form-group"> <div class="row form-group">
<div class="col-md-10"> <div class="col-md-10">
<%= text_area_tag 'text_search', @search_text, class: 'form-control' %> <%= text_area_tag 'text_search', @search_text, class: 'form-control' %>
......
...@@ -7,6 +7,7 @@ Rails.application.routes.draw do ...@@ -7,6 +7,7 @@ Rails.application.routes.draw do
get 'jobs/applied_jobs', to: 'jobs#applied_jobs' get 'jobs/applied_jobs', to: 'jobs#applied_jobs'
get 'jobs/show/', to: 'jobs#show' get 'jobs/show/', to: 'jobs#show'
post 'jobs/show/', to: 'jobs#show'
get 'jobs/detail/', to: 'jobs#detail' get 'jobs/detail/', to: 'jobs#detail'
get 'jobs/apply/', to: 'jobs#apply' get 'jobs/apply/', to: 'jobs#apply'
get 'jobs/confirm', to: 'jobs#confirm' get 'jobs/confirm', to: 'jobs#confirm'
...@@ -17,7 +18,6 @@ Rails.application.routes.draw do ...@@ -17,7 +18,6 @@ Rails.application.routes.draw do
get 'jobs/favorite_remove', to: 'jobs#favorite_remove' get 'jobs/favorite_remove', to: 'jobs#favorite_remove'
get 'jobs/favorited_jobs', to: 'jobs#favorited_jobs' get 'jobs/favorited_jobs', to: 'jobs#favorited_jobs'
get 'jobs/history_jobs', to: 'jobs#history_jobs' get 'jobs/history_jobs', to: 'jobs#history_jobs'
post 'jobs/search', to: 'jobs#search'
resource :cities resource :cities
devise_scope :user do devise_scope :user do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment