affiliate_window_etl 0.0.2 → 0.0.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9608ebcbad9449f57193fc51055c6be2d8aabe0d
|
4
|
+
data.tar.gz: f4d7a27eb09a864bb4b7e7adf3dbfc7d3fc675f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 735481f591f4113b3e0f25364cf0f174698a908671b90b0ceac8a4d69a9af9794946c7171e298d6b0fc0676b0902b655cff93e67ff5f5ddb2b21538cb1a9b567
|
7
|
+
data.tar.gz: d5e2a0e4701a960f2c447dd4a3c7af41d2ba372d1bc74d646af061be289b79b84ccca5908f4e0765a5b9e75360d49b4341aa6e12b5e010fb47f13d03645a33e0
|
data/README.md
CHANGED
@@ -95,6 +95,9 @@ The stream to write debug output. Defaults to `stdout`.
|
|
95
95
|
|
96
96
|
Valid options are: `stdout`, `stderr` and `none`.
|
97
97
|
|
98
|
+
Optionally, you can initialize the ETL with a custom logger if you are using the
|
99
|
+
Ruby API.
|
100
|
+
|
98
101
|
## How to contribute
|
99
102
|
|
100
103
|
Bug reports and pull requests are welcome on
|
@@ -1,9 +1,10 @@
|
|
1
1
|
class AffiliateWindow
|
2
2
|
class ETL
|
3
|
-
attr_accessor :config
|
3
|
+
attr_accessor :config, :logger
|
4
4
|
|
5
|
-
def initialize(env: ENV)
|
5
|
+
def initialize(env: ENV, logger: nil)
|
6
6
|
self.config = Config.new(env: env)
|
7
|
+
self.logger = logger || config.logger
|
7
8
|
end
|
8
9
|
|
9
10
|
def run
|
@@ -40,7 +41,7 @@ class AffiliateWindow
|
|
40
41
|
def extracter
|
41
42
|
Extracter.new(
|
42
43
|
client: client,
|
43
|
-
|
44
|
+
logger: logger,
|
44
45
|
)
|
45
46
|
end
|
46
47
|
|
@@ -26,11 +26,12 @@ class AffiliateWindow
|
|
26
26
|
env.fetch("LAST_N_DAYS", "7").to_i
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
29
|
+
def logger
|
30
30
|
name = env.fetch("DEBUG_STREAM", "stdout")
|
31
31
|
name = name.downcase.to_sym
|
32
32
|
|
33
|
-
{ stdout: $stdout, stderr: $stderr, none: nil }.fetch(name)
|
33
|
+
stream = { stdout: $stdout, stderr: $stderr, none: nil }.fetch(name)
|
34
|
+
Logger.new(stream) if stream
|
34
35
|
end
|
35
36
|
end
|
36
37
|
end
|
@@ -3,11 +3,11 @@ class AffiliateWindow
|
|
3
3
|
class Extracter # rubocop:disable Metrics/ClassLength
|
4
4
|
CHUNK_SIZE = 100
|
5
5
|
|
6
|
-
attr_accessor :client, :
|
6
|
+
attr_accessor :client, :logger
|
7
7
|
|
8
|
-
def initialize(client:,
|
8
|
+
def initialize(client:, logger: nil)
|
9
9
|
self.client = client
|
10
|
-
self.
|
10
|
+
self.logger = logger
|
11
11
|
end
|
12
12
|
|
13
13
|
def extract(type, params = {})
|
@@ -181,9 +181,8 @@ class AffiliateWindow
|
|
181
181
|
end
|
182
182
|
|
183
183
|
def write(message)
|
184
|
-
return unless
|
185
|
-
|
186
|
-
output.puts(message_with_quota)
|
184
|
+
return unless logger
|
185
|
+
logger.debug { "[quota:#{client.remaining_quota}] #{message}" }
|
187
186
|
end
|
188
187
|
end
|
189
188
|
end
|