embulk-input-mixpanel 0.5.12 → 0.5.13

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: 4c4d29865b7b17b4df43e0b6810a73392ab57627
4
- data.tar.gz: 2884b91def9e5e6dbf7ed0eb331a5c9f0355521c
3
+ metadata.gz: 66b8edacf57562c25bb7663220b5c2f85e585da4
4
+ data.tar.gz: d631d41e6761ba3dc840085d24d9666a0f0b1221
5
5
  SHA512:
6
- metadata.gz: cb95e825d05e33d626edf85d1b1760481c6350deb0741b801d5e07afe17c42fd20f0eca7155093b47e6e4e42ba67c1cf7771628210c28ca4ba33893301029a56
7
- data.tar.gz: 91792f7c85c26bf04fd88e8874e5ce6472464beb6cfa65e837178eaee2ba478dbf5363c5bb60042081b2a1a83b267934c8487ba91774c27f20f385278e2d73c2
6
+ metadata.gz: 38cdaa6706bf5ac3b76eb7be40a52ff2473b6e4fe3f7037f9d00ee61cfe35c94d0bd85a3a00d15a1d6486100c5ab1851aee1bce4c54cbeaadc93f90b2396523e
7
+ data.tar.gz: 0c778717481718ecf4b97c636ec0f5ed6966be18b8687ba0c95941e66726fd4fe543674490a266d5d9948ac31b775574e229030f4efd26cc1159e8e14d9b8acc
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.5.13 - 2018-10-04
2
+
3
+ * [enhancement] Limit number of returned records in guess and preview [#60](https://github.com/treasure-data/embulk-input-mixpanel/pull/60)
4
+
1
5
  ## 0.5.12 - 2017-02-09
2
6
 
3
7
  * [bug] Fix incorrect from_date [#59](https://github.com/treasure-data/embulk-input-mixpanel/pull/59)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "embulk-input-mixpanel"
3
- spec.version = "0.5.12"
3
+ spec.version = "0.5.13"
4
4
  spec.authors = ["yoshihara", "uu59"]
5
5
  spec.summary = "Mixpanel input plugin for Embulk"
6
6
  spec.description = "Loads records from Mixpanel."
@@ -11,7 +11,6 @@ module Embulk
11
11
  class Mixpanel < InputPlugin
12
12
  Plugin.register_input("mixpanel", self)
13
13
 
14
- GUESS_RECORDS_COUNT = 10
15
14
  NOT_PROPERTY_COLUMN = "event".freeze
16
15
 
17
16
  # https://mixpanel.com/help/questions/articles/special-or-reserved-properties
@@ -355,7 +354,7 @@ module Embulk
355
354
  end
356
355
 
357
356
  def self.guess_from_records(records)
358
- sample_props = records.first(GUESS_RECORDS_COUNT).map {|r| r["properties"]}
357
+ sample_props = records.map {|r| r["properties"]}
359
358
  schema = Guess::SchemaGuess.from_hash_records(sample_props)
360
359
  columns = schema.map do |col|
361
360
  next if col.name == "time"
@@ -12,7 +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
+ SMALL_NUM_OF_RECORDS = 10
16
16
  DEFAULT_EXPORT_ENDPOINT = "https://data.mixpanel.com/api/2.0/export/".freeze
17
17
 
18
18
  attr_reader :retryer
@@ -66,7 +66,7 @@ module Embulk
66
66
  latest_tried_to_date = to_date
67
67
  params["to_date"] = to_date.strftime("%Y-%m-%d")
68
68
  records = retryer.with_retry do
69
- request_small_dataset(params, SMALLSET_BYTE_RANGE)
69
+ request_small_dataset(params, SMALL_NUM_OF_RECORDS)
70
70
  end
71
71
  next if records.first.nil?
72
72
  return records
@@ -129,16 +129,13 @@ module Embulk
129
129
  end
130
130
  end
131
131
 
132
- def request_small_dataset(params, range)
132
+ def request_small_dataset(params, num_of_records)
133
133
  # guess/preview
134
- # Try to fetch first `range` bytes
134
+ # Try to fetch first number of records
135
+ params["limit"] = num_of_records
135
136
  set_signatures(params)
136
137
  Embulk.logger.info "Sending request to #{@endpoint}"
137
- res = httpclient.get(@endpoint, params, {"Range" => "bytes=#{range}"})
138
- if res.code == 416
139
- # cannot satisfied requested Range, get full body
140
- res = httpclient.get(@endpoint, params)
141
- end
138
+ res = httpclient.get(@endpoint, params)
142
139
  handle_error(res,res.body)
143
140
  response_to_enum(res.body)
144
141
  end
@@ -145,7 +145,7 @@ module Embulk
145
145
  class ExportSmallDataset < self
146
146
  def test_to_date_after_1_day
147
147
  to = (Date.parse(params["from_date"]) + 1).to_s
148
- mock(@client).request_small_dataset(params.merge("to_date" => to), Client::SMALLSET_BYTE_RANGE) { [:foo] }
148
+ mock(@client).request_small_dataset(params.merge("to_date" => to), Client::SMALL_NUM_OF_RECORDS) { [:foo] }
149
149
 
150
150
  @client.export_for_small_dataset(params)
151
151
  end
@@ -163,8 +163,8 @@ module Embulk
163
163
  stub_client
164
164
  to1 = (Date.parse(params["from_date"]) + 1).to_s
165
165
  to2 = (Date.parse(params["from_date"]) + 10).to_s
166
- mock(@client).request_small_dataset(params.merge("to_date" => to1), Client::SMALLSET_BYTE_RANGE) { [] }
167
- mock(@client).request_small_dataset(params.merge("to_date" => to2), Client::SMALLSET_BYTE_RANGE) { [:foo] }
166
+ mock(@client).request_small_dataset(params.merge("to_date" => to1), Client::SMALL_NUM_OF_RECORDS) { [] }
167
+ mock(@client).request_small_dataset(params.merge("to_date" => to2), Client::SMALL_NUM_OF_RECORDS) { [:foo] }
168
168
 
169
169
  @client.export_for_small_dataset(params)
170
170
  end
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.12
4
+ version: 0.5.13
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: 2018-02-09 00:00:00.000000000 Z
12
+ date: 2018-10-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  requirement: !ruby/object:Gem::Requirement
@@ -239,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
239
239
  version: '0'
240
240
  requirements: []
241
241
  rubyforge_project:
242
- rubygems_version: 2.6.6
242
+ rubygems_version: 2.4.8
243
243
  signing_key:
244
244
  specification_version: 4
245
245
  summary: Mixpanel input plugin for Embulk