trueandco_analytics 0.4.10 → 0.4.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fef72a2fa99a4c541a73e17070841802585efe9d
4
- data.tar.gz: cb5413156e06f8a00b70bdb1f9947a86c22cf204
3
+ metadata.gz: 9c5e7362fdc8ee18d920be56be5a5239c29c945d
4
+ data.tar.gz: 6cbb35319c7ba3e65da8f2ac2c26cd1dde7c4b06
5
5
  SHA512:
6
- metadata.gz: 7376c24d0251350d458951104823150d897443d0a97000673a5042e8fc1acc9ba44ffc029466fc4cdc652815eb93f44540c017deb0552031764130a00d1fc7c2
7
- data.tar.gz: 1559c7b5dc3838a0435144274afc2676ae24b4c96dc0616fafef10d0113c59a1d9b8cc9f885a9d96951c8b7595f6c176824355e9ffb3f7355120b6f9a19c7568
6
+ metadata.gz: bc3a1b923e3fcbdc2de474dd751ddc2360139b07f712acbb643b8c57fb0ed08553881e355bbaaf31915f9b310adf03a450d38eb304287d284df46ea04005ff80
7
+ data.tar.gz: c1df04195b4ed047a2258933db51642a6060d072736bc632777952a8ea0dd7130c154a089f9b6534c080ccc0155719b92104fbc2c9636262bbc428e72c6a3df4
@@ -1,17 +1,19 @@
1
1
  #!/usr/bin/env ruby
2
2
  ENGINE_ROOT = File.expand_path('../..', __FILE__)
3
- CURRENT_PATH = Dir.pwd + '/'
3
+ CURRENT_PATH = Dir.pwd
4
4
 
5
5
  require 'bundler/setup'
6
6
  require 'i18n'
7
7
  require 'optparse'
8
8
  require 'fileutils'
9
+ require 'yaml'
9
10
  require 'active_record'
10
11
  require 'mysql2'
11
12
  require 'trueandco_analytics'
12
- require "#{CURRENT_PATH}config/initializers/trueandco_analytics"
13
+ require "#{CURRENT_PATH}/config/initializers/trueandco_analytics"
13
14
 
14
- connect_db = TrueandcoAnalytics::Config::Params.connect_db
15
+ current_db_mode = TrueandcoAnalytics::Config::Params.current_db_mode
16
+ connect_db = TrueandcoAnalytics::Database::GetCurrentConfig.new(current_db_mode, "#{CURRENT_PATH}/config/database.yml").execute
15
17
  1.times do
16
18
  break if connect_db.nil?
17
19
  ActiveRecord::Base.establish_connection(connect_db)
@@ -10,9 +10,8 @@ TrueandcoAnalytics.setup do |config|
10
10
 
11
11
  # Specify the database where redis will store the statistics for the session site
12
12
  config.connect_redis = {
13
- #url: "redis://your_host:6379",
13
+ url: "redis://localhost:6379/1",
14
14
  #redis_password: '',
15
- redis_db: 1
16
15
  }
17
16
 
18
17
  # Specify Sidekiq config
@@ -20,18 +19,9 @@ TrueandcoAnalytics.setup do |config|
20
19
  config.sidekiq_configure_server_url = 'redis://localhost:6379/1'
21
20
  config.sidekiq_configure_namespace = 'metric'
22
21
 
23
- #Log name in rails app
22
+ # Log name in rails app
24
23
  config.log = nil
25
24
 
26
- #Specify the database to use in console mode
27
- =begin
28
- config.connect_db = {
29
- adapter: :mysql2,
30
- database: 'development_db_name',
31
- username: 'ivan',
32
- password: '3443555',
33
- host: '127.0.0.1',
34
- port: 3306
35
- }
36
- =end
25
+ # Specify current database mode of config/database.yml to use in console mode
26
+ config.current_db_mode = 'development'
37
27
  end
@@ -20,8 +20,8 @@ module TrueandcoAnalytics
20
20
  @sidekiq_configure_namespace_check = false
21
21
  @log = nil
22
22
  @log_check = false
23
- @connect_db = nil
24
- @connect_db_check = false
23
+ @current_db_mode = nil
24
+ @current_db_mode_check = false
25
25
 
26
26
  class << self
27
27
 
@@ -42,12 +42,12 @@ module TrueandcoAnalytics
42
42
  end
43
43
 
44
44
  attr_reader :time_survey, :time_dead_session, :buy_selector,
45
- :sidekiq_configure_client_url, :sidekiq_configure_server_url, :sidekiq_configure_namespace,
46
- :connect_db, :connect_redis
47
-
45
+ :sidekiq_configure_client_url, :sidekiq_configure_server_url, :sidekiq_configure_namespace, :connect_redis,
46
+ :current_db_mode
47
+
48
48
  attr_writer_only_once :time_survey, :user_method,
49
- :sidekiq_configure_client_url, :sidekiq_configure_server_url, :sidekiq_configure_namespace,
50
- :connect_db, :connect_redis
49
+ :sidekiq_configure_client_url, :sidekiq_configure_server_url, :sidekiq_configure_namespace, :connect_redis,
50
+ :current_db_mode
51
51
 
52
52
  def buy_selector=(value)
53
53
  return if value.nil?
@@ -0,0 +1,20 @@
1
+ module TrueandcoAnalytics::Database
2
+ class GetCurrentConfig
3
+
4
+ def initialize(current_mode, path)
5
+ @current_mode = current_mode
6
+ @path = path
7
+ end
8
+
9
+ def execute
10
+ config = YAML.load_file(path)
11
+ config[current_mode]
12
+ rescue StandardError => e
13
+ return nil
14
+ end
15
+
16
+ private
17
+
18
+ attr_reader :current_mode, :path
19
+ end
20
+ end
@@ -7,7 +7,7 @@ module TrueandcoAnalytics::ReportC
7
7
  @format = format
8
8
  @datetime_start = datetime_start
9
9
  @datetime_end = datetime_end
10
- @path = path || CURRENT_PATH
10
+ @path = path || (CURRENT_PATH + '/')
11
11
  end
12
12
 
13
13
  def execute
@@ -1,3 +1,3 @@
1
1
  module TrueandcoAnalytics
2
- VERSION = '0.4.10'
2
+ VERSION = '0.4.11'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trueandco_analytics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.10
4
+ version: 0.4.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Moroz Ivan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-24 00:00:00.000000000 Z
11
+ date: 2017-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -204,6 +204,7 @@ files:
204
204
  - lib/trueandco_analytics/config/params.rb
205
205
  - lib/trueandco_analytics/console/cli/common.rb
206
206
  - lib/trueandco_analytics/console/cli/report.rb
207
+ - lib/trueandco_analytics/console/commands/database/get_current_config.rb
207
208
  - lib/trueandco_analytics/console/commands/report_c/generate.rb
208
209
  - lib/trueandco_analytics/console/extension_string.rb
209
210
  - lib/trueandco_analytics/engine.rb