embulk-input-mixpanel 0.4.0 → 0.4.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: 0dedffafe59dd4e3dcbe23d13d3d2ae8f1a4046f
4
- data.tar.gz: dad21a163d3dfe678e3b4d49531c476fe48af594
3
+ metadata.gz: 7253da23180b92cc1403e3ee23b526d154a8e243
4
+ data.tar.gz: c1e09f40c320c7959a86db23d4ba1d5562167597
5
5
  SHA512:
6
- metadata.gz: 0ac29f80faece33812fb85d48aed368398ea1fb2ee779cab01b7489ea1f171cfa7ea6aa9d017527d6ab8ca80b6966f29c22164ca0534f3878c1f94e2cd92b56c
7
- data.tar.gz: c4a4382fd745a91c483ae5eff4b11e2aca0949a157ddcfb127d2430d273d4158c8087b350d0da5844e957a487a1c08e7bd0b1c07cef30900c23db883e870b566
6
+ metadata.gz: bac8feab3089bdd03b8df1758db23a153f3a39edba8e8d10dde9b6b7e9224271985466a8fc8114b308e7b6994360d43b9abf6a1b9246a462c74d3ef562ebdd63
7
+ data.tar.gz: 44d4a809616745c4ee595a2eb476df8897936d2531e1d847414b26e1211b8dcfdedcb1da95e49fb908ecf059b103670425ef0c3899614d5443ba10ea4fe38468
@@ -1,3 +1,6 @@
1
+ ## 0.4.1 - 2016-03-08
2
+ * [enhancement] Reduce data bytes with range [#38](https://github.com/treasure-data/embulk-input-mixpanel/pull/38)
3
+
1
4
  ## 0.4.0 - 2016-03-04
2
5
 
3
6
  This version contains compatibility breaking. Only support Embulk 0.8 or later since this version, no longer support Embulk 0.7.x or earlier.
data/README.md CHANGED
@@ -8,7 +8,7 @@ embulk-input-mixpanel is the Embulk input plugin for [Mixpanel](https://mixpanel
8
8
 
9
9
  ## Overview
10
10
 
11
- Required Embulk version >= 0.6.16.
11
+ Required Embulk version >= 0.8.6 (since v0.4.0).
12
12
 
13
13
  * **Plugin type**: input
14
14
  * **Resume supported**: no
@@ -1,7 +1,7 @@
1
1
 
2
2
  Gem::Specification.new do |spec|
3
3
  spec.name = "embulk-input-mixpanel"
4
- spec.version = "0.4.0"
4
+ spec.version = "0.4.1"
5
5
  spec.authors = ["yoshihara", "uu59"]
6
6
  spec.summary = "Mixpanel input plugin for Embulk"
7
7
  spec.description = "Loads records from Mixpanel."
@@ -12,6 +12,7 @@ module Embulk
12
12
  PING_TIMEOUT_SECONDS = 3
13
13
  PING_RETRY_LIMIT = 3
14
14
  PING_RETRY_WAIT = 2
15
+ SMALLSET_BYTE_RANGE = "0-#{5 * 1024 * 1024}"
15
16
 
16
17
  def self.mixpanel_available?
17
18
  retryer = PerfectRetry.new do |config|
@@ -48,9 +49,9 @@ module Embulk
48
49
  to_date = Date.parse(params["from_date"].to_s) + days
49
50
  params["to_date"] = to_date.strftime("%Y-%m-%d")
50
51
 
51
- body = request(params)
52
+ body = request(params, SMALLSET_BYTE_RANGE)
52
53
  result = response_to_enum(body)
53
- if result.to_a.length.zero?
54
+ if result.first.nil?
54
55
  if times >= 5
55
56
  raise ConfigError.new "#{params["from_date"]} + #{days} days has no record. too old date?"
56
57
  end
@@ -71,13 +72,20 @@ module Embulk
71
72
  end
72
73
  end
73
74
 
74
- def request(params)
75
+ def request(params, range = nil)
75
76
  # https://mixpanel.com/docs/api-documentation/exporting-raw-data-you-inserted-into-mixpanel
76
77
  params[:expire] ||= Time.now.to_i + TIMEOUT_SECONDS
77
78
  params[:sig] = signature(params)
78
79
  Embulk.logger.debug "Export param: #{params.to_s}"
79
80
 
80
- response = httpclient.get(ENDPOINT_EXPORT, params)
81
+ headers = {}
82
+ response =
83
+ if range
84
+ # guess/preview
85
+ httpclient.get(ENDPOINT_EXPORT, params, {"Range" => "bytes=#{range}"})
86
+ else
87
+ httpclient.get(ENDPOINT_EXPORT, params)
88
+ end
81
89
  Embulk.logger.debug "response code: #{response.code}"
82
90
  case response.code
83
91
  when 400..499
@@ -92,7 +92,7 @@ module Embulk
92
92
  class ExportSmallDataset < self
93
93
  def test_to_date_after_1_day
94
94
  to = (Date.parse(params["from_date"]) + 1).to_s
95
- mock(@client).request(params.merge("to_date" => to)) { jsonl_dummy_responses }
95
+ mock(@client).request(params.merge("to_date" => to), Client::SMALLSET_BYTE_RANGE) { jsonl_dummy_responses }
96
96
 
97
97
  @client.export_for_small_dataset(params)
98
98
  end
@@ -100,14 +100,14 @@ module Embulk
100
100
  def test_to_date_after_1_day_after_10_days_if_empty
101
101
  to1 = (Date.parse(params["from_date"]) + 1).to_s
102
102
  to2 = (Date.parse(params["from_date"]) + 10).to_s
103
- mock(@client).request(params.merge("to_date" => to1)) { "" }
104
- mock(@client).request(params.merge("to_date" => to2)) { jsonl_dummy_responses }
103
+ mock(@client).request(params.merge("to_date" => to1), Client::SMALLSET_BYTE_RANGE) { "" }
104
+ mock(@client).request(params.merge("to_date" => to2), Client::SMALLSET_BYTE_RANGE) { jsonl_dummy_responses }
105
105
 
106
106
  @client.export_for_small_dataset(params)
107
107
  end
108
108
 
109
109
  def test_config_error_when_too_long_empty_dates
110
- stub(@client).request(anything) { "" }
110
+ stub(@client).request(anything, anything) { "" }
111
111
 
112
112
  assert_raise(Embulk::ConfigError) do
113
113
  @client.export_for_small_dataset(params)
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.4.0
4
+ version: 0.4.1
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: 2016-03-04 00:00:00.000000000 Z
12
+ date: 2016-03-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  requirement: !ruby/object:Gem::Requirement