sc_analytics 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 174fbe2000c4f79d76fc86330eac07a14d9f4807
4
- data.tar.gz: 51f8eb358ef21862d6ae311e0c8bc45671e45045
3
+ metadata.gz: ad7b46ef538fe53b0f49427d9a463c01974219a6
4
+ data.tar.gz: f04a324d58419b59e5e71d6476cba83db1c12ee6
5
5
  SHA512:
6
- metadata.gz: 3ae18c5a68627339343f6d15c6076c161d30dfe87bf98a656a76cd1fc0c01d094a35ec011fbe17b2e242aa0114676a82bc745a9953277bfe960b9ec5b2fc3f19
7
- data.tar.gz: 101e0b4cb37f6cda59b7131ee7ac536f1132677f5cb339796ea0f865a3dd8c8e2bdde37668260680e5a492377a0091fed783ef8dd4c4793c8956e3ef65f48f4e
6
+ metadata.gz: ee4936d4feb370c7a9787b6a4634ad94e1b791cd4d3e43c253d526ee8ab820f76e167bbdf9098b3e72d7310d6cb72f7e109343ff2796e6d35606ea9fd2a49e35
7
+ data.tar.gz: fc16d994afc77015de624ccd7b01989b207d5ffcf660ea8d2c9105c51c580b2e9d5d216a4ec648fd7b784c97ca19cca7ef1e8ad16ba05e515c6391134275978e
@@ -3,7 +3,7 @@ module SCAnalytics
3
3
  class Query
4
4
  require 'erb'
5
5
 
6
- attr_reader :connection, :results, :query_name, :bind_variables, :csv_file, :combined_csv_file, :csv_dir, :csv_combined_dir, :cursor, :columns_to_cast, :start_time, :end_time
6
+ attr_reader :connection, :threads, :results, :query_name, :bind_variables, :csv_file, :combined_csv_file, :csv_dir, :csv_combined_dir, :cursor, :columns_to_cast, :start_time, :end_time
7
7
  attr_accessor :sql, :database, :auto_cast, :concurrent
8
8
  alias_method :result, :results
9
9
  alias_method :name, :query_name
@@ -233,7 +233,7 @@ module SCAnalytics
233
233
  end
234
234
 
235
235
  def suggest_dir(file_name, dir)
236
- return file_name unless File.dirname(file_name) == "."
236
+ return file_name unless File.dirname(file_name) == "." && dir != "."
237
237
 
238
238
  FileUtils.mkdir_p(dir.to_s)
239
239
  "#{dir}/" + file_name
@@ -255,23 +255,15 @@ module SCAnalytics
255
255
  @start_time = Time.now
256
256
 
257
257
  results = {}
258
- threads = []
259
- @tines.each_value do |query|
260
- threads << Thread.new do
261
- Thread.stop
262
- query.run
263
- results[query.database.first] = query.results
258
+ @threads = {}
259
+ @tines.each_pair do |db, query|
260
+ @threads[db] = Thread.new(query) do |qry|
261
+ qry.run
262
+ results[qry.database.first] = qry.results
264
263
  end
265
264
  end
266
265
 
267
- threads.each{|thread| until thread.stop?; end}
268
-
269
- threads.each do |thread|
270
- thread.run
271
- thread.join if @concurrent == false
272
- end
273
-
274
- threads.each{|thread| thread.join }
266
+ @threads.each_value{|thread| thread.join }
275
267
 
276
268
  @end_time = Time.now
277
269
  return results
@@ -1,3 +1,3 @@
1
1
  module SCAnalytics
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/sc_analytics.rb CHANGED
@@ -8,6 +8,7 @@ require 'fileutils'
8
8
  require 'csv'
9
9
  require 'win32ole'
10
10
  require 'thread'
11
+ Thread.abort_on_exception = true
11
12
 
12
13
  begin
13
14
  # for development environment
@@ -27,8 +28,8 @@ module SCAnalytics
27
28
 
28
29
  threads = []
29
30
  queries.each do |query|
30
- threads << Thread.new do
31
- query.run
31
+ threads << Thread.new(query) do |qry|
32
+ qry.run
32
33
  end
33
34
  end
34
35
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sc_analytics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Rowan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-30 00:00:00.000000000 Z
11
+ date: 2015-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -91,7 +91,6 @@ files:
91
91
  - README.md
92
92
  - Rakefile
93
93
  - bin/console
94
- - bin/run_report.rb
95
94
  - bin/setup
96
95
  - example/db_configs_sample.yml
97
96
  - lib/sc_analytics.rb
data/bin/run_report.rb DELETED
@@ -1,22 +0,0 @@
1
- require 'sc_analytics'
2
- include SCAnalytics
3
-
4
- report = ARGV[0]
5
- unless report
6
- puts "Please enter the name of the report you wish to run"
7
- report = STDIN.gets.strip
8
- raise unless report
9
- end
10
-
11
- *report_path, report_name = report.split("/")
12
- report_name = report_name.sub(/(\.rb)*$/, ".rb")
13
-
14
- puts
15
- job_start = alert("BEGINNING JOB #{report_name.gsub(/\.rb$/,'')}")
16
-
17
- Dir.chdir(report_path.join("/")) unless report_path.empty?
18
-
19
- instructions = File.read(report_name)
20
- SCAnalytics.instance_eval(instructions, report_name)
21
-
22
- alert("COMPLETED JOB #{report_name} in #{(Time.now - job_start)/60} minutes")