holistics 0.3.4 → 0.3.5

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
- SHA256:
3
- metadata.gz: 07bec8a025b674144e6fb6e35b9ef2c9a279e917e2187587d83a75e025f369c0
4
- data.tar.gz: abe49de6255090ee1c96898df73eeb25ee3cc88dd36eef7233901c12dbc87980
2
+ SHA1:
3
+ metadata.gz: cab913239d13210e0e3c091b01bc3f9b61cdc78d
4
+ data.tar.gz: 53b64ba89eb7ffb7134b7b80c15948d291b75efe
5
5
  SHA512:
6
- metadata.gz: d63c018afd38938a15be260b6ccdd63f3168d2ebba073789cba120cab1c52ea2fde9592061d580c1bfd5a166ca2662461bf16462d9b090b5fc1b951a86cec3ec
7
- data.tar.gz: 6cef3b620618a6bbc562bc3ec6ed55197036ec18ebefe3ddc1c78e01492695dc17f58906df85b2054ed73f1b7e049832a302d4a64c54e84f30e98a50ba16d1fa
6
+ metadata.gz: 89b361bb3763a3c89c59ffe4845d5f3b1625da74292fd6e19164dfb19ee1814566e9c8f246f7d7a753fb56a4e926c7894738099006dad0063f2c4dc1e1753925
7
+ data.tar.gz: f115d45d5baa6972a7d30d2b9610032aa39b924d1cf97c1ff98101cfc20e9ca8e6b640b5830245c77f39b1a2915e3c424ebdc40d3959eb7d68d90b8646eefa1c
data/lib/holistics.rb CHANGED
@@ -7,6 +7,7 @@ require 'holistics/custom_logger'
7
7
  require 'holistics/auth_api_client'
8
8
 
9
9
  require 'import'
10
+ require 'import_chunking'
10
11
  require 'transport'
11
12
  require 'transform'
12
13
  require 'data_sources'
@@ -44,6 +45,7 @@ module Holistics
44
45
  end
45
46
 
46
47
  register(Holistics::Import, 'import', 'import <command>', "Execute import commands")
48
+ register(Holistics::ImportChunking, 'import_chunking', 'import_chunking <command>', "Generate import chunks for date range imports")
47
49
  register(Holistics::Transport, 'transport', 'transport <command>', "Execute transport module's commands")
48
50
  register(Holistics::Transform, 'transform', 'transform <command>', "Execute transform module's commands")
49
51
  register(Holistics::DataSources, 'data_sources', 'data_sources <command>', "Execute data_sources module's commands")
@@ -1,4 +1,4 @@
1
1
  module Holistics
2
- VERSION = '0.3.4'
3
- DATE = '2018-08-24'
2
+ VERSION = '0.3.5'
3
+ DATE = '2021-04-19'
4
4
  end
@@ -0,0 +1,52 @@
1
+ require 'thor'
2
+ require 'colorize'
3
+ require 'time'
4
+
5
+ module Holistics
6
+ class ImportChunking < Thor
7
+
8
+
9
+ # Example
10
+ # holistics import_chunking execute -j 29283 --range-start 2020-8-01T00:00:00Z --range-end 2021-9-01T00:00:00Z --chunk-days 10
11
+
12
+
13
+ method_option :import_id, aliases: '-j', type: :string, required: true, desc: 'ID of import job to be executed'
14
+ method_option :range_start, aliases: '--range-start', type: :string, required: true, desc: 'start range'
15
+ method_option :range_end, aliases: '--range-end', type: :string, required: true, desc: 'end range'
16
+ method_option :chunk_days, aliases: '--chunk-days', type: :numeric, required: true, desc: 'The range in days of each import'
17
+
18
+ desc 'execute', 'Generate import chunks for a date range'
19
+ def execute
20
+ one_day = 86_400
21
+ chunk_duration = one_day * options[:chunk_days]
22
+
23
+ date_start = Time.parse(options[:range_start])
24
+ date_end = Time.parse(options[:range_end])
25
+
26
+ generated_result = []
27
+
28
+ current_time = date_start
29
+
30
+ while current_time < date_end
31
+ chunk_start = current_time
32
+ chunk_end = current_time + chunk_duration
33
+
34
+ generated_result << gen_command(options[:import_id],
35
+ chunk_start,
36
+ chunk_end < date_end ? chunk_end : date_end)
37
+
38
+ current_time += chunk_duration
39
+ end
40
+
41
+ puts generated_result.join(" && \\ \n")
42
+ end
43
+
44
+ private
45
+
46
+ def gen_command(id, range_start, range_end)
47
+ start_str = range_start.utc.iso8601
48
+ end_str = range_end.utc.iso8601
49
+ "holistics import execute -j #{id} --custom-range --range-start #{start_str} --range-end #{end_str}"
50
+ end
51
+ end
52
+ end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: holistics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thanh Dinh Khac
8
8
  - Huy Nguyen
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-08-24 00:00:00.000000000 Z
12
+ date: 2021-04-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -118,6 +118,7 @@ files:
118
118
  - lib/holistics/helpers/job_manager.rb
119
119
  - lib/holistics/version.rb
120
120
  - lib/import.rb
121
+ - lib/import_chunking.rb
121
122
  - lib/tabular_formatter.rb
122
123
  - lib/transform.rb
123
124
  - lib/transport.rb
@@ -126,7 +127,7 @@ homepage: http://rubygems.org/gems/holistics-cli
126
127
  licenses:
127
128
  - GPL
128
129
  metadata: {}
129
- post_install_message:
130
+ post_install_message:
130
131
  rdoc_options: []
131
132
  require_paths:
132
133
  - lib
@@ -142,9 +143,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
143
  - !ruby/object:Gem::Version
143
144
  version: '0'
144
145
  requirements: []
145
- rubyforge_project:
146
- rubygems_version: 2.7.7
147
- signing_key:
146
+ rubyforge_project:
147
+ rubygems_version: 2.5.1
148
+ signing_key:
148
149
  specification_version: 4
149
150
  summary: CLI interface for Holistics
150
151
  test_files: []