embulk-input-google_analytics 0.1.15 → 0.1.16.alpha.1
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: 93dac5ab48493c13dac60d7640cd9588942858a0
|
4
|
+
data.tar.gz: f3a71a84eea8e0f0933d225d5f66da21fa30b857
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f866865ba1a2e5318c490d6274377d8ccafa5394404f62045dca9d5f7845bedc65da83d921b4c9bd4298c424fe59702ea04a6d7da525ef220f894d5eba240d4d
|
7
|
+
data.tar.gz: 106bbd9f7822f76de17ea8ba33fd3fa1817b05ace656dc5d6f6d1329f7342feecaf382a7c475c0554424618d1925aeaa78ffccd66f4505dd8f3645db38c425e7
|
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
Gem::Specification.new do |spec|
|
3
3
|
spec.name = "embulk-input-google_analytics"
|
4
|
-
spec.version = "0.1.
|
4
|
+
spec.version = "0.1.16.alpha.1"
|
5
5
|
spec.authors = ["uu59"]
|
6
6
|
spec.summary = "Google Analytics input plugin for Embulk"
|
7
7
|
spec.description = "Loads records from Google Analytics."
|
@@ -127,7 +127,7 @@ module Embulk
|
|
127
127
|
end
|
128
128
|
|
129
129
|
if task["incremental"]
|
130
|
-
calculate_next_times(latest_time_series)
|
130
|
+
calculate_next_times(client.get_profile[:timezone], latest_time_series)
|
131
131
|
else
|
132
132
|
{}
|
133
133
|
end
|
@@ -139,11 +139,12 @@ module Embulk
|
|
139
139
|
false
|
140
140
|
end
|
141
141
|
|
142
|
-
def calculate_next_times(fetched_latest_time)
|
142
|
+
def calculate_next_times(client_time_zone, fetched_latest_time)
|
143
143
|
task_report = {}
|
144
|
-
|
145
144
|
if fetched_latest_time
|
146
|
-
|
145
|
+
# Convert fetched_last_time to user timezone
|
146
|
+
timezone = ActiveSupport::TimeZone[client_time_zone]
|
147
|
+
task_report[:start_date] = timezone.nil? ? fetched_latest_time.strftime("%Y-%m-%d") : timezone.parse(fetched_latest_time.to_s).strftime("%Y-%m-%d")
|
147
148
|
|
148
149
|
# if end_date specified as statically YYYY-MM-DD, it will be conflict with start_date (end_date < start_date)
|
149
150
|
# Or when end_date is nil, only start_date will be filled on next run but it is illegal API request.
|
@@ -2,6 +2,7 @@ require "embulk"
|
|
2
2
|
Embulk.setup
|
3
3
|
|
4
4
|
require "embulk/input/google_analytics"
|
5
|
+
require "active_support/core_ext/time"
|
5
6
|
require "override_assert_raise"
|
6
7
|
require "fixture_helper"
|
7
8
|
|
@@ -11,7 +12,7 @@ module Embulk
|
|
11
12
|
class TestPlugin < Test::Unit::TestCase
|
12
13
|
include OverrideAssertRaise
|
13
14
|
include FixtureHelper
|
14
|
-
|
15
|
+
DEFAULT_TIMEZONE = "America/Los_Angeles"
|
15
16
|
sub_test_case ".transaction" do
|
16
17
|
setup do
|
17
18
|
any_instance_of(Client) do |klass|
|
@@ -266,6 +267,7 @@ module Embulk
|
|
266
267
|
|
267
268
|
sub_test_case "calculate_next_times" do
|
268
269
|
setup do
|
270
|
+
@timeparser = ActiveSupport::TimeZone["UTC"]
|
269
271
|
@page_builder = Object.new
|
270
272
|
@config = embulk_config(valid_config["in"])
|
271
273
|
end
|
@@ -285,7 +287,7 @@ module Embulk
|
|
285
287
|
end_date: task["end_date"],
|
286
288
|
last_record_time: task["last_record_time"],
|
287
289
|
}
|
288
|
-
assert_equal expected, plugin.calculate_next_times(nil)
|
290
|
+
assert_equal expected, plugin.calculate_next_times(DEFAULT_TIMEZONE, nil)
|
289
291
|
end
|
290
292
|
end
|
291
293
|
|
@@ -297,14 +299,32 @@ module Embulk
|
|
297
299
|
end
|
298
300
|
|
299
301
|
test "config_diff will modify" do
|
300
|
-
latest_time =
|
302
|
+
latest_time = parse_time("2000-01-07")
|
303
|
+
plugin = Plugin.new(config, nil, nil, @page_builder)
|
304
|
+
expected = {
|
305
|
+
start_date: "2000-01-06",
|
306
|
+
end_date: "today",
|
307
|
+
last_record_time: latest_time.strftime("%Y-%m-%d %H:%M:%S %z"),
|
308
|
+
}
|
309
|
+
assert_equal expected, plugin.calculate_next_times(DEFAULT_TIMEZONE, latest_time)
|
310
|
+
end
|
311
|
+
end
|
312
|
+
sub_test_case "system timezone is 1 day behind profile timezone" do
|
313
|
+
setup do
|
314
|
+
@config[:start_date] = "2000-01-01"
|
315
|
+
@config[:end_date] = "2000-01-05"
|
316
|
+
@timeparser = ActiveSupport::TimeZone["Asia/Ho_Chi_Minh"]
|
317
|
+
end
|
318
|
+
|
319
|
+
test "config_diff will modify with end date set to correct timezone" do
|
320
|
+
latest_time = parse_time("2000-01-07 00:00:00")
|
301
321
|
plugin = Plugin.new(config, nil, nil, @page_builder)
|
302
322
|
expected = {
|
303
|
-
start_date:
|
323
|
+
start_date: "2000-01-06",
|
304
324
|
end_date: "today",
|
305
325
|
last_record_time: latest_time.strftime("%Y-%m-%d %H:%M:%S %z"),
|
306
326
|
}
|
307
|
-
assert_equal expected, plugin.calculate_next_times(latest_time)
|
327
|
+
assert_equal expected, plugin.calculate_next_times(DEFAULT_TIMEZONE, latest_time)
|
308
328
|
end
|
309
329
|
end
|
310
330
|
|
@@ -315,14 +335,14 @@ module Embulk
|
|
315
335
|
end
|
316
336
|
|
317
337
|
test "config_diff end_date won't modify" do
|
318
|
-
latest_time =
|
338
|
+
latest_time = parse_time("2000-01-07")
|
319
339
|
plugin = Plugin.new(config, nil, nil, @page_builder)
|
320
340
|
expected = {
|
321
|
-
start_date:
|
341
|
+
start_date: "2000-01-06",
|
322
342
|
end_date: @config[:end_date],
|
323
343
|
last_record_time: latest_time.strftime("%Y-%m-%d %H:%M:%S %z"),
|
324
344
|
}
|
325
|
-
assert_equal expected, plugin.calculate_next_times(latest_time)
|
345
|
+
assert_equal expected, plugin.calculate_next_times(DEFAULT_TIMEZONE, latest_time)
|
326
346
|
end
|
327
347
|
end
|
328
348
|
end
|
@@ -343,7 +363,7 @@ module Embulk
|
|
343
363
|
end_date: task["end_date"],
|
344
364
|
last_record_time: task["last_record_time"],
|
345
365
|
}
|
346
|
-
assert_equal expected, plugin.calculate_next_times(nil)
|
366
|
+
assert_equal expected, plugin.calculate_next_times(DEFAULT_TIMEZONE, nil)
|
347
367
|
end
|
348
368
|
end
|
349
369
|
|
@@ -355,15 +375,27 @@ module Embulk
|
|
355
375
|
end
|
356
376
|
|
357
377
|
test "config_diff will modify" do
|
358
|
-
latest_time =
|
378
|
+
latest_time = parse_time("2000-01-07")
|
359
379
|
plugin = Plugin.new(config, nil, nil, @page_builder)
|
360
380
|
expected = {
|
361
|
-
start_date:
|
381
|
+
start_date: "2000-01-06",
|
362
382
|
end_date: "today",
|
363
383
|
last_record_time: latest_time.strftime("%Y-%m-%d %H:%M:%S %z"),
|
364
384
|
}
|
365
|
-
assert_equal expected, plugin.calculate_next_times(latest_time)
|
385
|
+
assert_equal expected, plugin.calculate_next_times(DEFAULT_TIMEZONE, latest_time)
|
366
386
|
end
|
387
|
+
|
388
|
+
test "config_diff will modify" do
|
389
|
+
latest_time = parse_time("2000-01-07")
|
390
|
+
plugin = Plugin.new(config, nil, nil, @page_builder)
|
391
|
+
expected = {
|
392
|
+
start_date: "2000-01-06",
|
393
|
+
end_date: "today",
|
394
|
+
last_record_time: latest_time.strftime("%Y-%m-%d %H:%M:%S %z"),
|
395
|
+
}
|
396
|
+
assert_equal expected, plugin.calculate_next_times(DEFAULT_TIMEZONE, latest_time)
|
397
|
+
end
|
398
|
+
|
367
399
|
end
|
368
400
|
|
369
401
|
sub_test_case "end_date is nil" do
|
@@ -373,14 +405,14 @@ module Embulk
|
|
373
405
|
end
|
374
406
|
|
375
407
|
test "config_diff will modify" do
|
376
|
-
latest_time =
|
408
|
+
latest_time = parse_time("2000-01-07")
|
377
409
|
plugin = Plugin.new(config, nil, nil, @page_builder)
|
378
410
|
expected = {
|
379
|
-
start_date:
|
411
|
+
start_date: "2000-01-06",
|
380
412
|
end_date: "today",
|
381
413
|
last_record_time: latest_time.strftime("%Y-%m-%d %H:%M:%S %z"),
|
382
414
|
}
|
383
|
-
assert_equal expected, plugin.calculate_next_times(latest_time)
|
415
|
+
assert_equal expected, plugin.calculate_next_times(DEFAULT_TIMEZONE, latest_time)
|
384
416
|
end
|
385
417
|
end
|
386
418
|
|
@@ -391,14 +423,14 @@ module Embulk
|
|
391
423
|
end
|
392
424
|
|
393
425
|
test "config_diff end_date won't modify" do
|
394
|
-
latest_time =
|
426
|
+
latest_time = parse_time("2000-01-07")
|
395
427
|
plugin = Plugin.new(config, nil, nil, @page_builder)
|
396
428
|
expected = {
|
397
|
-
start_date:
|
429
|
+
start_date: "2000-01-06",
|
398
430
|
end_date: @config[:end_date],
|
399
431
|
last_record_time: latest_time.strftime("%Y-%m-%d %H:%M:%S %z"),
|
400
432
|
}
|
401
|
-
assert_equal expected, plugin.calculate_next_times(latest_time)
|
433
|
+
assert_equal expected, plugin.calculate_next_times(DEFAULT_TIMEZONE, latest_time)
|
402
434
|
end
|
403
435
|
end
|
404
436
|
end
|
@@ -411,6 +443,11 @@ module Embulk
|
|
411
443
|
def config
|
412
444
|
@config
|
413
445
|
end
|
446
|
+
|
447
|
+
def parse_time(time_string)
|
448
|
+
@timeparser.parse(time_string)
|
449
|
+
end
|
450
|
+
|
414
451
|
end
|
415
452
|
|
416
453
|
def valid_config
|
metadata
CHANGED
@@ -1,211 +1,211 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-input-google_analytics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.16.alpha.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- uu59
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: httpclient
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
16
15
|
requirements:
|
17
16
|
- - ">="
|
18
17
|
- !ruby/object:Gem::Version
|
19
18
|
version: '0'
|
19
|
+
name: httpclient
|
20
|
+
prerelease: false
|
21
|
+
type: :runtime
|
20
22
|
version_requirements: !ruby/object:Gem::Requirement
|
21
23
|
requirements:
|
22
24
|
- - ">="
|
23
25
|
- !ruby/object:Gem::Version
|
24
26
|
version: '0'
|
25
|
-
prerelease: false
|
26
|
-
type: :runtime
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: google-api-client
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
30
29
|
requirements:
|
31
30
|
- - '='
|
32
31
|
- !ruby/object:Gem::Version
|
33
32
|
version: 0.10.1
|
33
|
+
name: google-api-client
|
34
|
+
prerelease: false
|
35
|
+
type: :runtime
|
34
36
|
version_requirements: !ruby/object:Gem::Requirement
|
35
37
|
requirements:
|
36
38
|
- - '='
|
37
39
|
- !ruby/object:Gem::Version
|
38
40
|
version: 0.10.1
|
39
|
-
prerelease: false
|
40
|
-
type: :runtime
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: signet
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
44
43
|
requirements:
|
45
44
|
- - ">="
|
46
45
|
- !ruby/object:Gem::Version
|
47
46
|
version: '0'
|
47
|
+
name: signet
|
48
|
+
prerelease: false
|
49
|
+
type: :runtime
|
48
50
|
version_requirements: !ruby/object:Gem::Requirement
|
49
51
|
requirements:
|
50
52
|
- - ">="
|
51
53
|
- !ruby/object:Gem::Version
|
52
54
|
version: '0'
|
53
|
-
prerelease: false
|
54
|
-
type: :runtime
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name: activesupport
|
57
56
|
requirement: !ruby/object:Gem::Requirement
|
58
57
|
requirements:
|
59
58
|
- - ">="
|
60
59
|
- !ruby/object:Gem::Version
|
61
60
|
version: '0'
|
61
|
+
name: activesupport
|
62
|
+
prerelease: false
|
63
|
+
type: :runtime
|
62
64
|
version_requirements: !ruby/object:Gem::Requirement
|
63
65
|
requirements:
|
64
66
|
- - ">="
|
65
67
|
- !ruby/object:Gem::Version
|
66
68
|
version: '0'
|
67
|
-
prerelease: false
|
68
|
-
type: :runtime
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name: perfect_retry
|
71
70
|
requirement: !ruby/object:Gem::Requirement
|
72
71
|
requirements:
|
73
72
|
- - "~>"
|
74
73
|
- !ruby/object:Gem::Version
|
75
74
|
version: '0.5'
|
75
|
+
name: perfect_retry
|
76
|
+
prerelease: false
|
77
|
+
type: :runtime
|
76
78
|
version_requirements: !ruby/object:Gem::Requirement
|
77
79
|
requirements:
|
78
80
|
- - "~>"
|
79
81
|
- !ruby/object:Gem::Version
|
80
82
|
version: '0.5'
|
81
|
-
prerelease: false
|
82
|
-
type: :runtime
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name: embulk
|
85
84
|
requirement: !ruby/object:Gem::Requirement
|
86
85
|
requirements:
|
87
86
|
- - ">="
|
88
87
|
- !ruby/object:Gem::Version
|
89
88
|
version: 0.8.9
|
89
|
+
name: embulk
|
90
|
+
prerelease: false
|
91
|
+
type: :development
|
90
92
|
version_requirements: !ruby/object:Gem::Requirement
|
91
93
|
requirements:
|
92
94
|
- - ">="
|
93
95
|
- !ruby/object:Gem::Version
|
94
96
|
version: 0.8.9
|
95
|
-
prerelease: false
|
96
|
-
type: :development
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name: bundler
|
99
98
|
requirement: !ruby/object:Gem::Requirement
|
100
99
|
requirements:
|
101
100
|
- - ">="
|
102
101
|
- !ruby/object:Gem::Version
|
103
102
|
version: 1.10.6
|
103
|
+
name: bundler
|
104
|
+
prerelease: false
|
105
|
+
type: :development
|
104
106
|
version_requirements: !ruby/object:Gem::Requirement
|
105
107
|
requirements:
|
106
108
|
- - ">="
|
107
109
|
- !ruby/object:Gem::Version
|
108
110
|
version: 1.10.6
|
109
|
-
prerelease: false
|
110
|
-
type: :development
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name: rake
|
113
112
|
requirement: !ruby/object:Gem::Requirement
|
114
113
|
requirements:
|
115
114
|
- - ">="
|
116
115
|
- !ruby/object:Gem::Version
|
117
116
|
version: '10.0'
|
117
|
+
name: rake
|
118
|
+
prerelease: false
|
119
|
+
type: :development
|
118
120
|
version_requirements: !ruby/object:Gem::Requirement
|
119
121
|
requirements:
|
120
122
|
- - ">="
|
121
123
|
- !ruby/object:Gem::Version
|
122
124
|
version: '10.0'
|
123
|
-
prerelease: false
|
124
|
-
type: :development
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name: test-unit
|
127
126
|
requirement: !ruby/object:Gem::Requirement
|
128
127
|
requirements:
|
129
128
|
- - ">="
|
130
129
|
- !ruby/object:Gem::Version
|
131
130
|
version: '0'
|
131
|
+
name: test-unit
|
132
|
+
prerelease: false
|
133
|
+
type: :development
|
132
134
|
version_requirements: !ruby/object:Gem::Requirement
|
133
135
|
requirements:
|
134
136
|
- - ">="
|
135
137
|
- !ruby/object:Gem::Version
|
136
138
|
version: '0'
|
137
|
-
prerelease: false
|
138
|
-
type: :development
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
|
-
name: test-unit-rr
|
141
140
|
requirement: !ruby/object:Gem::Requirement
|
142
141
|
requirements:
|
143
142
|
- - ">="
|
144
143
|
- !ruby/object:Gem::Version
|
145
144
|
version: '0'
|
145
|
+
name: test-unit-rr
|
146
|
+
prerelease: false
|
147
|
+
type: :development
|
146
148
|
version_requirements: !ruby/object:Gem::Requirement
|
147
149
|
requirements:
|
148
150
|
- - ">="
|
149
151
|
- !ruby/object:Gem::Version
|
150
152
|
version: '0'
|
151
|
-
prerelease: false
|
152
|
-
type: :development
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
|
-
name: simplecov
|
155
154
|
requirement: !ruby/object:Gem::Requirement
|
156
155
|
requirements:
|
157
156
|
- - ">="
|
158
157
|
- !ruby/object:Gem::Version
|
159
158
|
version: '0'
|
159
|
+
name: simplecov
|
160
|
+
prerelease: false
|
161
|
+
type: :development
|
160
162
|
version_requirements: !ruby/object:Gem::Requirement
|
161
163
|
requirements:
|
162
164
|
- - ">="
|
163
165
|
- !ruby/object:Gem::Version
|
164
166
|
version: '0'
|
165
|
-
prerelease: false
|
166
|
-
type: :development
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
|
-
name: codeclimate-test-reporter
|
169
168
|
requirement: !ruby/object:Gem::Requirement
|
170
169
|
requirements:
|
171
170
|
- - ">="
|
172
171
|
- !ruby/object:Gem::Version
|
173
172
|
version: '0'
|
173
|
+
name: codeclimate-test-reporter
|
174
|
+
prerelease: false
|
175
|
+
type: :development
|
174
176
|
version_requirements: !ruby/object:Gem::Requirement
|
175
177
|
requirements:
|
176
178
|
- - ">="
|
177
179
|
- !ruby/object:Gem::Version
|
178
180
|
version: '0'
|
179
|
-
prerelease: false
|
180
|
-
type: :development
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
|
-
name: pry
|
183
182
|
requirement: !ruby/object:Gem::Requirement
|
184
183
|
requirements:
|
185
184
|
- - ">="
|
186
185
|
- !ruby/object:Gem::Version
|
187
186
|
version: '0'
|
187
|
+
name: pry
|
188
|
+
prerelease: false
|
189
|
+
type: :development
|
188
190
|
version_requirements: !ruby/object:Gem::Requirement
|
189
191
|
requirements:
|
190
192
|
- - ">="
|
191
193
|
- !ruby/object:Gem::Version
|
192
194
|
version: '0'
|
193
|
-
prerelease: false
|
194
|
-
type: :development
|
195
195
|
- !ruby/object:Gem::Dependency
|
196
|
-
name: gem_release_helper
|
197
196
|
requirement: !ruby/object:Gem::Requirement
|
198
197
|
requirements:
|
199
198
|
- - "~>"
|
200
199
|
- !ruby/object:Gem::Version
|
201
200
|
version: '1.0'
|
201
|
+
name: gem_release_helper
|
202
|
+
prerelease: false
|
203
|
+
type: :development
|
202
204
|
version_requirements: !ruby/object:Gem::Requirement
|
203
205
|
requirements:
|
204
206
|
- - "~>"
|
205
207
|
- !ruby/object:Gem::Version
|
206
208
|
version: '1.0'
|
207
|
-
prerelease: false
|
208
|
-
type: :development
|
209
209
|
description: Loads records from Google Analytics.
|
210
210
|
email:
|
211
211
|
- k@uu59.org
|
@@ -248,9 +248,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
248
248
|
version: '0'
|
249
249
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
250
250
|
requirements:
|
251
|
-
- - "
|
251
|
+
- - ">"
|
252
252
|
- !ruby/object:Gem::Version
|
253
|
-
version:
|
253
|
+
version: 1.3.1
|
254
254
|
requirements: []
|
255
255
|
rubyforge_project:
|
256
256
|
rubygems_version: 2.6.6
|