embulk-input-lkqd 0.1.0 → 0.2.0

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: b93579065f9e23f8657ba1347106a632be11d206
4
- data.tar.gz: 68a43225355600b5f32a5cc747c901131615c70b
3
+ metadata.gz: 01f73feb965f432aad6c52c7fa9ee749c272853f
4
+ data.tar.gz: a41458a6593cdc5c9b773bc913c45c17382fed00
5
5
  SHA512:
6
- metadata.gz: 76e8dd612eb8ef05230b14dfff0a6c6af4d512cc9555a7429613fdbc01d217004efe06266eb1afe44167a6e63673080fcd3f9e82dd17bb9b59d2a507a5d49e25
7
- data.tar.gz: 792d5f855f244a9c36752991c912f66862b90b41d69f9bbd655f21558c489f95b6cd4f2c55ce04ae81725dec96a11ea7cfdd141771f90aa1de1fe0f57fa4a5ef
6
+ metadata.gz: 312dbc836979c4fcabf9966826fcb63032ae4a14689ce93e9ad9847ccb21210a0d12ee0d719c369a6796c91e1a97833b3cf23d388fcd555b788cb901777d8765
7
+ data.tar.gz: 4dcdda5ef3bfe6464d3c46fcbd85a0831d9ecc58b357bf34178bbc8a7eb76e8d55d4db66209bfea5f5e9e44139a1713cda54fc075bd865ebc97e69f00a1f9eab
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "embulk-input-lkqd"
3
- spec.version = "0.1.0"
3
+ spec.version = "0.2.0"
4
4
  spec.authors = ["Ming Liu"]
5
5
  spec.summary = "LKQD input plugin for Embulk"
6
6
  spec.description = "Loads reporting data from LKQD API."
@@ -53,19 +53,40 @@ module Embulk
53
53
  column_name.gsub!(/^\W/, '')
54
54
  column_option = DEFAULT_COLUMNS[column_name]
55
55
  if column_option
56
- return {type: column_option['out_type'].to_sym, name: column_name, format: column_option['format']}
56
+ return {type: column_option['type'].to_sym, name: column_name, format: column_option['format']}
57
57
  else
58
58
  return {type: :string, name: column_name}
59
59
  end
60
60
  end
61
61
 
62
+ def self.try_convert(row)
63
+ return row.map do |field|
64
+ name, value = field
65
+ column_name = name.gsub(/^\W/, '')
66
+ column_option = DEFAULT_COLUMNS[column_name]
67
+ if column_option.nil?
68
+ next value
69
+ elsif column_option['type'] == 'timestamp'
70
+ next Time.strptime(value, column_option['format']).to_i
71
+ elsif column_option['type'] == 'long'
72
+ next value.gsub(',','').to_i
73
+ elsif column_option['type'] == 'double' && value.match(/%$/)
74
+ next value.gsub(',','').to_f / 100.0
75
+ elsif column_option['type'] == 'double'
76
+ next value.gsub(',','').to_f
77
+ else
78
+ next value
79
+ end
80
+ end
81
+ end
82
+
62
83
  def init
63
84
  @task = task
64
85
  end
65
86
 
66
87
  def run
67
88
  CSV.foreach(@task['tempfile_path'], {headers: true}).each do |row|
68
- page_builder.add(row)
89
+ page_builder.add(Lkqd.try_convert(row))
69
90
  end
70
91
  page_builder.finish
71
92
 
@@ -75,89 +96,89 @@ module Embulk
75
96
 
