Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
veNJOB
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
2
Merge Requests
2
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
Thanh Hung Pham
veNJOB
Commits
38655032
Commit
38655032
authored
Jul 13, 2017
by
Thanh Hung Pham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Inport solr
parent
156a27e7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
13 deletions
+13
-13
app/controllers/jobs_controller.rb
+4
-13
app/models/job.rb
+9
-0
No files found.
app/controllers/jobs_controller.rb
View file @
38655032
...
...
@@ -9,21 +9,11 @@ class JobsController < ApplicationController
@search_conditions
=
params
[
:text_search
]
rsolr
=
RSolr
.
connect
url:
'http://localhost:8983/solr/veNJOBDATA/'
# rsolr.add(job_id: 1, job_name: 'a', job_description: 'b')
# rsolr.update data: '<commit/>', headers: { 'Content-Type' => 'text/xml' }
# rsolr.update data: { optimize: true }.to_json, headers: { 'Content-Type' => 'application/json' }
# rsolr.commit
response
=
rsolr
.
get
'select'
,
params:
{
q:
@search_conditions
,
start:
0
,
rows:
10
}
response
[
'response'
][
'docs
'
]
response
=
rsolr
.
get
'select'
,
params:
{
q:
@search_conditions
}
job_ids
=
response
[
'response'
][
'docs'
][
'job_id
'
]
raise
'test'
# search = rsolr.select params: { q: @search_conditions }
# search['response']['docs']
redirect_to
jobs_show_path
redirect_to
jobs_show_path
(
job_ids:
job_ids
)
end
def
detail
...
...
@@ -52,6 +42,7 @@ class JobsController < ApplicationController
end
def
show
raise
'test'
unless
params
[
:city_id
].
nil?
@job_count
=
Job
.
where
(
city_id:
params
[
:city_id
]).
count
@jobs
=
Job
.
where
(
city_id:
params
[
:city_id
]).
page
params
[
:page
]
...
...
app/models/job.rb
View file @
38655032
class
Job
<
ApplicationRecord
after_save
:import_solr
belongs_to
:city
,
optional:
true
belongs_to
:company
,
optional:
true
belongs_to
:job_type
,
optional:
true
...
...
@@ -9,4 +10,12 @@ class Job < ApplicationRecord
paginates_per
20
validates
:name
,
presence:
true
,
length:
{
maximum:
200
}
private
def
import_solr
rsolr
=
RSolr
.
connect
url:
'http://localhost:8983/solr/veNJOBDATA/'
rsolr
.
add
(
job_id:
id
,
job_name:
name
,
job_description:
description
)
rsolr
.
commit
end
end
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