Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
venjob_nth
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ngô Trung Hưng
venjob_nth
Commits
8d2405f1
Commit
8d2405f1
authored
Sep 01, 2020
by
Ngô Trung Hưng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix func search
parent
4e3ee992
Pipeline
#1057
failed with stages
in 0 seconds
Changes
13
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
75 additions
and
181 deletions
+75
-181
app/assets/stylesheets/custom.scss
+30
-11
app/controllers/home_controller.rb
+2
-2
app/controllers/job_controller.rb
+1
-0
app/controllers/search_controller.rb
+6
-6
app/forms/search.rb
+4
-1
app/views/home/_banner_and_search.html.erb
+6
-12
app/views/home/index.html.erb
+1
-1
app/views/job/result_data.html.erb
+2
-2
app/views/search/_banner_and_search.html.erb
+12
-14
app/views/search/_new.html.erb
+0
-119
app/views/search/result.html.erb
+2
-2
config/routes.rb
+1
-3
lib/solr/searches/query.rb
+8
-8
No files found.
app/assets/stylesheets/custom.scss
View file @
8d2405f1
...
...
@@ -406,18 +406,29 @@ $main-color: #23303D;
transform
:
translateY
(
-50%
);
}
}
.search_industries
select
{
@mixin
custom_select
{
padding
:
12px
10px
12px
5px
;
width
:
100%
;
border-radius
:
4px
!
important
;
border
:
none
;
box-shadow
:
none
;
background
:
transparent
;
outline
:
none
;
cursor
:
pointer
;
text-indent
:
0
.01px
;
text-overflow
:
ellipsis
;
text-overflow
:
ellipsis
;
padding-left
:
16px
;
color
:
#666
;
font-size
:
15px
;
}
.search_industries
select
{
@include
custom_select
()
}
.search_location
select
{
@include
custom_select
()
}
.search_location
{
...
...
@@ -557,10 +568,12 @@ $main-color: #23303D;
background-color
:
#fff
;
color
:
#666
;
margin-bottom
:
10px
;
border
:
none
;
font-size
:
13px
;
// padding: 0px 4px;
}
.search_industries_mobile
{
position
:
relative
;
@include
custom_selected_mobile
();
&
:
:
before
{
position
:
absolute
;
content
:
''
;
...
...
@@ -572,7 +585,13 @@ $main-color: #23303D;
transform
:
translateY
(
-50%
);
}
}
.search_location_mobile
{
.search_industries_mobile
select
{
padding
:
0px
4px
;
@include
custom_selected_mobile
()
}
.search_location_mobile
select
{
padding
:
0px
4px
;
@include
custom_selected_mobile
()
}
...
...
@@ -1362,12 +1381,12 @@ $main-color: #23303D;
.btn_search_submit
{
height
:
30px
;
}
.search_industries_mobile
{
padding-right
:
4px
;
}
.search_location_mobile
{
padding-right
:
4px
;
}
//
.search_industries_mobile {
//
padding-right: 4px;
//
}
//
.search_location_mobile {
//
padding-right: 4px;
//
}
}
@media
only
screen
and
(
max-width
:
576px
)
{
.lol
{
...
...
app/controllers/home_controller.rb
View file @
8d2405f1
...
...
@@ -3,8 +3,8 @@
# Home page
class
HomeController
<
ApplicationController
def
index
@search
=
Se
ndDataToApplyForm
.
new
@industries
=
Industry
.
order
(
name: :asc
)
.
all
@search
=
Se
arch
.
new
@industries
=
Industry
.
order
(
name: :asc
)
@job_count
=
Job
.
count
@cities
=
City
.
all_cities
@lasted_jobs
=
Job
.
order
(
created_at: :desc
).
limit
(
Job
::
NUMBER_LASTED_JOB
)
...
...
app/controllers/job_controller.rb
View file @
8d2405f1
...
...
@@ -28,6 +28,7 @@ class JobController < ApplicationController
end
def
render_result
(
obj
)
@search
=
Search
.
new
@keyword
=
obj
.
name
@data
=
obj
.
jobs
.
page
(
params
[
:page
])
return
render
'error/page_not_found'
if
@data
.
blank?
...
...
app/controllers/search_controller.rb
View file @
8d2405f1
...
...
@@ -2,12 +2,12 @@ class SearchController < ApplicationController
before_action
:load_data_dropdown
def
search
debugger
@
keyword
=
params
[
:send_data_to_apply_form
][
:keyword
]
@
industry
=
Industry
.
find_by
(
id:
params
[
:industry_id
])
if
params
[
:industry_id
].
present?
@
city
=
City
.
find_by
(
id:
params
[
:city_id
])
if
params
[
:city_id
].
present?
@results
=
Search
::
Query
.
new
.
search
(
@keyword
,
params
[
:industry_id
],
params
[
:city_id
],
params
[
:page
])
return
render
'error/page_not_found'
if
params
[
:page
].
to_i
>
@results
.
total_pages
@keyword
=
params
[
:search
][
:keyword
]
@
industry
=
Industry
.
find_by
(
id:
params
[
:search
][
:industry_id
])
@
city
=
City
.
find_by
(
id:
params
[
:search
][
:city_id
])
@
results
=
Searches
::
Query
.
new
.
search
(
params
)
return
render
'error/page_not_found'
if
params
[
:page
].
to_i
>
@results
.
total_pages
@search
=
Search
.
new
render
:result
end
...
...
app/forms/se
nd_data_to_apply_form
.rb
→
app/forms/se
arch
.rb
View file @
8d2405f1
# frozen_string_literal: true
class
Se
ndDataToApplyForm
class
Se
arch
include
ActiveModel
::
Model
attr_accessor
:keyword
,
:industry_id
,
:city_id
selected_industry
=
@industry
.
blank?
?
'*'
:
@industry
.
id
selected_city
=
@city
.
blank?
?
'*'
:
@city
.
id
end
app/views/home/_banner_and_search.html.erb
View file @
8d2405f1
...
...
@@ -31,15 +31,13 @@
<div
class=
"icon_list"
>
<i
class=
"fa fa-list-ul"
aria-hidden=
"true"
></i>
</div>
<%
selected
=
@industry
.
blank?
?
'*'
:
@industry
.
id
%>
<%=
select_tag
'industry_id'
,
options_from_collection_for_select
(
@industries
,
'id'
,
'name'
,
selected
),
prompt:
t
(
'pages.banner.all_industries'
),
class:
'show_list_industries'
%>
<%=
select_tag
'industry_id'
,
options_from_collection_for_select
(
@industries
,
'id'
,
'name'
,
selected_industry
),
prompt:
t
(
'pages.banner.all_industries'
),
class:
'show_list_industries'
%>
</div>
<div
class=
"search_location"
>
<div
class=
"icon_list"
>
<i
class=
"fas fa-map-marker-alt"
></i>
</div>
<%
selected
=
@city
.
blank?
?
'*'
:
@city
.
id
%>
<%=
select_tag
'city_id'
,
options_from_collection_for_select
(
@cities
,
'id'
,
'name'
,
selected
),
prompt:
t
(
'pages.banner.all_locations'
),
class:
'show_list_cities'
%>
<%=
select_tag
'city_id'
,
options_from_collection_for_select
(
@cities
,
'id'
,
'name'
,
selected_city
),
prompt:
t
(
'pages.banner.all_locations'
),
class:
'show_list_cities'
%>
</div>
<div
class=
"search_submit"
>
<%=
f
.
submit
t
(
'pages.banner.btn_text_search'
),
name:
nil
,
class:
'btn_search_submit'
%>
...
...
@@ -63,15 +61,13 @@
<div
class=
"icon_list"
>
<i
class=
"fa fa-list-ul"
aria-hidden=
"true"
></i>
</div>
<%
selected
=
@industry
.
blank?
?
'*'
:
@industry
.
id
%>
<%=
select_tag
'industry_id'
,
options_from_collection_for_select
(
@industries
,
'id'
,
'name'
,
selected
),
prompt:
t
(
'pages.banner.all_industries'
),
class:
'show_list_industries'
%>
<%=
select_tag
'industry_id'
,
options_from_collection_for_select
(
@industries
,
'id'
,
'name'
,
selected_industry
),
prompt:
t
(
'pages.banner.all_industries'
),
class:
'show_list_industries'
%>
</div>
<div
class=
"search_location"
>
<div
class=
"icon_list"
>
<i
class=
"fas fa-map-marker-alt"
></i>
</div>
<%
selected
=
@city
.
blank?
?
'*'
:
@city
.
id
%>
<%=
select_tag
'city_id'
,
options_from_collection_for_select
(
@cities
,
'id'
,
'name'
,
selected
),
prompt:
t
(
'pages.banner.all_locations'
),
class:
'show_list_cities'
%>
<%=
select_tag
'city_id'
,
options_from_collection_for_select
(
@cities
,
'id'
,
'name'
,
selected_city
),
prompt:
t
(
'pages.banner.all_locations'
),
class:
'show_list_cities'
%>
</div>
<div
class=
"search_submit"
>
<%=
f
.
submit
t
(
'pages.banner.btn_text_search'
),
name:
nil
,
class:
'btn_search_submit'
%>
...
...
@@ -94,14 +90,12 @@
</div>
<div
class=
"col-sm-6 col-xs-12"
>
<div
class=
"search_industries_mobile"
>
<%
selected
=
@industry
.
blank?
?
'*'
:
@industry
.
id
%>
<%=
select_tag
'industry_id'
,
options_from_collection_for_select
(
@industries
,
'id'
,
'name'
,
selected
),
prompt:
t
(
'pages.banner.all_industries'
),
class:
'show_list_industries_mobile'
%>
<%=
select_tag
'industry_id'
,
options_from_collection_for_select
(
@industries
,
'id'
,
'name'
,
selected_industry
),
prompt:
t
(
'pages.banner.all_industries'
),
class:
'show_list_industries_mobile'
%>
</div>
</div>
<div
class=
"col-sm-6 col-xs-12"
>
<div
class=
"search_location_mobile"
>
<%
selected
=
@city
.
blank?
?
'*'
:
@city
.
id
%>
<%=
select_tag
'city_id'
,
options_from_collection_for_select
(
@cities
,
'id'
,
'name'
,
selected
),
prompt:
t
(
'pages.banner.all_locations'
),
class:
'show_list_cities_mobile'
%>
<%=
select_tag
'city_id'
,
options_from_collection_for_select
(
@cities
,
'id'
,
'name'
,
selected_city
),
prompt:
t
(
'pages.banner.all_locations'
),
class:
'show_list_cities_mobile'
%>
</div>
</div>
</div>
...
...
app/views/home/index.html.erb
View file @
8d2405f1
<%
provide
(
:title
,
"
#{
t
(
'title.home'
)
}
"
)
%>
<%=
render
'search/
new
'
%>
<%=
render
'search/
banner_and_search
'
%>
<div
class=
"padding_index"
></div>
<%
unless
@job_count
.
nil?
%>
<div
class=
"box_text_five_jobs"
>
...
...
app/views/job/result_data.html.erb
View file @
8d2405f1
<%
provide
(
:title
,
"
#{
t
(
'pages.detail.br_title'
)
}
"
)
%>
<%=
render
'
home
/banner_and_search'
%>
<%=
render
'
search
/banner_and_search'
%>
<div
class=
"padding_index"
></div>
<div
class=
"container"
>
<div
class=
"row"
>
...
...
@@ -11,7 +11,7 @@
<%=
t
(
'pages.result.result_find'
,
job:
@data
.
total_count
,
key:
@keyword
).
html_safe
%>
</div>
<%
else
%>
<%=
t
(
'pages.result.no_result_find'
,
key:
@keyword
).
html_safe
%>
<%=
t
(
'pages.result.no_result_find'
,
key:
@keyword
).
html_safe
%>
<%
end
%>
</span>
</div>
...
...
app/views/search/_banner_and_search.html.erb
View file @
8d2405f1
...
...
@@ -16,13 +16,11 @@
<div
class=
"box-search"
>
<div
class=
"search_scaffold"
>
<div
class =
"total_job"
>
<%
if
@job_count
.
blank?
%>
<h4
class=
"show_total_job"
>
<%=
t
(
'pages.banner.slogan_2'
)
%>
</h4>
<%
else
%>
<h4
class=
"show_total_job"
>
<%=
t
(
'pages.banner.slogan_3'
,
job_count:
@job_count
)
%>
</h4>
<%
end
%>
<h4
class=
"show_total_job"
>
<%=
@job_count
.
blank?
?
t
(
'pages.banner.slogan_2'
)
:
t
(
'pages.banner.slogan_3'
,
job_count:
@job_count
)
%>
</h4>
</div>
<%=
form_
with
url:
search_path
,
method: :get
,
local:
true
,
skip_enforcing_utf8:
true
do
|
f
|
%>
<%=
form_
for
@search
,
enforce_utf8:
false
,
method: :get
do
|
f
|
%>
<div
class=
"filter_box"
>
<div
class=
"search_input"
>
<%=
f
.
search_field
:keyword
,
value:
@keyword
,
class:
'custom_input_search'
,
placeholder:
t
(
'pages.banner.search_placeholder'
)
%>
...
...
@@ -32,14 +30,14 @@
<i
class=
"fa fa-list-ul"
aria-hidden=
"true"
></i>
</div>
<%
selected
=
@industry
.
blank?
?
'*'
:
@industry
.
id
%>
<%=
select_tag
'industry_id'
,
options_from_collection_for_select
(
@industries
,
'id'
,
'name'
,
selected
),
prompt:
t
(
'pages.banner.all_industries'
),
class:
'show_list_industries'
%>
<%=
f
.
select
'industry_id'
,
options_from_collection_for_select
(
@industries
,
'id'
,
'name'
,
selected
),
prompt:
t
(
'pages.banner.all_industries'
),
class:
'show_list_industries'
%>
</div>
<div
class=
"search_location"
>
<div
class=
"icon_list"
>
<i
class=
"fas fa-map-marker-alt"
></i>
</div>
<%
selected
=
@city
.
blank?
?
'*'
:
@city
.
id
%>
<%=
select_tag
'city_id'
,
options_from_collection_for_select
(
@cities
,
'id'
,
'name'
,
selected
),
prompt:
t
(
'pages.banner.all_locations'
),
class:
'show_list_cities'
%>
<%=
f
.
select
'city_id'
,
options_from_collection_for_select
(
@cities
,
'id'
,
'name'
,
selected
),
prompt:
t
(
'pages.banner.all_locations'
),
class:
'show_list_cities'
%>
</div>
<div
class=
"search_submit"
>
<%=
f
.
submit
t
(
'pages.banner.btn_text_search'
),
name:
nil
,
class:
'btn_search_submit'
%>
...
...
@@ -54,7 +52,7 @@
<div
class =
"total_job"
>
<h4
class=
"show_total_job"
>
<%=
t
(
'pages.banner.slogan_3'
,
job_count:
@job_count
)
%>
</h4>
</div>
<%=
form_
with
url:
search_path
,
method: :get
,
local:
true
,
skip_enforcing_utf8:
true
do
|
f
|
%>
<%=
form_
for
@search
,
enforce_utf8:
false
,
method: :get
do
|
f
|
%>
<div
class=
"filter_box filter_box_tablet"
>
<div
class=
"search_input"
>
<%=
f
.
search_field
:keyword
,
value:
@keyword
,
class:
'custom_input_search'
,
placeholder:
t
(
'pages.banner.search_placeholder'
)
%>
...
...
@@ -64,14 +62,14 @@
<i
class=
"fa fa-list-ul"
aria-hidden=
"true"
></i>
</div>
<%
selected
=
@industry
.
blank?
?
'*'
:
@industry
.
id
%>
<%=
select_tag
'industry_id'
,
options_from_collection_for_select
(
@industries
,
'id'
,
'name'
,
selected
),
prompt:
t
(
'pages.banner.all_industries'
),
class:
'show_list_industries'
%>
<%=
f
.
select
'industry_id'
,
options_from_collection_for_select
(
@industries
,
'id'
,
'name'
,
selected
),
prompt:
t
(
'pages.banner.all_industries'
),
class:
'show_list_industries'
%>
</div>
<div
class=
"search_location"
>
<div
class=
"icon_list"
>
<i
class=
"fas fa-map-marker-alt"
></i>
</div>
<%
selected
=
@city
.
blank?
?
'*'
:
@city
.
id
%>
<%=
select_tag
'city_id'
,
options_from_collection_for_select
(
@cities
,
'id'
,
'name'
,
selected
),
prompt:
t
(
'pages.banner.all_locations'
),
class:
'show_list_cities'
%>
<%=
f
.
select
'city_id'
,
options_from_collection_for_select
(
@cities
,
'id'
,
'name'
,
selected
),
prompt:
t
(
'pages.banner.all_locations'
),
class:
'show_list_cities'
%>
</div>
<div
class=
"search_submit"
>
<%=
f
.
submit
t
(
'pages.banner.btn_text_search'
),
name:
nil
,
class:
'btn_search_submit'
%>
...
...
@@ -85,7 +83,7 @@
</div>
<!-- Process search mobile-->
<div
class=
"box-search-mobile"
>
<%=
form_
with
url:
search_path
,
method: :get
,
local:
true
,
skip_enforcing_utf8:
true
do
|
f
|
%>
<%=
form_
for
@search
,
enforce_utf8:
false
,
method: :get
do
|
f
|
%>
<div
class=
"fillter-search-mobile"
>
<div
class=
"container"
>
<div
class=
"row no-gutters"
>
...
...
@@ -95,13 +93,13 @@
<div
class=
"col-sm-6 col-xs-12"
>
<div
class=
"search_industries_mobile"
>
<%
selected
=
@industry
.
blank?
?
'*'
:
@industry
.
id
%>
<%=
select_tag
'industry_id'
,
options_from_collection_for_select
(
@industries
,
'id'
,
'name'
,
selected
),
prompt:
t
(
'pages.banner.all_industries'
),
class:
'show_list_industries_mobile'
%>
<%=
f
.
select
'industry_id'
,
options_from_collection_for_select
(
@industries
,
'id'
,
'name'
,
selected
),
prompt:
t
(
'pages.banner.all_industries'
),
class:
'show_list_industries_mobile'
%>
</div>
</div>
<div
class=
"col-sm-6 col-xs-12"
>
<div
class=
"search_location_mobile"
>
<%
selected
=
@city
.
blank?
?
'*'
:
@city
.
id
%>
<%=
select_tag
'city_id'
,
options_from_collection_for_select
(
@cities
,
'id'
,
'name'
,
selected
),
prompt:
t
(
'pages.banner.all_locations'
),
class:
'show_list_cities_mobile'
%>
<%=
f
.
select
'city_id'
,
options_from_collection_for_select
(
@cities
,
'id'
,
'name'
,
selected
),
prompt:
t
(
'pages.banner.all_locations'
),
class:
'show_list_cities_mobile'
%>
</div>
</div>
</div>
...
...
app/views/search/_new.html.erb
deleted
100644 → 0
View file @
4e3ee992
<div
class =
"box-banner"
>
<%=
image_tag
'banner-search-box-home.png'
,
class:
"banner-top"
%>
<div
class=
"row"
>
<div
class=
"col-xs-12"
>
<div
class =
"slogan"
>
<h2
class =
"slogan_text"
>
<%=
t
(
'pages.banner.slogan'
)
%>
</h2>
<h5
class =
"slogan_text_h5"
>
<%=
t
(
'pages.banner.slogan'
)
%>
</h5>
</div>
</div>
</div>
<!-- Process search pc-->
<div
class=
"box-search"
>
<div
class=
"search_scaffold"
>
<div
class =
"total_job"
>
<%
if
@job_count
.
blank?
%>
<h4
class=
"show_total_job"
>
<%=
t
(
'pages.banner.slogan_2'
)
%>
</h4>
<%
else
%>
<h4
class=
"show_total_job"
>
<%=
t
(
'pages.banner.slogan_3'
,
job_count:
@job_count
)
%>
</h4>
<%
end
%>
</div>
<%=
form_for
@search
,
method: :get
do
|
f
|
%>
<div
class=
"filter_box"
>
<div
class=
"search_input"
>
<%=
f
.
search_field
:keyword
,
value:
@keyword
,
class:
'custom_input_search'
,
placeholder:
t
(
'pages.banner.search_placeholder'
)
%>
</div>
<div
class=
"search_industries"
>
<div
class=
"icon_list"
>
<i
class=
"fa fa-list-ul"
aria-hidden=
"true"
></i>
</div>
<%
selected
=
@industry
.
blank?
?
'*'
:
@industry
.
id
%>
<%=
select_tag
'industry_id'
,
options_from_collection_for_select
(
@industries
,
'id'
,
'name'
,
selected
),
prompt:
t
(
'pages.banner.all_industries'
),
class:
'show_list_industries'
%>
</div>
<div
class=
"search_location"
>
<div
class=
"icon_list"
>
<i
class=
"fas fa-map-marker-alt"
></i>
</div>
<%
selected
=
@city
.
blank?
?
'*'
:
@city
.
id
%>
<%=
select_tag
'city_id'
,
options_from_collection_for_select
(
@cities
,
'id'
,
'name'
,
selected
),
prompt:
t
(
'pages.banner.all_locations'
),
class:
'show_list_cities'
%>
</div>
<div
class=
"search_submit"
>
<%=
f
.
submit
t
(
'pages.banner.btn_text_search'
),
name:
nil
,
class:
'btn_search_submit'
%>
</div>
</div>
<%
end
%>
</div>
</div>
<!-- Process search tablet-->
<div
class=
"box-search-tablet"
>
<div
class=
"search_scaffold-tablet"
>
<div
class =
"total_job"
>
<h4
class=
"show_total_job"
>
<%=
t
(
'pages.banner.slogan_3'
,
job_count:
@job_count
)
%>
</h4>
</div>
<%=
form_with
url:
search_path
,
method: :get
,
local:
true
,
skip_enforcing_utf8:
true
do
|
f
|
%>
<div
class=
"filter_box filter_box_tablet"
>
<div
class=
"search_input"
>
<%=
f
.
search_field
:keyword
,
value:
@keyword
,
class:
'custom_input_search'
,
placeholder:
t
(
'pages.banner.search_placeholder'
)
%>
</div>
<div
class=
"search_industries"
>
<div
class=
"icon_list"
>
<i
class=
"fa fa-list-ul"
aria-hidden=
"true"
></i>
</div>
<%
selected
=
@industry
.
blank?
?
'*'
:
@industry
.
id
%>
<%=
select_tag
'industry_id'
,
options_from_collection_for_select
(
@industries
,
'id'
,
'name'
,
selected
),
prompt:
t
(
'pages.banner.all_industries'
),
class:
'show_list_industries'
%>
</div>
<div
class=
"search_location"
>
<div
class=
"icon_list"
>
<i
class=
"fas fa-map-marker-alt"
></i>
</div>
<%
selected
=
@city
.
blank?
?
'*'
:
@city
.
id
%>
<%=
select_tag
'city_id'
,
options_from_collection_for_select
(
@cities
,
'id'
,
'name'
,
selected
),
prompt:
t
(
'pages.banner.all_locations'
),
class:
'show_list_cities'
%>
</div>
<div
class=
"search_submit"
>
<%=
f
.
submit
t
(
'pages.banner.btn_text_search'
),
name:
nil
,
class:
'btn_search_submit'
%>
</div>
</div>
<%
end
%>
</div>
</div>
<div
class=
"box-show-total-jobs-mobile"
>
<span>
<%=
t
(
'pages.banner.slogan_3'
,
job_count:
@job_count
)
%>
</span>
</div>
<!-- Process search mobile-->
<div
class=
"box-search-mobile"
>
<%=
form_with
url:
search_path
,
method: :get
,
local:
true
,
skip_enforcing_utf8:
true
do
|
f
|
%>
<div
class=
"fillter-search-mobile"
>
<div
class=
"container"
>
<div
class=
"row no-gutters"
>
<div
class=
"col-md-12"
>
<%=
f
.
search_field
:keyword
,
value:
@keyword
,
class:
'custom_input_mobile_search'
,
placeholder:
t
(
'pages.banner.search_placeholder'
)
%>
</div>
<div
class=
"col-sm-6 col-xs-12"
>
<div
class=
"search_industries_mobile"
>
<%
selected
=
@industry
.
blank?
?
'*'
:
@industry
.
id
%>
<%=
select_tag
'industry_id'
,
options_from_collection_for_select
(
@industries
,
'id'
,
'name'
,
selected
),
prompt:
t
(
'pages.banner.all_industries'
),
class:
'show_list_industries_mobile'
%>
</div>
</div>
<div
class=
"col-sm-6 col-xs-12"
>
<div
class=
"search_location_mobile"
>
<%
selected
=
@city
.
blank?
?
'*'
:
@city
.
id
%>
<%=
select_tag
'city_id'
,
options_from_collection_for_select
(
@cities
,
'id'
,
'name'
,
selected
),
prompt:
t
(
'pages.banner.all_locations'
),
class:
'show_list_cities_mobile'
%>
</div>
</div>
</div>
</div>
</div>
<div
class=
"container"
>
<div
class=
"row no-gutters"
>
<div
class=
"col-sm-12"
>
<%=
f
.
submit
t
(
'pages.banner.btn_text_search'
),
name:
nil
,
class:
'btn_search_submit'
%>
</div>
</div>
</div>
</div>
<%
end
%>
</div>
app/views/search/result.html.erb
View file @
8d2405f1
<%
provide
(
:title
,
"
#{
t
(
'pages.detail.br_title'
)
}
"
)
%>
<%=
render
'
home
/banner_and_search'
%>
<%=
render
'
search
/banner_and_search'
%>
<div
class=
"padding_index"
></div>
<div
class=
"container"
>
<div
class=
"row"
>
...
...
@@ -14,7 +14,7 @@
<%=
t
(
'pages.result.result_find'
,
job:
@results
.
total_count
,
key:
@keyword
).
html_safe
%>
<%
else
%>
<%=
t
(
'pages.result.no_result_find'
,
key:
@keyword
).
html_safe
%>
<%
end
%>
<%
end
%>
<b>
<%=
"
#{
@industry
.
try
(
:name
)
}
#{
@city
.
try
(
:name
)
}
"
%>
</b>
</span>
</div>
...
...
config/routes.rb
View file @
8d2405f1
...
...
@@ -6,9 +6,7 @@ Rails.application.routes.draw do
devise_for
:users
,
controllers:
{
registrations:
'registrations'
,
passwords:
'passwords'
}
root
'home#index'
# Search
get
'search'
,
to:
'search#search'
,
as: :send_data_to_apply_forms
get
'search'
,
to:
'search#search'
,
as: :search
get
'search'
,
to:
'search#search'
,
as: :searches
get
'register/:code'
,
to:
'users#confirm_sign_up'
,
as: :confirm_sign_up
get
'industries'
,
to:
'industry#index'
,
as: :industry_index
get
'cities'
,
to:
'city#index'
,
as: :city_index
...
...
lib/solr/search/query.rb
→
lib/solr/search
es
/query.rb
View file @
8d2405f1
module
Search
class
Query
def
search
(
keyword
,
industry_id
,
city_id
,
params_page
)
module
Search
es
class
Query
def
search
(
params
)
solr
=
connect_solr
# Escape input & Convert space to asterisks
data
=
sub_space_params!
(
keyword
,
industry_id
,
city_id
)
query
=
if
keyword
.
blank?
&&
industry_id
.
blank?
&&
city_id
.
blank?
data
=
sub_space_params!
(
params
[
:search
][
:keyword
],
params
[
:search
][
:industry_id
],
params
[
:search
][
:city_id
]
)
query
=
if
[
params
[
:search
][
:keyword
],
params
[
:search
][
:industry_id
],
params
[
:search
][
:city_id
]].
all?
{
|
v
|
v
.
blank?
}
'*:*'
else
"solr((name:
#{
data
[
:keyword
]
}
) OR (company_name:
#{
data
[
:keyword
]
}
)) AND (industry_id:
#{
data
[
:industry_id
]
}
) AND (location_id:
#{
data
[
:location_id
]
}
)"
end
response
=
solr
.
paginate
(
params
_page
,
Settings
.
number_result_search_in_page
,
'select'
,
params:
{
q:
query
})
results
=
Kaminari
.
paginate_array
(
response
[
'response'
][
'docs'
],
total_count:
response
[
'response'
][
'numFound'
]).
page
(
params
_page
).
per
(
Settings
.
number_result_search_in_page
)
response
=
solr
.
paginate
(
params
[
:page
]
,
Settings
.
number_result_search_in_page
,
'select'
,
params:
{
q:
query
})
results
=
Kaminari
.
paginate_array
(
response
[
'response'
][
'docs'
],
total_count:
response
[
'response'
][
'numFound'
]).
page
(
params
[
:page
]
).
per
(
Settings
.
number_result_search_in_page
)
end
def
sub_space_params!
(
keyword
,
industry_id
,
location_id
)
arr_params
=
{}
arr_params
[
:keyword
]
=
RSolr
.
solr_escape
(
keyword
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment