embulk-input-mixpanel 0.5.4 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f5341d3459ab9ebb11548c637781a2e56f8f827d
4
- data.tar.gz: fddc31638fbfc95d804b140e91a79a880e2fd0c8
3
+ metadata.gz: feae04dbd0d3d9eebea301fecf14418a588723d4
4
+ data.tar.gz: 0ae3937206d959f34f1d542297925388f616f31b
5
5
  SHA512:
6
- metadata.gz: ddd3e72b06554148f5bf7e866823aa3e65004ef317f7a55df269c41499515f8b23b63f4571c565bbe0123871bb1cc0d9451fc25f36939f1f5974737699152730
7
- data.tar.gz: c59a6e927cb172562d0ecead325d4f8c5359f6bec34f672673abdf9a061b9e7aeecc617f820f99beffed30171fa038a8fa25a917f9bf82e923a49cb9a7405ac8
6
+ metadata.gz: 742c1956e206d8876f40bf564b40d072cf4f8416850e10584228a4f290a889a2171354b94ce23e2f1b84cbb28e3401e640ea4f4084648b43de0a0ac0ea91d158
7
+ data.tar.gz: 3827c9c15d5db544261a1c666286ed4a465d8caf42a1cce0ab21f55e7092c9322430df180ec0b08af645df3de271fe461885863388a2aa019ccbaa4a8d27de79
@@ -1,5 +1,5 @@
1
1
  ## 0.5.4 - 2017-08-15
2
- * [bug] Fix a bug when `fetch_days` is 1 plugin will fetch 2 days instead of 1
2
+ * [bug] Fix a bug when `fetch_days` is 1 plugin will fetch 2 days instead of 1 [#51](https://github.com/treasure-data/embulk-input-mixpanel/pull/51)
3
3
 
4
4
  ## 0.5.3 - 2017-08-07
5
5
  * [enhancement] Allow user to choose to run incremental or not `incremental` option default to true [#50](https://github.com/treasure-data/embulk-input-mixpanel/pull/50)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "embulk-input-mixpanel"
3
- spec.version = "0.5.4"
3
+ spec.version = "0.5.5"
4
4
  spec.authors = ["yoshihara", "uu59"]
5
5
  spec.summary = "Mixpanel input plugin for Embulk"
6
6
  spec.description = "Loads records from Mixpanel."
@@ -24,11 +24,8 @@ module Embulk
24
24
  $city $region mp_country_code $browser $browser_version $device $current_url $initial_referrer $initial_referring_domain $os $referrer $referring_domain $screen_height $screen_width $search_engine $city $region $mp_country_code $timezone $browser_version $browser $initial_referrer $initial_referring_domain $os $last_seen $city $region mp_country_code $app_release $app_version $carrier $ios_ifa $os_version $manufacturer $lib_version $model $os $screen_height $screen_width $wifi $city $region $mp_country_code $timezone $ios_app_release $ios_app_version $ios_device_model $ios_lib_version $ios_version $ios_ifa $last_seen $city $region mp_country_code $app_version $bluetooth_enabled $bluetooth_version $brand $carrier $has_nfc $has_telephone $lib_version $manufacturer $model $os $os_version $screen_dpi $screen_height $screen_width $wifi $google_play_services $city $region mp_country_code $timezone $android_app_version $android_app_version_code $android_lib_version $android_os $android_os_version $android_brand $android_model $android_manufacturer $last_seen
25
25
  ).uniq.freeze
26
26
 
27
- # NOTE: It takes long time to fetch data between from_date to
28
- # to_date by one API request. So this plugin fetches data
29
- # between each 7 (SLICE_DAYS_COUNT) days.
30
- SLICE_DAYS_COUNT = 7
31
27
 
28
+ DEFAULT_FETCH_DAYS = 7
32
29
  DEFAULT_TIME_COLUMN = 'time'
33
30
 
34
31
  def self.transaction(config, &control)
@@ -68,7 +65,8 @@ module Embulk
68
65
  incremental_column: incremental_column,
69
66
  retry_limit: config.param(:retry_limit, :integer, default: 5),
70
67
  latest_fetched_time: latest_fetched_time,
71
- incremental: incremental
68
+ incremental: incremental,
69
+ slice_range: config.param(:slice_range, :integer, default: 7)
72
70
  }
