embulk-input-lkqd 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/embulk-input-lkqd.gemspec +1 -1
- data/lib/embulk/input/lkqd.rb +9 -12
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 699c8a2abf576d12dbc93d62310ea5198d04aa5f
|
4
|
+
data.tar.gz: def429a9636de45856499e19085ebef8fd7aee86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ae2cc084340adaacade236fd350c98cef31707548d945b5e0cf1238660f75a0095a2bd0419df53f25d9b1d08094cb1acbd1af270ca786d877e0065df36b3c48
|
7
|
+
data.tar.gz: 133919c57ce94e915ebd3c0d99c2a3c2ae58c77ef05a7e79ad2e352cafacf7dc3161151003678280211cc0ca1a76254ad8c6bb8792a05f308990c54c19b73386
|
data/embulk-input-lkqd.gemspec
CHANGED
data/lib/embulk/input/lkqd.rb
CHANGED
@@ -17,7 +17,6 @@ module Embulk
|
|
17
17
|
"secret_key" => config.param("secret_key", :string),
|
18
18
|
"endpoint" => config.param("endpoint", :string, default: 'https://api.lkqd.com/reports'),
|
19
19
|
"copy_temp_to" => config.param("copy_temp_to", :string, default: nil),
|
20
|
-
"try_convert" => config.param("try_convert", :bool, default: true),
|
21
20
|
"measurable_impressions" => config.param("measurable_impressions", :bool, default: false),
|
22
21
|
"viewable_impressions" => config.param("viewable_impressions", :bool, default: false),
|
23
22
|
"report_parameters" => config.param("report_parameters", :hash, default: {}),
|
@@ -25,7 +24,7 @@ module Embulk
|
|
25
24
|
task['authorization'] = Base64.urlsafe_encode64("#{task['secret_key_id']}:#{task['secret_key']}")
|
26
25
|
|
27
26
|
response = request_lkqd({authorization: task['authorization'], endpoint: task['endpoint'], report_parameters: task['report_parameters']})
|
28
|
-
tempfile = Tempfile.new('
|
27
|
+
tempfile = Tempfile.new('embulk-input-lkqd_')
|
29
28
|
while chunk = response.body.readpartial
|
30
29
|
tempfile.write chunk
|
31
30
|
end
|
@@ -78,7 +77,7 @@ module Embulk
|
|
78
77
|
column_name.gsub!(/^\W/, '')
|
79
78
|
column_option = DEFAULT_COLUMNS[column_name]
|
80
79
|
if column_option
|
81
|
-
return {type: column_option['type'].to_sym, name: column_name
|
80
|
+
return {type: column_option['type'].to_sym, name: column_name}
|
82
81
|
else
|
83
82
|
return {type: :string, name: column_name}
|
84
83
|
end
|
@@ -91,8 +90,8 @@ module Embulk
|
|
91
90
|
column_option = DEFAULT_COLUMNS[column_name]
|
92
91
|
if column_option.nil?
|
93
92
|
next value
|
94
|
-
elsif column_option['type'] == 'timestamp'
|
95
|
-
|
93
|
+
#elsif column_option['type'] == 'timestamp'
|
94
|
+
# next Time.strptime(value + " " + options[:timezone], column_option['format'] + " %Z").to_i
|
96
95
|
elsif column_option['type'] == 'long'
|
97
96
|
next value.gsub(',','').to_i
|
98
97
|
elsif column_option['type'] == 'double' && value.match(/%$/)
|
@@ -106,13 +105,12 @@ module Embulk
|
|
106
105
|
end
|
107
106
|
|
108
107
|
def self.measurable_impressions?(task)
|
109
|
-
task['
|
110
|
-
task['viewability_measured_rate_index'] && task['impressions_index']
|
108
|
+
task['measurable_impressions'] && task['viewability_measured_rate_index'] && task['impressions_index']
|
111
109
|
end
|
112
110
|
|
113
111
|
def self.viewable_impressions?(task)
|
114
|
-
task['
|
115
|
-
task['
|
112
|
+
task['viewable_impressions'] && task['viewability_rate_index'] &&
|
113
|
+
task['viewability_measured_rate_index'] && task['impressions_index']
|
116
114
|
end
|
117
115
|
|
118
116
|
def init
|
@@ -121,13 +119,12 @@ module Embulk
|
|
121
119
|
|
122
120
|
def run
|
123
121
|
convert_options = {timezone: @task['report_parameters']['timezone']}
|
124
|
-
try_convert = @task['try_convert']
|
125
122
|
viewability_measured_rate_index = @task['viewability_measured_rate_index']
|
126
123
|
viewability_rate_index = @task['viewability_rate_index']
|
127
124
|
impressions_index = @task['impressions_index']
|
128
125
|
|
129
126
|
CSV.foreach(@task['tempfile_path'], {headers: true}).each do |row|
|
130
|
-
row =
|
127
|
+
row = Lkqd.try_convert(row, convert_options)
|
131
128
|
if Lkqd.measurable_impressions?(@task)
|
132
129
|
row << row[impressions_index] * row[viewability_measured_rate_index]
|
133
130
|
end
|
@@ -146,7 +143,7 @@ module Embulk
|
|
146
143
|
|
147
144
|
DEFAULT_COLUMNS = {
|
148
145
|
# dimensions' columns
|
149
|
-
'Time'=> { 'type' => '
|
146
|
+
'Time'=> { 'type' => 'string' },
|
150
147
|
'Account'=> { 'type' => 'string' },
|
151
148
|
'Supply Source ID'=> { 'type' => 'string' },
|
152
149
|
'Supply Source'=> { 'type' => 'string' },
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-input-lkqd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ming Liu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
101
|
version: '0'
|
102
102
|
requirements: []
|
103
103
|
rubyforge_project:
|
104
|
-
rubygems_version: 2.6.
|
104
|
+
rubygems_version: 2.6.12
|
105
105
|
signing_key:
|
106
106
|
specification_version: 4
|
107
107
|
summary: LKQD input plugin for Embulk
|