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
0
Merge Requests
0
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
Nguyen Ngoc Nghia
VeNJOB
Commits
2315b850
Commit
2315b850
authored
Feb 20, 2020
by
nnnghia98
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check if city/industry id valid
parent
a9f7ae86
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
11 deletions
+11
-11
app/services/solr_service.rb
+7
-7
lib/tasks/task.rake
+4
-4
No files found.
app/services/solr_service.rb
View file @
2315b850
require
"rsolr"
class
SolrService
def
initialize
(
search_keyword
)
def
initialize
(
search_keyword
=
{}
)
@solr
=
RSolr
.
connect
(
url:
Settings
.
solr
.
connection
.
server_url
,
read_timeout:
Settings
.
solr
.
connection
.
read_timeout
,
...
...
@@ -56,21 +56,21 @@ class SolrService
end
def
query_by_city
city
=
City
.
find
(
@search_keyword
)
city_name
=
city
.
name
city
=
City
.
find
_by
(
id:
@search_keyword
)
fq_city
=
city
?
"city:
#{
escape_str
(
city
.
name
)
}
"
:
""
q
=
"*:*"
fq
=
"city:
#{
escape_str
(
city_name
)
}
"
fq
=
fq_city
send_request
(
q
,
fq
)
end
def
query_by_industry
industry
=
Industry
.
find
(
@search_keyword
)
industry_name
=
industry
.
name
industry
=
Industry
.
find
_by
(
id:
@search_keyword
)
fq_industry
=
industry
?
"industry:
#{
escape_str
(
industry
.
name
)
}
"
:
""
q
=
"*:*"
fq
=
"industry:
#{
escape_str
(
industry_name
)
}
"
fq
=
fq_industry
send_request
(
q
,
fq
)
end
...
...
lib/tasks/task.rake
View file @
2315b850
...
...
@@ -13,15 +13,15 @@ namespace :solr do
task
solr_index: :environment
do
SolrService
.
new
.
add_data
solr_index_
data
=
ActiveSupport
::
Logger
.
new
(
"log/solr_service.log"
)
solr_index_
data
.
info
"Solr index data succesfully at
#{
Time
.
current
}
"
solr_index_
logger
=
ActiveSupport
::
Logger
.
new
(
"log/solr_service.log"
)
solr_index_
logger
.
info
"Solr index data succesfully at
#{
Time
.
current
}
"
end
desc
"solr delete data"
task
solr_delete: :environment
do
SolrService
.
new
.
delete_data
solr_delete_
data
=
ActiveSupport
::
Logger
.
new
(
"log/solr_service.log"
)
solr_delete_
data
.
info
"Solr delete all data succesfully at
#{
Time
.
current
}
"
solr_delete_
logger
=
ActiveSupport
::
Logger
.
new
(
"log/solr_service.log"
)
solr_delete_
logger
.
info
"Solr delete all data succesfully at
#{
Time
.
current
}
"
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