Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
venjobs_app
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
1
Merge Requests
1
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
Quang Vinh Nguyen
venjobs_app
Commits
2f354789
Commit
2f354789
authored
Jun 15, 2018
by
Quang Vinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
edit jobs controller
parent
90363ae6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
3 deletions
+21
-3
app/controllers/jobs_controller.rb
+18
-1
app/views/jobs/index.html.erb
+3
-2
No files found.
app/controllers/jobs_controller.rb
View file @
2f354789
class
JobsController
<
ApplicationController
def
index
@jobs
=
Job
.
search
(
params
[
:search
]).
order
(
'created_at DESC'
).
page
(
params
[
:page
])
# @jobs = Job.search(params[:search]).order('created_at DESC').page(params[:page])
@jobs
=
get_jobs_rsolr
(
params
[
:search
])
end
def
show
...
...
@@ -24,4 +25,20 @@ class JobsController < ApplicationController
def
get_jobs_in_city
(
city_id
)
Job
.
where
(
city_id:
city_id
)
end
def
get_jobs_rsolr
(
title
=
'*'
)
solr
=
RSolr
.
connect
url:
'http://localhost:8983/solr/gettingstarted/'
search_params
=
{
q:
"*:*"
,
fl:
"job_title:
#{
title
.
inspect
}
"
,
rows:
5_000
}
response_solr
=
solr
.
get
'select'
,
params:
search_params
job_ids
=
if
response_solr
[
'response'
][
'docs'
].
any?
response_solr
[
'response'
][
'docs'
].
collect
do
|
row
|
row
[
'job_id'
]
end
end
unless
job_ids
.
nil?
job_ids
.
collect
do
|
job_id
|
Job
.
where
(
id:
job_id
).
first
end
end
end
end
app/views/jobs/index.html.erb
View file @
2f354789
...
...
@@ -12,6 +12,6 @@
</nav>
<ul
class=
'jobs'
>
<%=
paginate
@jobs
,
outer_window:
3
%>
<%=
render
@jobs
%>
<%
#
= paginate @jobs, outer_window: 3 %>
<%= render @jobs
unless @jobs.blank?
%>
</ul>
\ No newline at end of file
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