76
97
  DEFAULT_COLUMNS = {
77
98
  # dimensions' columns
78
- 'Time'=> { 'out_type' => 'timestamp', 'format' => "%Y-%m-%dT%H", 'timezone' => 'UTC' },
79
- 'Account'=> { 'out_type' => 'string' },
80
- 'Supply Source ID'=> { 'out_type' => 'string' },
81
- 'Supply Source'=> { 'out_type' => 'string' },
82
- 'Supply Partner'=> { 'out_type' => 'string' },
83
- 'Environment'=> { 'out_type' => 'string' },
84
- 'Domain'=> { 'out_type' => 'string' },
85
- 'App Name'=> { 'out_type' => 'string' },
86
- 'Bundle ID'=> { 'out_type' => 'string' },
87
- 'Supply Tag Type'=> { 'out_type' => 'string' },
88
- 'Demand Partner'=> { 'out_type' => 'string' },
89
- 'Demand Deal ID' => { 'out_type' => 'string' },
90
- 'Demand Deal'=> { 'out_type' => 'string' },
91
- 'Demand Tag'=> { 'out_type' => 'string' },
92
- 'Format'=> { 'out_type' => 'string' },
93
- 'Country'=> { 'out_type' => 'string' },
94
- 'Device Type'=> { 'out_type' => 'string' },
95
- 'OS'=> { 'out_type' => 'string' },
96
- 'Width X Height'=> { 'out_type' => 'string' },
99
+ 'Time'=> { 'type' => 'timestamp', 'format' => "%Y-%m-%dT%H" },
100
+ 'Account'=> { 'type' => 'string' },
101
+ 'Supply Source ID'=> { 'type' => 'string' },
102
+ 'Supply Source'=> { 'type' => 'string' },
103
+ 'Supply Partner'=> { 'type' => 'string' },
104
+ 'Environment'=> { 'type' => 'string' },
105
+ 'Domain'=> { 'type' => 'string' },
106
+ 'App Name'=> { 'type' => 'string' },
107
+ 'Bundle ID'=> { 'type' => 'string' },
108
+ 'Supply Tag Type'=> { 'type' => 'string' },
109
+ 'Demand Partner'=> { 'type' => 'string' },
110
+ 'Demand Deal ID' => { 'type' => 'string' },
111
+ 'Demand Deal'=> { 'type' => 'string' },
112
+ 'Demand Tag'=> { 'type' => 'string' },
113
+ 'Format'=> { 'type' => 'string' },
114
+ 'Country'=> { 'type' => 'string' },
115
+ 'Device Type'=> { 'type' => 'string' },
116
+ 'OS'=> { 'type' => 'string' },
117
+ 'Width X Height'=> { 'type' => 'string' },
97
118
  # "Opportunity report" columns
98
- 'Tag Loads' => { 'out_type' => 'long' },
99
- 'Opportunities' => { 'out_type' => 'long' },
100
- 'Format Loads' => { 'out_type' => 'long' },
101
- 'Format Fill Rate' => { 'out_type' => 'double' },
102
- 'Ineligible Ops: Demand' => { 'out_type' => 'long' },
103
- 'Ineligible Ops: Restrictions' => { 'out_type' => 'long' },
104
- 'Impressions' => { 'out_type' => 'long' },
105
- 'Fill Rate' => { 'out_type' => 'double' },
106
- 'Efficiency Rate' => { 'out_type' => 'double' },
107
- 'CPM' => { 'out_type' => 'double' },
108
- 'Revenue' => { 'out_type' => 'double' },
109
- 'Cost' => { 'out_type' => 'double' },
110
- 'Profit' => { 'out_type' => 'double' },
111
- 'Profit Margin' => { 'out_type' => 'double' },
112
- 'Clicks' => { 'out_type' => 'long' },
113
- 'CTR' => { 'out_type' => 'double' },
114
- '25% Views' => { 'out_type' => 'long' },
115
- '50% Views' => { 'out_type' => 'long' },
116
- '75% Views' => { 'out_type' => 'long' },
117
- '100% Views' => { 'out_type' => 'long' },
118
- '25% View Rate' => { 'out_type' => 'double' },
119
- '50% View Rate' => { 'out_type' => 'double' },
120
- '75% View Rate' => { 'out_type' => 'double' },
121
- '100% View Rate' => { 'out_type' => 'double' },
122
- 'Viewability Measured Rate' => { 'out_type' => 'double' },
123
- 'Viewability Rate' => { 'out_type' => 'double' },
119
+ 'Tag Loads' => { 'type' => 'long' },
120
+ 'Opportunities' => { 'type' => 'long' },
121
+ 'Format Loads' => { 'type' => 'long' },
122
+ 'Format Fill Rate' => { 'type' => 'double' },
123
+ 'Ineligible Ops: Demand' => { 'type' => 'long' },
124
+ 'Ineligible Ops: Restrictions' => { 'type' => 'long' },
125
+ 'Impressions' => { 'type' => 'long' },
126
+ 'Fill Rate' => { 'type' => 'double' },
127
+ 'Efficiency Rate' => { 'type' => 'double' },
128
+ 'CPM' => { 'type' => 'double' },
129
+ 'Revenue' => { 'type' => 'double' },
130
+ 'Cost' => { 'type' => 'double' },
131
+ 'Profit' => { 'type' => 'double' },
132
+ 'Profit Margin' => { 'type' => 'double' },
133
+ 'Clicks' => { 'type' => 'long' },
134
+ 'CTR' => { 'type' => 'double' },
135
+ '25% Views' => { 'type' => 'long' },
136
+ '50% Views' => { 'type' => 'long' },
137
+ '75% Views' => { 'type' => 'long' },
138
+ '100% Views' => { 'type' => 'long' },
139
+ '25% View Rate' => { 'type' => 'double' },
140
+ '50% View Rate' => { 'type' => 'double' },
141
+ '75% View Rate' => { 'type' => 'double' },
142
+ '100% View Rate' => { 'type' => 'double' },
143
+ 'Viewability Measured Rate' => { 'type' => 'double' },
144
+ 'Viewability Rate' => { 'type' => 'double' },
124
145
  # "Request report" columns
125
- 'Tag Requests' => { 'out_type' => 'long' },
126
- 'Ads' => { 'out_type' => 'long' },
127
- 'VAST Ads' => { 'out_type' => 'long' },
128
- 'VPAID Ads' => { 'out_type' => 'long' },
129
- 'Wins' => { 'out_type' => 'long' },
130
- 'Ad Rate' => { 'out_type' => 'double' },
131
- 'VAST Ad Rate' => { 'out_type' => 'double' },
132
- 'VPAID Ad Rate' => { 'out_type' => 'double' },
133
- 'Win Rate' => { 'out_type' => 'double' },
134
- 'VPAID Responses' => { 'out_type' => 'long' },
135
- 'VPAID Attempts' => { 'out_type' => 'long' },
136
- 'VPAID Successes' => { 'out_type' => 'long' },
137
- 'VPAID Opt Outs' => { 'out_type' => 'long' },
138
- 'VPAID Timeouts' => { 'out_type' => 'long' },
139
- 'VPAID Errors' => { 'out_type' => 'long' },
140
- 'VPAID Success Rate' => { 'out_type' => 'double' },
141
- 'VPAID Opt Out Rate' => { 'out_type' => 'double' },
142
- 'VPAID Timeout Rate' => { 'out_type' => 'double' },
143
- 'VPAID Error Rate' => { 'out_type' => 'double' },
144
- 'Tag Timeouts' => { 'out_type' => 'long' },
145
- 'Tag Timeout Rate' => { 'out_type' => 'double' },
146
- 'Tag Errors' => { 'out_type' => 'long' },
147
- 'Tag Error Rate' => { 'out_type' => 'long' },
148
- 'Playback Errors' => { 'out_type' => 'long' },
149
- 'Playback Error Rate' => { 'out_type' => 'double' },
146
+ 'Tag Requests' => { 'type' => 'long' },
147
+ 'Ads' => { 'type' => 'long' },
148
+ 'VAST Ads' => { 'type' => 'long' },
149
+ 'VPAID Ads' => { 'type' => 'long' },
150
+ 'Wins' => { 'type' => 'long' },
151
+ 'Ad Rate' => { 'type' => 'double' },
152
+ 'VAST Ad Rate' => { 'type' => 'double' },
153
+ 'VPAID Ad Rate' => { 'type' => 'double' },
154
+ 'Win Rate' => { 'type' => 'double' },
155
+ 'VPAID Responses' => { 'type' => 'long' },
156
+ 'VPAID Attempts' => { 'type' => 'long' },
157
+ 'VPAID Successes' => { 'type' => 'long' },
158
+ 'VPAID Opt Outs' => { 'type' => 'long' },
159
+ 'VPAID Timeouts' => { 'type' => 'long' },
160
+ 'VPAID Errors' => { 'type' => 'long' },
161
+ 'VPAID Success Rate' => { 'type' => 'double' },
162
+ 'VPAID Opt Out Rate' => { 'type' => 'double' },
163
+ 'VPAID Timeout Rate' => { 'type' => 'double' },
164
+ 'VPAID Error Rate' => { 'type' => 'double' },
165
+ 'Tag Timeouts' => { 'type' => 'long' },
166
+ 'Tag Timeout Rate' => { 'type' => 'double' },
167
+ 'Tag Errors' => { 'type' => 'long' },
168
+ 'Tag Error Rate' => { 'type' => 'long' },
169
+ 'Playback Errors' => { 'type' => 'long' },
170
+ 'Playback Error Rate' => { 'type' => 'double' },
150
171
  # custom data columns
151
- 'Custom 1'=> { 'out_type' => 'string' },
152
- 'Custom 2'=> { 'out_type' => 'string' },
153
- 'Custom 3'=> { 'out_type' => 'string' },
154
- 'Custom 4'=> { 'out_type' => 'string' },
155
- 'Custom 5'=> { 'out_type' => 'string' },
156
- 'Custom 6'=> { 'out_type' => 'string' },
157
- 'Custom 7'=> { 'out_type' => 'string' },
158
- 'Custom 8'=> { 'out_type' => 'string' },
159
- 'Custom 9'=> { 'out_type' => 'string' },
160
- 'Custom 10'=> { 'out_type' => 'string' },
172
+ 'Custom 1'=> { 'type' => 'string' },
173
+ 'Custom 2'=> { 'type' => 'string' },
174
+ 'Custom 3'=> { 'type' => 'string' },
175
+ 'Custom 4'=> { 'type' => 'string' },
176
+ 'Custom 5'=> { 'type' => 'string' },
177
+ 'Custom 6'=> { 'type' => 'string' },
178
+ 'Custom 7'=> { 'type' => 'string' },
179
+ 'Custom 8'=> { 'type' => 'string' },
180
+ 'Custom 9'=> { 'type' => 'string' },
181
+ 'Custom 10'=> { 'type' => 'string' },
161
182
  }.freeze
