appcues_data_uploader 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 +4 -4
- data/lib/appcues_data_uploader.rb +13 -5
- data/lib/appcues_data_uploader/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f8bb6dc96485d07fb821f6559e13588d1d032cd
|
4
|
+
data.tar.gz: 33de9f67aca03c4b6935e039766c900b6970db44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea11670e11b4971c70adc307f93f31ba438f6f6ccff67fec061bdb64db6be3f500cc8ad4522e6e5466fa2fe9e22947241ebab872bdb91a98f3df6b701afc5c82
|
7
|
+
data.tar.gz: 77273d66e4e529c09c51fe219d79d3e8783a94d52f03932ee662d485551dcbf4a9915db77bb15551ea92fa37d4363e41b6802485a01f5a2cb907e3f468e795ca
|
@@ -31,7 +31,7 @@ class AppcuesDataUploader
|
|
31
31
|
|
32
32
|
option_parser = OptionParser.new do |opts|
|
33
33
|
opts.banner = <<-EOT
|
34
|
-
Usage:
|
34
|
+
Usage: appcues-data-uploader [options] -a account_id [filename ...]
|
35
35
|
|
36
36
|
Uploads profile data from one or more CSVs to the Appcues API.
|
37
37
|
If no filename or a filename of '-' is given, STDIN is used.
|
@@ -52,6 +52,8 @@ Will result in two profile updates being sent to the API:
|
|
52
52
|
|
53
53
|
{"account_id": "999", "user_id": "123", "profile_update": {"first_name": "Pete", "has_posse": false, "height_in_inches": 68.5}}
|
54
54
|
{"account_id": "999", "user_id": "456", "profile_update": {"first_name": "André", "has_posse": true, "height_in_inches": 88}}
|
55
|
+
|
56
|
+
See https://github.com/appcues/data-uploader for more information.
|
55
57
|
EOT
|
56
58
|
|
57
59
|
opts.separator ""
|
@@ -87,10 +89,16 @@ Will result in two profile updates being sent to the API:
|
|
87
89
|
|
88
90
|
if !options.account_id
|
89
91
|
STDERR.puts "You must specify an account ID with the -a option."
|
92
|
+
STDERR.puts "Run `appcues-data-uploader --help` for more information."
|
90
93
|
exit 1
|
91
94
|
end
|
92
95
|
|
93
|
-
|
96
|
+
begin
|
97
|
+
new(options).perform_uploads()
|
98
|
+
rescue Exception => e
|
99
|
+
STDERR.puts "#{e.class}: #{e.message}"
|
100
|
+
exit 255
|
101
|
+
end
|
94
102
|
end
|
95
103
|
end
|
96
104
|
|
@@ -137,7 +145,7 @@ private
|
|
137
145
|
user_activities = []
|
138
146
|
|
139
147
|
CSV.new(input_fh, headers: true).each do |row|
|
140
|
-
row_hash = row.
|
148
|
+
row_hash = row.to_hash
|
141
149
|
|
142
150
|
if !user_id_column
|
143
151
|
user_id_column = get_user_id_column(row_hash)
|
@@ -178,7 +186,7 @@ private
|
|
178
186
|
end
|
179
187
|
|
180
188
|
if failed_uas.count > 0
|
181
|
-
debug "
|
189
|
+
debug "Retrying #{failed_uas.count} requests."
|
182
190
|
make_activity_requests(failed_uas)
|
183
191
|
end
|
184
192
|
end
|
@@ -214,7 +222,7 @@ private
|
|
214
222
|
canonical_key = key.gsub(/[^a-zA-Z]/, '').downcase
|
215
223
|
return key if canonical_key == 'userid'
|
216
224
|
end
|
217
|
-
raise
|
225
|
+
raise "Couldn't detect user ID column from CSV input. Ensure that the CSV data starts with headers, and one is named like 'user_id'."
|
218
226
|
end
|
219
227
|
|
220
228
|
## Prints a message to STDERR unless we're in quiet mode.
|