Commit ced8b073 by Hoang Phuc Do

Merge branch 'bk_dhp_solr' into dhp_solr

# Conflicts:
#	Gemfile
#	app/controllers/product_items_controller.rb
#	app/helpers/carts_helper.rb
#	app/services/cart.rb
parents efca5cdb 3873645b
...@@ -23,3 +23,6 @@ ...@@ -23,3 +23,6 @@
# Ignore database config file # Ignore database config file
/config/database.yml /config/database.yml
config/settings.local.yml
config/settings/*.local.yml
config/environments/*.local.yml
...@@ -76,7 +76,11 @@ GEM ...@@ -76,7 +76,11 @@ GEM
execjs execjs
coffee-script-source (1.12.2) coffee-script-source (1.12.2)
concurrent-ruby (1.0.5) concurrent-ruby (1.0.5)
config (1.4.0)
activesupport (>= 3.0)
deep_merge (~> 1.1.1)
connection_pool (2.2.1) connection_pool (2.2.1)
deep_merge (1.1.1)
devise (4.3.0) devise (4.3.0)
bcrypt (~> 3.0) bcrypt (~> 3.0)
orm_adapter (~> 0.1) orm_adapter (~> 0.1)
...@@ -87,6 +91,8 @@ GEM ...@@ -87,6 +91,8 @@ GEM
execjs (2.7.0) execjs (2.7.0)
faker (1.6.6) faker (1.6.6)
i18n (~> 0.5) i18n (~> 0.5)
faraday (0.12.1)
multipart-post (>= 1.2, < 3)
ffi (1.9.18) ffi (1.9.18)
font-awesome-rails (4.7.0.2) font-awesome-rails (4.7.0.2)
railties (>= 3.2, < 5.2) railties (>= 3.2, < 5.2)
...@@ -132,6 +138,7 @@ GEM ...@@ -132,6 +138,7 @@ GEM
mini_portile2 (2.2.0) mini_portile2 (2.2.0)
minitest (5.10.2) minitest (5.10.2)
multi_json (1.12.1) multi_json (1.12.1)
multipart-post (2.0.0)
mysql2 (0.4.6) mysql2 (0.4.6)
nio4r (2.1.0) nio4r (2.1.0)
nokogiri (1.8.0) nokogiri (1.8.0)
...@@ -187,6 +194,9 @@ GEM ...@@ -187,6 +194,9 @@ GEM
responders (2.4.0) responders (2.4.0)
actionpack (>= 4.2.0, < 5.3) actionpack (>= 4.2.0, < 5.3)
railties (>= 4.2.0, < 5.3) railties (>= 4.2.0, < 5.3)
rsolr (2.0.2)
builder (>= 2.1.2)
faraday
rubocop (0.49.1) rubocop (0.49.1)
parallel (~> 1.10) parallel (~> 1.10)
parser (>= 2.3.3.1, < 3.0) parser (>= 2.3.3.1, < 3.0)
...@@ -262,6 +272,7 @@ DEPENDENCIES ...@@ -262,6 +272,7 @@ DEPENDENCIES
capybara (~> 2.13) capybara (~> 2.13)
carrierwave (~> 1.0) carrierwave (~> 1.0)
coffee-rails (~> 4.2) coffee-rails (~> 4.2)
config
devise (~> 4.3) devise (~> 4.3)
faker (~> 1.6, >= 1.6.3) faker (~> 1.6, >= 1.6.3)
font-awesome-rails (~> 4.7, >= 4.7.0.2) font-awesome-rails (~> 4.7, >= 4.7.0.2)
...@@ -275,6 +286,7 @@ DEPENDENCIES ...@@ -275,6 +286,7 @@ DEPENDENCIES
puma (~> 3.7) puma (~> 3.7)
rails (~> 5.1.1) rails (~> 5.1.1)
rails-assets-bootstrap-touchspin! rails-assets-bootstrap-touchspin!
rsolr (~> 2.0, >= 2.0.2)
rubocop (~> 0.49.1) rubocop (~> 0.49.1)
sass-rails (~> 5.0) sass-rails (~> 5.0)
selenium-webdriver selenium-webdriver
......
require 'rsolr'
class SolrSearch
attr_accessor :rsolr
def initialize
@rsolr = RSolr.connect url: Settings.rsolr.address
end
end
\ No newline at end of file
Config.setup do |config|
# Name of the constant exposing loaded settings
config.const_name = 'Settings'
# Ability to remove elements of the array set in earlier loaded settings file. For example value: '--'.
#
# config.knockout_prefix = nil
# Overwrite arrays found in previously loaded settings file. When set to `false`, arrays will be merged.
#
# config.overwrite_arrays = true
# Load environment variables from the `ENV` object and override any settings defined in files.
#
# config.use_env = false
# Define ENV variable prefix deciding which variables to load into config.
#
# config.env_prefix = 'Settings'
# What string to use as level separator for settings loaded from ENV variables. Default value of '.' works well
# with Heroku, but you might want to change it for example for '__' to easy override settings from command line, where
# using dots in variable names might not be allowed (eg. Bash).
#
# config.env_separator = '.'
# Ability to process variables names:
# * nil - no change
# * :downcase - convert to lower case
#
# config.env_converter = :downcase
# Parse numeric values as integers instead of strings.
#
# config.env_parse_values = true
end
# RSolr
rsolr:
address: http://localhost:8983/solr/dhp_venshop
\ No newline at end of file
namespace :import_solr_data do
desc "Import product data from database"
task product: :environment do
documents = []
Product.all.each do |product|
documents << { id: product.id, title: product.title, price: product.price }
end
solr_search = SolrSearch.new
solr_search.rsolr.add documents
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