162
183
  end
163
184
 
metadata CHANGED
@@ -1,66 +1,66 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-input-lkqd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ming Liu
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2017-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
+ name: http
14
15
  requirement: !ruby/object:Gem::Requirement
15
16
  requirements:
16
17
  - - "~>"
17
18
  - !ruby/object:Gem::Version
18
19
  version: 2.2.2
19
- name: http
20
- prerelease: false
21
20
  type: :runtime
21
+ prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 2.2.2
27
27
  - !ruby/object:Gem::Dependency
28
+ name: embulk
28
29
  requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - '='
31
32
  - !ruby/object:Gem::Version
32
33
  version: 0.8.28
33
- name: embulk
34
- prerelease: false
35
34
  type: :development
35
+ prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.8.28
41
41
  - !ruby/object:Gem::Dependency
42
+ name: bundler
42
43
  requirement: !ruby/object:Gem::Requirement
43
44
  requirements:
44
45
  - - ">="
45
46
  - !ruby/object:Gem::Version
46
47
  version: 1.10.6
47
- name: bundler
48
- prerelease: false
49
48
  type: :development
49
+ prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.10.6
55
55
  - !ruby/object:Gem::Dependency
56
+ name: rake
56
57
  requirement: !ruby/object:Gem::Requirement
57
58
  requirements:
58
59
  - - ">="
59
60
  - !ruby/object:Gem::Version
60
61
  version: '10.0'
61
- name: rake
62
- prerelease: false
63
62
  type: :development
63
+ prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
@@ -85,7 +85,7 @@ homepage: https://github.com/liuming/embulk-input-lkqd
85
85
  licenses:
86
86
  - MIT
87
87
  metadata: {}
88
- post_install_message:
88
+ post_install_message:
89
89
  rdoc_options: []
90
90
  require_paths:
91
91
  - lib
@@ -100,9 +100,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
102
  requirements: []
103
- rubyforge_project:
103
+ rubyforge_project:
104
104
  rubygems_version: 2.6.8
105
- signing_key:
105
+ signing_key:
106
106
  specification_version: 4
107
107
  summary: LKQD input plugin for Embulk
108
108
  test_files: []