holistics 0.3.4 → 0.3.5
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 +5 -5
- data/lib/holistics.rb +2 -0
- data/lib/holistics/version.rb +2 -2
- data/lib/import_chunking.rb +52 -0
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cab913239d13210e0e3c091b01bc3f9b61cdc78d
|
4
|
+
data.tar.gz: 53b64ba89eb7ffb7134b7b80c15948d291b75efe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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")
|
data/lib/holistics/version.rb
CHANGED
@@ -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
|
+
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:
|
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.
|
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: []
|