73
71
 
74
72
  if task[:fetch_unknown_columns] && task[:fetch_custom_properties]
@@ -161,8 +159,7 @@ module Embulk
161
159
  prev_latest_fetched_time = task[:latest_fetched_time] || 0
162
160
  prev_latest_fetched_time_format = Time.at(prev_latest_fetched_time).strftime("%F %T %z")
163
161
  current_latest_fetched_time = prev_latest_fetched_time
164
-
165
- @dates.each_slice(SLICE_DAYS_COUNT) do |dates|
162
+ @dates.each_slice(task[:slice_range]) do |dates|
166
163
  ignored_record_count = 0
167
164
  unless preview?
168
165
  Embulk.logger.info "Fetching data from #{dates.first} to #{dates.last} ..."
@@ -196,7 +193,6 @@ module Embulk
196
193
  end
197
194
  page_builder.add(values)
198
195
  end
199
-
200
196
  if ignored_record_count > 0
201
197
  Embulk.logger.warn "Skipped already loaded #{ignored_record_count} records. These record times are older or equal than previous fetched record time (#{prev_latest_fetched_time} @ #{prev_latest_fetched_time_format})."
202
198
  end
@@ -316,12 +312,12 @@ module Embulk
316
312
  end
317
313
 
318
314
  def self.default_guess_start_date
319
- Date.today - SLICE_DAYS_COUNT - 1
315
+ Date.today - DEFAULT_FETCH_DAYS - 1
320
316
  end
321
317
 
322
318
  def self.guess_range(config)
323
319
  from_date = config.param(:from_date, :string, default: default_guess_start_date.to_s)
324
- fetch_days = config.param(:fetch_days, :integer, default: SLICE_DAYS_COUNT)
320
+ fetch_days = config.param(:fetch_days, :integer, default: DEFAULT_FETCH_DAYS)
325
321
  range = RangeGenerator.new(from_date, fetch_days).generate_range
326
322
  if range.empty?
327
323
  return default_guess_start_date..(Date.today - 1)
@@ -541,6 +541,7 @@ module Embulk
541
541
  retry_initial_wait_sec: 0,
542
542
  retry_limit: 3,
543
543
  latest_fetched_time: 0,
544
+ slice_range: 7
544
545
  }
545
546
  end
546
547
  end
@@ -585,6 +586,20 @@ module Embulk
585
586
  @plugin.run
586
587
  end
587
588
 
589
+ class SliceRangeRunTest < self
590
+
591
+ def test_default_slice_range
592
+ plugin = Mixpanel.new(task.merge(slice_range: 2), nil, nil, @page_builder)
593
+ stub(plugin).preview? {false}
594
+ stub(plugin).fetch(["2015-02-22", "2015-02-23"],0){[]}
595
+ stub(plugin).fetch(["2015-02-24", "2015-02-25"],0){[]}
596
+ stub(plugin).fetch(["2015-02-26", "2015-02-27"],0){[]}
597
+ stub(plugin).fetch(["2015-02-28", "2015-03-01"],0){[]}
598
+ mock(@page_builder).finish
599
+ plugin.run
600
+ end
601
+ end
602
+
588
603
  class NonIncrementalRunTest < self
589
604
 
590
605
  def test_non_incremental_run
@@ -807,6 +822,7 @@ module Embulk
807
822
  retry_initial_wait_sec: 2,
808
823
  retry_limit: 3,
809
824
  latest_fetched_time: 0,
825
+ slice_range: 7
810
826
  }
811
827
  end
812
828
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-input-mixpanel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - yoshihara
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-08-15 00:00:00.000000000 Z
12
+ date: 2017-09-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  requirement: !ruby/object:Gem::Requirement
@@ -224,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
224
224
  version: '0'
225
225
  requirements: []
226
226
  rubyforge_project:
227
- rubygems_version: 2.6.12
227
+ rubygems_version: 2.6.6
228
228
  signing_key:
229
229
  specification_version: 4
230
230
  summary: Mixpanel input plugin for Embulk