Commit 2550b768 by Tô Ngọc Ánh

add config gem

parent 4fa29101
Pipeline #1055 canceled with stages
in 0 seconds
...@@ -30,3 +30,7 @@ ...@@ -30,3 +30,7 @@
/public/uploads/ /public/uploads/
.env .env
config/settings.local.yml
config/settings/*.local.yml
config/environments/*.local.yml
...@@ -71,4 +71,5 @@ gem 'kaminari' ...@@ -71,4 +71,5 @@ gem 'kaminari'
gem 'devise' gem 'devise'
gem 'carrierwave', '~> 2.0' gem 'carrierwave', '~> 2.0'
gem 'rsolr' gem 'rsolr'
gem 'config'
## ##
...@@ -81,7 +81,11 @@ GEM ...@@ -81,7 +81,11 @@ GEM
execjs execjs
coffee-script-source (1.12.2) coffee-script-source (1.12.2)
concurrent-ruby (1.1.6) concurrent-ruby (1.1.6)
config (2.2.1)
deep_merge (~> 1.2, >= 1.2.1)
dry-validation (~> 1.0, >= 1.0.0)
crass (1.0.6) crass (1.0.6)
deep_merge (1.2.1)
devise (4.7.1) devise (4.7.1)
bcrypt (~> 3.0) bcrypt (~> 3.0)
orm_adapter (~> 0.1) orm_adapter (~> 0.1)
...@@ -92,6 +96,44 @@ GEM ...@@ -92,6 +96,44 @@ GEM
dotenv-rails (2.7.6) dotenv-rails (2.7.6)
dotenv (= 2.7.6) dotenv (= 2.7.6)
railties (>= 3.2) railties (>= 3.2)
dry-configurable (0.11.6)
concurrent-ruby (~> 1.0)
dry-core (~> 0.4, >= 0.4.7)
dry-equalizer (~> 0.2)
dry-container (0.7.2)
concurrent-ruby (~> 1.0)
dry-configurable (~> 0.1, >= 0.1.3)
dry-core (0.4.9)
concurrent-ruby (~> 1.0)
dry-equalizer (0.3.0)
dry-inflector (0.2.0)
dry-initializer (3.0.3)
dry-logic (1.0.7)
concurrent-ruby (~> 1.0)
dry-core (~> 0.2)
dry-equalizer (~> 0.2)
dry-schema (1.5.3)
concurrent-ruby (~> 1.0)
dry-configurable (~> 0.8, >= 0.8.3)
dry-core (~> 0.4)
dry-equalizer (~> 0.2)
dry-initializer (~> 3.0)
dry-logic (~> 1.0)
dry-types (~> 1.4)
dry-types (1.4.0)
concurrent-ruby (~> 1.0)
dry-container (~> 0.3)
dry-core (~> 0.4, >= 0.4.4)
dry-equalizer (~> 0.3)
dry-inflector (~> 0.1, >= 0.1.2)
dry-logic (~> 1.0, >= 1.0.2)
dry-validation (1.5.4)
concurrent-ruby (~> 1.0)
dry-container (~> 0.7, >= 0.7.1)
dry-core (~> 0.4)
dry-equalizer (~> 0.2)
dry-initializer (~> 3.0)
dry-schema (~> 1.5)
erubi (1.9.0) erubi (1.9.0)
execjs (2.7.0) execjs (2.7.0)
faraday (1.0.1) faraday (1.0.1)
...@@ -247,6 +289,7 @@ DEPENDENCIES ...@@ -247,6 +289,7 @@ DEPENDENCIES
carrierwave (~> 2.0) carrierwave (~> 2.0)
chromedriver-helper chromedriver-helper
coffee-rails (~> 4.2) coffee-rails (~> 4.2)
config
devise devise
dotenv-rails dotenv-rails
jbuilder (~> 2.5) jbuilder (~> 2.5)
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<div class='content'> <div class='content'>
<% if @jobs.any? %> <% if @jobs.any? %>
<div class='message text-center'> <div class='message text-center'>
<h3>We found <%= pluralize(@jobs.total_count, 'result') %> for <strong><%= @keyword %></strong> </h3> <h4>We found <%= pluralize(@jobs.total_count, 'result') %> for <strong><%= @keyword %></strong> </h4>
</div> </div>
<hr> <hr>
<%= paginate @jobs %> <%= paginate @jobs %>
......
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 an existing value when merging a `nil` value.
# When set to `false`, the existing value is retained after merge.
#
# config.merge_nil_values = true
# 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.
#
# Reading variables from ENV is case-sensitive. If you define lowercase value below, ensure your ENV variables are
# prefixed in the same way.
#
# When not set it defaults to `config.const_name`.
#
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
# Validate presence and type of specific config values. Check https://github.com/dry-rb/dry-validation for details.
#
# config.schema do
# required(:name).filled
# required(:age).maybe(:int?)
# required(:email).filled(format?: EMAIL_REGEX)
# end
end
solr_server: 'http://192.168.1.133:8983/solr/venjob'
class SolrServer class SolrServer
def initialize def initialize
@solr = RSolr.connect(url: 'http://192.168.1.133:8983/solr/venjob') @solr = RSolr.connect(url: Settings.solr_server)
end end
def search(keyword, industry_id, location_id, page) def search(keyword, industry_id, location_id, page)
......
# require './lib/common/solr_server'
# namespace :solr do
# desc 'reindex data'
# task reindex: :environment do
# solr = SolrServer.new
# solr.delete_by_query '*:*'
# jobs = Job.includes(:company, :industries, :locations)
# documents = []
# jobs.each_with_index do |job, index|
# documents[index] = {
# id: job.id,
# title: job.title,
# description: job.description,
# salary: job.salary,
# company: job.company.name,
# industry_ids: job.industries.map(&:id),
# industries: job.industries.map(&:name),
# location_ids: job.locations.map(&:id),
# locations: job.locations.map(&:city)
# }
# end
# solr.add documents, add_attributes: {commitWithin: 10}
# 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