Commit b4bbde09 by Trịnh Hoàng Phúc

Merge branch 'feature/solr_management' into 'master'

Feature/solr management

See merge request !14
parents 2caeabd0 8450f8c6
Pipeline #592 canceled with stages
in 0 seconds
......@@ -25,6 +25,8 @@ gem 'bcrypt', '~> 3.1.7'
gem 'devise'
gem 'rsolr'
gem 'carrierwave'
gem 'activerecord-import'
......
......@@ -95,6 +95,8 @@ GEM
responders
warden (~> 1.2.3)
erubi (1.9.0)
faraday (1.0.1)
multipart-post (>= 1.2, < 3)
ffi (1.12.2)
ffi (1.12.2-java)
ffi (1.12.2-x64-mingw32)
......@@ -141,6 +143,7 @@ GEM
msgpack (1.3.3-java)
msgpack (1.3.3-x64-mingw32)
msgpack (1.3.3-x86-mingw32)
multipart-post (2.1.1)
mysql2 (0.5.3)
mysql2 (0.5.3-x64-mingw32)
mysql2 (0.5.3-x86-mingw32)
......@@ -206,6 +209,9 @@ GEM
responders (3.0.0)
actionpack (>= 5.0)
railties (>= 5.0)
rsolr (2.3.0)
builder (>= 2.1.2)
faraday (>= 0.9.0)
ruby-vips (2.0.17)
ffi (~> 1.9)
ruby_dep (1.5.0)
......@@ -298,6 +304,7 @@ DEPENDENCIES
pry
puma (~> 4.1)
rails (~> 6.0.2, >= 6.0.2.2)
rsolr
sass-rails (>= 6)
selenium-webdriver
settingslogic
......
require "rsolr"
namespace :solr do
desc "Solr management"
solr = RSolr.connect :url => "http://localhost:8983/solr/venjob"
task import: :environment do
job = Job.all
hash_jobs = job.map { |item|
salary = 0
min_salary = 0
max_salary = 0
{
job_id: item.id,
title: item.title,
updated_date_job: item.updated_date_job.nil? ? 0 : DateTime.parse(item.updated_date_job).to_i,
level: item.level,
years_of_experience: item.years_of_experience,
salary: salary,
min_salary: min_salary,
max_salary: max_salary,
expiration_date: item.expiration_date.nil? ? 0 : DateTime.parse(item.expiration_date).to_i,
job_description: item.job_description,
created_at: item.created_at.to_i,
industry_ids: item.industries.map { |industry| industry.id },
industry_names: item.industries.map { |industry| industry.title },
city_ids: item.cities.map { |city| city.id },
city_names: item.cities.map { |city| city.title },
company_id: item.company_id,
company_name: item.company.title,
company_address: item.company.address,
company_description: item.company.description,
company_logo: item.company.logo,
favorite_count: Favorite.where("job_id = ?", item.id).count,
apply_count: Apply.where("job_id = ?", item.id).count
}
}
solr.add hash_jobs
solr.commit
end
task delete_all: :environment do
solr.delete_by_query "*:*"
solr.commit
end
end
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