brainzz 0.0.11 → 0.0.12
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/README.md +104 -33
- data/lib/brainzz/commands/analytics_command.rb +4 -0
- data/lib/brainzz/commands/base_command.rb +7 -1
- data/lib/brainzz/commands/video_stats_by_day_command.rb +5 -2
- data/lib/brainzz/commands/video_stats_command.rb +4 -4
- data/lib/brainzz/commands/view_count_by_day_command.rb +0 -11
- data/lib/brainzz/commands/view_totals_command.rb +5 -2
- data/lib/brainzz/core.rb +44 -44
- data/lib/brainzz/factories/annotations_clickable_count.rb +4 -1
- data/lib/brainzz/factories/annotations_clicked_count.rb +4 -2
- data/lib/brainzz/factories/comment_count.rb +2 -1
- data/lib/brainzz/factories/dislike_count.rb +1 -0
- data/lib/brainzz/factories/like_count.rb +3 -2
- data/lib/brainzz/factories/share_count.rb +3 -2
- data/lib/brainzz/factories/subscribers_gained_count.rb +3 -1
- data/lib/brainzz/factories/subscribers_lost_count.rb +3 -1
- data/lib/brainzz/factories/view_count.rb +4 -3
- data/lib/brainzz/factories/view_duration.rb +2 -1
- data/lib/brainzz/factories/view_percentage.rb +2 -1
- data/lib/brainzz/models/video_stat.rb +7 -2
- data/lib/brainzz/params/video_stats_params.rb +20 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b5f82f5036c28151473f2fcebbffc4f602748de
|
4
|
+
data.tar.gz: 205663e5cbe802ead27977f180dc1ce55b940e77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b464322f717393ab637cf9fd3f8022a38d7d9c6ee824b161ab6edb751fc55ae36e51383a4fd96ed10737f9de69f809ddc959520260d70434871a9a8f117be02
|
7
|
+
data.tar.gz: f7dccc5ae1fb0ac178c6d6d7ddf07db73126d57a958c0578d2dfde0d0e3a2843ffceb6ce0019f655fa21d6ccab615bd4ead0936460f72e36bd31fb3f47f27e74
|
data/README.md
CHANGED
@@ -25,6 +25,7 @@ Check `config/dotenv/test.env` for the required keys.
|
|
25
25
|
The values in this file are required environment variables
|
26
26
|
when consuming this gem.
|
27
27
|
|
28
|
+
|
28
29
|
Environment Variables
|
29
30
|
---------------------
|
30
31
|
Brainzz requires the use of multiple environment variables:
|
@@ -37,12 +38,15 @@ Brainzz requires the use of multiple environment variables:
|
|
37
38
|
|
38
39
|
Place values in `config/dotenv/integration.env`.
|
39
40
|
|
41
|
+
|
40
42
|
### Attaining BRAINZZ_GOOGLE_API_KEY
|
41
43
|
|
42
44
|
Follow the instructions [here][atv-wiki-google-api-key]
|
43
45
|
to find the required values.
|
44
46
|
|
47
|
+
|
45
48
|
### Attaining BRAINZZ_REFRESH_TOKEN
|
49
|
+
|
46
50
|
An OAUTH refresh token for the BRAINZZ_CONTENT_OWNER Google account
|
47
51
|
uses BRAINZZ_CLIENT_SECRET and BRAINZZ_CLIENT_SECRET
|
48
52
|
|
@@ -58,8 +62,10 @@ uses BRAINZZ_CLIENT_SECRET and BRAINZZ_CLIENT_SECRET
|
|
58
62
|
- Exchange code for tokens
|
59
63
|
- Grab value for the Refresh Token and store
|
60
64
|
|
65
|
+
|
61
66
|
Interface
|
62
67
|
---------
|
68
|
+
|
63
69
|
All public endpoints are exposed in Brainzz::Core.
|
64
70
|
|
65
71
|
Every response from the public API is wrapped in a `Response` object
|
@@ -104,9 +110,10 @@ and video objects as the values.
|
|
104
110
|
|
105
111
|
#### Parameters
|
106
112
|
|
107
|
-
* video
|
108
|
-
* start date
|
109
|
-
* end date
|
113
|
+
* video ids (Array[String])
|
114
|
+
* start date (DateTime)
|
115
|
+
* end date (DateTime)
|
116
|
+
|
110
117
|
|
111
118
|
#### Result
|
112
119
|
|
@@ -130,236 +137,300 @@ corresponding to the following YouTube referrals:
|
|
130
137
|
|
131
138
|
The constants are defined in `Brainzz::ViewCountEnum`.
|
132
139
|
|
140
|
+
|
133
141
|
### view_totals_for
|
134
142
|
|
135
143
|
#### Parameters
|
144
|
+
|
136
145
|
Same as views_by_day_for.
|
137
146
|
|
147
|
+
|
138
148
|
#### Result
|
149
|
+
|
139
150
|
Same as views_by_day_for except date values are nil.
|
140
151
|
|
141
152
|
Views for date range are aggregated per source type.
|
142
153
|
|
154
|
+
|
143
155
|
### likes_by_day_for
|
144
156
|
|
145
157
|
#### Parameters
|
146
158
|
|
147
|
-
* video
|
148
|
-
* start date
|
149
|
-
* end date
|
159
|
+
* video ids (Array[String])
|
160
|
+
* start date (DateTime)
|
161
|
+
* end date (DateTime)
|
162
|
+
|
150
163
|
|
151
164
|
#### Result
|
152
165
|
|
153
166
|
An array of `Brainzz::LikeCount` objects ordered by date in ascending order.
|
154
167
|
|
168
|
+
|
155
169
|
### like_totals_for
|
156
170
|
|
157
171
|
#### Parameters
|
172
|
+
|
158
173
|
Same as likes_by_day_for.
|
159
174
|
|
175
|
+
|
160
176
|
#### Result
|
177
|
+
|
161
178
|
Same as likes_by_day_for except date values are nil.
|
162
179
|
|
163
180
|
Likes for date range are aggregated.
|
164
181
|
|
182
|
+
|
165
183
|
### shares_by_day_for
|
166
184
|
|
167
185
|
#### Parameters
|
168
186
|
|
169
|
-
* video
|
170
|
-
* start date
|
171
|
-
* end date
|
187
|
+
* video ids (Array[String])
|
188
|
+
* start date (DateTime)
|
189
|
+
* end date (DateTime)
|
190
|
+
|
172
191
|
|
173
192
|
#### Result
|
174
193
|
|
175
194
|
An array of `Brainzz::ShareCount` objects ordered by date in ascending order.
|
176
195
|
|
196
|
+
|
177
197
|
### share_totals_for
|
178
198
|
|
179
199
|
#### Parameters
|
200
|
+
|
180
201
|
Same as shares_by_day_for.
|
181
202
|
|
182
203
|
#### Result
|
204
|
+
|
183
205
|
Same as shares_by_day_for except date values are nil.
|
184
206
|
|
185
207
|
Shares for date range are aggregated.
|
186
208
|
|
209
|
+
|
187
210
|
### dislikes_by_day_for
|
188
211
|
|
189
212
|
#### Parameters
|
190
213
|
|
191
|
-
* video
|
192
|
-
* start date
|
193
|
-
* end date
|
214
|
+
* video ids (Array[String])
|
215
|
+
* start date (DateTime)
|
216
|
+
* end date (DateTime)
|
217
|
+
|
194
218
|
|
195
219
|
#### Result
|
196
220
|
|
197
221
|
An array of `Brainzz::DislikeCount` objects ordered by date in ascending order.
|
198
222
|
|
223
|
+
|
199
224
|
### dislike_totals_for
|
200
225
|
|
201
226
|
#### Parameters
|
227
|
+
|
202
228
|
Same as dislikes_by_day_for.
|
203
229
|
|
230
|
+
|
204
231
|
#### Result
|
232
|
+
|
205
233
|
Same as dislikes_by_day_for except date values are nil.
|
206
234
|
|
207
235
|
Dislikes for date range are aggregated.
|
208
236
|
|
237
|
+
|
209
238
|
### comments_by_day_for
|
210
239
|
|
211
240
|
#### Parameters
|
212
241
|
|
213
|
-
* video
|
214
|
-
* start date
|
215
|
-
* end date
|
242
|
+
* video ids (Array[String])
|
243
|
+
* start date (DateTime)
|
244
|
+
* end date (DateTime)
|
245
|
+
|
216
246
|
|
217
247
|
#### Result
|
218
248
|
|
219
249
|
An array of `Brainzz::CommentCount` objects ordered by date in ascending order.
|
220
250
|
|
251
|
+
|
221
252
|
### comment_totals_for
|
222
253
|
|
223
254
|
#### Parameters
|
255
|
+
|
224
256
|
Same as comments_by_day_for.
|
225
257
|
|
258
|
+
|
226
259
|
#### Result
|
260
|
+
|
227
261
|
Same as comments_by_day_for except date values are nil.
|
228
262
|
|
229
263
|
Comments for date range are aggregated.
|
230
264
|
|
265
|
+
|
231
266
|
### subscribers_gained_by_day_for
|
232
267
|
|
233
268
|
#### Parameters
|
234
269
|
|
235
|
-
* video
|
236
|
-
* start date
|
237
|
-
* end date
|
270
|
+
* video ids (Array[String])
|
271
|
+
* start date (DateTime)
|
272
|
+
* end date (DateTime)
|
273
|
+
|
238
274
|
|
239
275
|
#### Result
|
240
276
|
|
241
277
|
An array of `Brainzz::SubscribersGainedCount` objects ordered by date in ascending order.
|
242
278
|
|
279
|
+
|
243
280
|
### subscribers_gained_totals_for
|
244
281
|
|
245
282
|
#### Parameters
|
283
|
+
|
246
284
|
Same as subscribers_gained_by_day_for.
|
247
285
|
|
286
|
+
|
248
287
|
#### Result
|
288
|
+
|
249
289
|
Same as subscribers_gained_by_day_for except date values are nil.
|
250
290
|
|
251
291
|
SubscribersGained for date range are aggregated.
|
252
292
|
|
293
|
+
|
253
294
|
### subscribers_lost_by_day_for
|
254
295
|
|
255
296
|
#### Parameters
|
256
297
|
|
257
|
-
* video
|
258
|
-
* start date
|
259
|
-
* end date
|
298
|
+
* video ids (Array[String])
|
299
|
+
* start date (DateTime)
|
300
|
+
* end date (DateTime)
|
301
|
+
|
260
302
|
|
261
303
|
#### Result
|
262
304
|
|
263
305
|
An array of `Brainzz::SubscribersLostCount` objects ordered by date in ascending order.
|
264
306
|
|
307
|
+
|
265
308
|
### subscribers_lost_totals_for
|
266
309
|
|
267
310
|
#### Parameters
|
311
|
+
|
268
312
|
Same as subscribers_lost_by_day_for.
|
269
313
|
|
314
|
+
|
270
315
|
#### Result
|
316
|
+
|
271
317
|
Same as subscribers_lost_by_day_for except date values are nil.
|
272
318
|
|
273
319
|
SubscribersLost for date range are aggregated.
|
274
320
|
|
321
|
+
|
275
322
|
### annotations_clickable_by_day_for
|
276
323
|
|
277
324
|
#### Parameters
|
278
325
|
|
279
|
-
* video
|
280
|
-
* start date
|
281
|
-
* end date
|
326
|
+
* video ids (Array[String])
|
327
|
+
* start date (DateTime)
|
328
|
+
* end date (DateTime)
|
329
|
+
|
282
330
|
|
283
331
|
#### Result
|
284
332
|
|
285
333
|
An array of `Brainzz::AnnotationsClickableCount` objects ordered by date in ascending order.
|
286
334
|
|
335
|
+
|
287
336
|
### annotations_clickable_totals_for
|
288
337
|
|
289
338
|
#### Parameters
|
339
|
+
|
290
340
|
Same as annotations_clickable_by_day_for.
|
291
341
|
|
342
|
+
|
292
343
|
#### Result
|
344
|
+
|
293
345
|
Same as annotations_clickable_by_day_for except date values are nil.
|
294
346
|
|
295
347
|
AnnotationsClickable for date range are aggregated.
|
296
348
|
|
349
|
+
|
297
350
|
### annotations_clicked_by_day_for
|
298
351
|
|
299
352
|
#### Parameters
|
300
353
|
|
301
|
-
* video
|
302
|
-
* start date
|
303
|
-
* end date
|
354
|
+
* video ids (Array[String])
|
355
|
+
* start date (DateTime)
|
356
|
+
* end date (DateTime)
|
357
|
+
|
304
358
|
|
305
359
|
#### Result
|
306
360
|
|
307
361
|
An array of `Brainzz::AnnotationsClickedCount` objects ordered by date in ascending order.
|
308
362
|
|
363
|
+
|
309
364
|
### annotations_clicked_totals_for
|
310
365
|
|
311
366
|
#### Parameters
|
367
|
+
|
312
368
|
Same as annotations_clicked_by_day_for.
|
313
369
|
|
370
|
+
|
314
371
|
#### Result
|
372
|
+
|
315
373
|
Same as annotations_clicked_by_day_for except date values are nil.
|
316
374
|
|
317
375
|
AnnotationsClicked for date range are aggregated.
|
318
376
|
|
377
|
+
|
319
378
|
### view_percentages_by_day_for
|
320
379
|
|
321
380
|
#### Parameters
|
322
381
|
|
323
|
-
* video
|
324
|
-
* start date
|
325
|
-
* end date
|
382
|
+
* video ids (Array[String])
|
383
|
+
* start date (DateTime)
|
384
|
+
* end date (DateTime)
|
385
|
+
|
326
386
|
|
327
387
|
#### Result
|
328
388
|
|
329
389
|
An array of `Brainzz::ViewPercentage` objects ordered by date in ascending order.
|
330
390
|
|
391
|
+
|
331
392
|
### view_percentage_totals_for
|
332
393
|
|
333
394
|
#### Parameters
|
395
|
+
|
334
396
|
Same as view_percentages_by_day_for.
|
335
397
|
|
398
|
+
|
336
399
|
#### Result
|
400
|
+
|
337
401
|
Same as view_percentages_by_day_for except date values are nil.
|
338
402
|
|
339
403
|
ViewPercentages for date range are aggregated.
|
340
404
|
|
405
|
+
|
341
406
|
### view_durations_by_day_for
|
342
407
|
|
343
408
|
#### Parameters
|
344
409
|
|
345
|
-
* video
|
346
|
-
* start date
|
347
|
-
* end date
|
410
|
+
* video ids (Array[String])
|
411
|
+
* start date (DateTime)
|
412
|
+
* end date (DateTime)
|
413
|
+
|
348
414
|
|
349
415
|
#### Result
|
350
416
|
|
351
417
|
An array of `Brainzz::ViewDuration` objects ordered by date in ascending order.
|
352
418
|
|
419
|
+
|
353
420
|
### view_duration_totals_for
|
354
421
|
|
355
422
|
#### Parameters
|
423
|
+
|
356
424
|
Same as view_durations_by_day_for.
|
357
425
|
|
426
|
+
|
358
427
|
#### Result
|
428
|
+
|
359
429
|
Same as view_durations_by_day_for except date values are nil.
|
360
430
|
|
361
431
|
ViewDurations for date range are aggregated.
|
362
432
|
|
433
|
+
|
363
434
|
Factories
|
364
435
|
---------
|
365
436
|
|
@@ -18,7 +18,9 @@ module Brainzz
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def params(parameters = nil)
|
21
|
-
{}
|
21
|
+
params = {}
|
22
|
+
params['dimensions'] = dimensions.join(',') unless dimensions.empty?
|
23
|
+
params
|
22
24
|
end
|
23
25
|
|
24
26
|
def headers
|
@@ -27,6 +29,10 @@ module Brainzz
|
|
27
29
|
}
|
28
30
|
end
|
29
31
|
|
32
|
+
def dimensions
|
33
|
+
[]
|
34
|
+
end
|
35
|
+
|
30
36
|
def url(parameters)
|
31
37
|
connection.build_url endpoint, params(parameters)
|
32
38
|
end
|
@@ -3,9 +3,9 @@ module Brainzz
|
|
3
3
|
class << self
|
4
4
|
private
|
5
5
|
|
6
|
-
def on_execute(
|
7
|
-
video_stats_params = VideoStatsParams.new
|
8
|
-
:
|
6
|
+
def on_execute(video_ids, start_date, end_date)
|
7
|
+
video_stats_params = VideoStatsParams.new({
|
8
|
+
:video_ids => video_ids,
|
9
9
|
:start_date => start_date,
|
10
10
|
:end_date => end_date,
|
11
11
|
})
|
@@ -23,7 +23,7 @@ module Brainzz
|
|
23
23
|
|
24
24
|
def params(video_stats_params)
|
25
25
|
super.merge({
|
26
|
-
'filters' => "video==#{video_stats_params.
|
26
|
+
'filters' => "video==#{video_stats_params.video_ids.join(',')}",
|
27
27
|
})
|
28
28
|
end
|
29
29
|
end
|
@@ -1,17 +1,6 @@
|
|
1
1
|
module Brainzz
|
2
2
|
class ViewCountByDayCommand < ViewTotalsCommand
|
3
3
|
extend VideoStatsByDayCommand
|
4
|
-
|
5
4
|
make_with_response ViewCountResponse
|
6
|
-
|
7
|
-
class << self
|
8
|
-
private
|
9
|
-
|
10
|
-
def params(video_stats_params)
|
11
|
-
super.merge({
|
12
|
-
'dimensions' => 'day,insightTrafficSourceType',
|
13
|
-
})
|
14
|
-
end
|
15
|
-
end
|
16
5
|
end
|
17
6
|
end
|
@@ -5,10 +5,13 @@ module Brainzz
|
|
5
5
|
class << self
|
6
6
|
private
|
7
7
|
|
8
|
+
def dimensions
|
9
|
+
super << 'insightTrafficSourceType'
|
10
|
+
end
|
11
|
+
|
8
12
|
def params(video_stats_params)
|
9
13
|
super.merge({
|
10
|
-
'metrics'
|
11
|
-
'dimensions' => 'insightTrafficSourceType',
|
14
|
+
'metrics' => 'views',
|
12
15
|
})
|
13
16
|
end
|
14
17
|
end
|
data/lib/brainzz/core.rb
CHANGED
@@ -10,92 +10,92 @@ module Brainzz
|
|
10
10
|
VideoDetailsCommand.execute video_ids, options
|
11
11
|
end
|
12
12
|
|
13
|
-
def views_by_day_for(
|
14
|
-
ViewCountByDayCommand.execute
|
13
|
+
def views_by_day_for(video_ids, start_date, end_date)
|
14
|
+
ViewCountByDayCommand.execute video_ids, start_date, end_date
|
15
15
|
end
|
16
16
|
|
17
|
-
def view_totals_for(
|
18
|
-
ViewTotalsCommand.execute
|
17
|
+
def view_totals_for(video_ids, start_date, end_date)
|
18
|
+
ViewTotalsCommand.execute video_ids, start_date, end_date
|
19
19
|
end
|
20
20
|
|
21
|
-
def likes_by_day_for(
|
22
|
-
LikeCountByDayCommand.execute
|
21
|
+
def likes_by_day_for(video_ids, start_date, end_date)
|
22
|
+
LikeCountByDayCommand.execute video_ids, start_date, end_date
|
23
23
|
end
|
24
24
|
|
25
|
-
def like_totals_for(
|
26
|
-
LikeTotalsCommand.execute
|
25
|
+
def like_totals_for(video_ids, start_date, end_date)
|
26
|
+
LikeTotalsCommand.execute video_ids, start_date, end_date
|
27
27
|
end
|
28
28
|
|
29
|
-
def shares_by_day_for(
|
30
|
-
ShareCountByDayCommand.execute
|
29
|
+
def shares_by_day_for(video_ids, start_date, end_date)
|
30
|
+
ShareCountByDayCommand.execute video_ids, start_date, end_date
|
31
31
|
end
|
32
32
|
|
33
|
-
def share_totals_for(
|
34
|
-
ShareTotalsCommand.execute
|
33
|
+
def share_totals_for(video_ids, start_date, end_date)
|
34
|
+
ShareTotalsCommand.execute video_ids, start_date, end_date
|
35
35
|
end
|
36
36
|
|
37
|
-
def dislikes_by_day_for(
|
38
|
-
DislikeCountByDayCommand.execute
|
37
|
+
def dislikes_by_day_for(video_ids, start_date, end_date)
|
38
|
+
DislikeCountByDayCommand.execute video_ids, start_date, end_date
|
39
39
|
end
|
40
40
|
|
41
|
-
def dislike_totals_for(
|
42
|
-
DislikeTotalsCommand.execute
|
41
|
+
def dislike_totals_for(video_ids, start_date, end_date)
|
42
|
+
DislikeTotalsCommand.execute video_ids, start_date, end_date
|
43
43
|
end
|
44
44
|
|
45
|
-
def comments_by_day_for(
|
46
|
-
CommentCountByDayCommand.execute
|
45
|
+
def comments_by_day_for(video_ids, start_date, end_date)
|
46
|
+
CommentCountByDayCommand.execute video_ids, start_date, end_date
|
47
47
|
end
|
48
48
|
|
49
|
-
def comment_totals_for(
|
50
|
-
CommentTotalsCommand.execute
|
49
|
+
def comment_totals_for(video_ids, start_date, end_date)
|
50
|
+
CommentTotalsCommand.execute video_ids, start_date, end_date
|
51
51
|
end
|
52
52
|
|
53
|
-
def subscribers_gained_by_day_for(
|
54
|
-
SubscribersGainedByDayCommand.execute
|
53
|
+
def subscribers_gained_by_day_for(video_ids, start_date, end_date)
|
54
|
+
SubscribersGainedByDayCommand.execute video_ids, start_date, end_date
|
55
55
|
end
|
56
56
|
|
57
|
-
def subscribers_gained_totals_for(
|
58
|
-
SubscribersGainedTotalsCommand.execute
|
57
|
+
def subscribers_gained_totals_for(video_ids, start_date, end_date)
|
58
|
+
SubscribersGainedTotalsCommand.execute video_ids, start_date, end_date
|
59
59
|
end
|
60
60
|
|
61
|
-
def subscribers_lost_by_day_for(
|
62
|
-
SubscribersLostByDayCommand.execute
|
61
|
+
def subscribers_lost_by_day_for(video_ids, start_date, end_date)
|
62
|
+
SubscribersLostByDayCommand.execute video_ids, start_date, end_date
|
63
63
|
end
|
64
64
|
|
65
|
-
def subscribers_lost_totals_for(
|
66
|
-
SubscribersLostTotalsCommand.execute
|
65
|
+
def subscribers_lost_totals_for(video_ids, start_date, end_date)
|
66
|
+
SubscribersLostTotalsCommand.execute video_ids, start_date, end_date
|
67
67
|
end
|
68
68
|
|
69
|
-
def annotations_clickable_by_day_for(
|
70
|
-
AnnotationsClickableByDayCommand.execute
|
69
|
+
def annotations_clickable_by_day_for(video_ids, start_date, end_date)
|
70
|
+
AnnotationsClickableByDayCommand.execute video_ids, start_date, end_date
|
71
71
|
end
|
72
72
|
|
73
|
-
def annotations_clickable_totals_for(
|
74
|
-
AnnotationsClickableTotalsCommand.execute
|
73
|
+
def annotations_clickable_totals_for(video_ids, start_date, end_date)
|
74
|
+
AnnotationsClickableTotalsCommand.execute video_ids, start_date, end_date
|
75
75
|
end
|
76
76
|
|
77
|
-
def annotations_clicked_by_day_for(
|
78
|
-
AnnotationsClickedByDayCommand.execute
|
77
|
+
def annotations_clicked_by_day_for(video_ids, start_date, end_date)
|
78
|
+
AnnotationsClickedByDayCommand.execute video_ids, start_date, end_date
|
79
79
|
end
|
80
80
|
|
81
|
-
def annotations_clicked_totals_for(
|
82
|
-
AnnotationsClickedTotalsCommand.execute
|
81
|
+
def annotations_clicked_totals_for(video_ids, start_date, end_date)
|
82
|
+
AnnotationsClickedTotalsCommand.execute video_ids, start_date, end_date
|
83
83
|
end
|
84
84
|
|
85
|
-
def view_percentages_by_day_for(
|
86
|
-
ViewPercentagesByDayCommand.execute
|
85
|
+
def view_percentages_by_day_for(video_ids, start_date, end_date)
|
86
|
+
ViewPercentagesByDayCommand.execute video_ids, start_date, end_date
|
87
87
|
end
|
88
88
|
|
89
|
-
def view_percentage_totals_for(
|
90
|
-
ViewPercentageTotalsCommand.execute
|
89
|
+
def view_percentage_totals_for(video_ids, start_date, end_date)
|
90
|
+
ViewPercentageTotalsCommand.execute video_ids, start_date, end_date
|
91
91
|
end
|
92
92
|
|
93
|
-
def view_durations_by_day_for(
|
94
|
-
ViewDurationsByDayCommand.execute
|
93
|
+
def view_durations_by_day_for(video_ids, start_date, end_date)
|
94
|
+
ViewDurationsByDayCommand.execute video_ids, start_date, end_date
|
95
95
|
end
|
96
96
|
|
97
|
-
def view_duration_totals_for(
|
98
|
-
ViewDurationTotalsCommand.execute
|
97
|
+
def view_duration_totals_for(video_ids, start_date, end_date)
|
98
|
+
ViewDurationTotalsCommand.execute video_ids, start_date, end_date
|
99
99
|
end
|
100
100
|
end
|
101
101
|
end
|
@@ -1,7 +1,10 @@
|
|
1
1
|
FactoryGirl.define do
|
2
2
|
factory :brainzz_annotations_clickable_count,
|
3
|
-
|
3
|
+
:class => Brainzz::AnnotationsClickableCount do
|
4
|
+
|
5
|
+
video_id { generate :brainzz_video_id }
|
4
6
|
annotations_clickable { rand(1_000_000) + 1 }
|
7
|
+
|
5
8
|
day { Time.parse (DateTime.now - rand(100)).strftime('%F') }
|
6
9
|
|
7
10
|
factory :brainzz_aggregate_annotations_clickable_count do
|
@@ -1,8 +1,10 @@
|
|
1
1
|
FactoryGirl.define do
|
2
2
|
factory :brainzz_annotations_clicked_count,
|
3
|
-
|
3
|
+
:class => Brainzz::AnnotationsClickedCount do
|
4
|
+
|
5
|
+
video_id { generate :brainzz_video_id }
|
4
6
|
annotations_clicked { rand(1_000_000) + 1 }
|
5
|
-
day
|
7
|
+
day { Time.parse (DateTime.now - rand(100)).strftime('%F') }
|
6
8
|
|
7
9
|
factory :brainzz_aggregate_annotations_clicked_count do
|
8
10
|
day nil
|
@@ -1,7 +1,8 @@
|
|
1
1
|
FactoryGirl.define do
|
2
2
|
factory :brainzz_comment_count, :class => Brainzz::CommentCount do
|
3
|
+
video_id { generate :brainzz_video_id }
|
3
4
|
comments { rand(1_000_000) + 1 }
|
4
|
-
day
|
5
|
+
day { Time.parse (DateTime.now - rand(100)).strftime('%F') }
|
5
6
|
|
6
7
|
factory :brainzz_aggregate_comment_count do
|
7
8
|
day nil
|
@@ -1,7 +1,8 @@
|
|
1
1
|
FactoryGirl.define do
|
2
2
|
factory :brainzz_like_count, :class => Brainzz::LikeCount do
|
3
|
-
|
4
|
-
|
3
|
+
video_id { generate :brainzz_video_id }
|
4
|
+
likes { rand(1_000_000) + 1 }
|
5
|
+
day { Time.parse (DateTime.now - rand(100)).strftime('%F') }
|
5
6
|
|
6
7
|
factory :brainzz_aggregate_like_count do
|
7
8
|
day nil
|
@@ -1,7 +1,8 @@
|
|
1
1
|
FactoryGirl.define do
|
2
2
|
factory :brainzz_share_count, :class => Brainzz::ShareCount do
|
3
|
-
|
4
|
-
|
3
|
+
video_id { generate :brainzz_video_id }
|
4
|
+
shares { rand(1_000_000) + 1 }
|
5
|
+
day { Time.parse (DateTime.now - rand(100)).strftime('%F') }
|
5
6
|
|
6
7
|
factory :brainzz_aggregate_share_count do
|
7
8
|
day nil
|
@@ -1,6 +1,8 @@
|
|
1
1
|
FactoryGirl.define do
|
2
2
|
factory :brainzz_subscribers_gained_count,
|
3
|
-
|
3
|
+
:class => Brainzz::SubscribersGainedCount do
|
4
|
+
|
5
|
+
video_id { generate :brainzz_video_id }
|
4
6
|
subscribers_gained { rand(1_000_000) + 1 }
|
5
7
|
day { Time.parse (DateTime.now - rand(100)).strftime('%F') }
|
6
8
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
FactoryGirl.define do
|
2
2
|
factory :brainzz_subscribers_lost_count,
|
3
|
-
|
3
|
+
:class => Brainzz::SubscribersLostCount do
|
4
|
+
|
5
|
+
video_id { generate :brainzz_video_id }
|
4
6
|
subscribers_lost { rand(1_000_000) + 1 }
|
5
7
|
day { Time.parse (DateTime.now - rand(100)).strftime('%F') }
|
6
8
|
|
@@ -1,8 +1,9 @@
|
|
1
1
|
FactoryGirl.define do
|
2
2
|
factory :brainzz_view_count, :class => Brainzz::ViewCount do
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
video_id { generate :brainzz_video_id }
|
4
|
+
views { rand(1_000_000) + 1 }
|
5
|
+
day { Time.parse (DateTime.now - rand(100)).strftime('%F') }
|
6
|
+
source { generate :brainzz_view_count_source }
|
6
7
|
|
7
8
|
factory :brainzz_aggregate_view_count do
|
8
9
|
day nil
|
@@ -1,7 +1,8 @@
|
|
1
1
|
FactoryGirl.define do
|
2
2
|
factory :brainzz_view_duration, :class => Brainzz::ViewDuration do
|
3
|
+
video_id { generate :brainzz_video_id }
|
3
4
|
duration { rand(1_000_000) + 1 }
|
4
|
-
day
|
5
|
+
day { Time.parse (DateTime.now - rand(100)).strftime('%F') }
|
5
6
|
|
6
7
|
factory :brainzz_aggregate_view_duration do
|
7
8
|
day nil
|
@@ -1,7 +1,8 @@
|
|
1
1
|
FactoryGirl.define do
|
2
2
|
factory :brainzz_view_percentage, :class => Brainzz::ViewPercentage do
|
3
|
+
video_id { generate :brainzz_video_id }
|
3
4
|
percentage { rand(1_000_000) / 10000.0 }
|
4
|
-
day
|
5
|
+
day { Time.parse (DateTime.now - rand(100)).strftime('%F') }
|
5
6
|
|
6
7
|
factory :brainzz_aggregate_view_percentage do
|
7
8
|
day nil
|
@@ -1,11 +1,12 @@
|
|
1
1
|
module Brainzz
|
2
2
|
class VideoStat < BaseModel
|
3
|
-
attr_accessor :day
|
3
|
+
attr_accessor :day, :video_id
|
4
4
|
|
5
5
|
def initialize(hash)
|
6
6
|
@hash = hash
|
7
7
|
|
8
|
-
@day
|
8
|
+
@day = transform_date(day_data)
|
9
|
+
@video_id = transform(video_id_data)
|
9
10
|
end
|
10
11
|
|
11
12
|
private
|
@@ -22,6 +23,10 @@ module Brainzz
|
|
22
23
|
data && keys['day'] && data[keys['day']]
|
23
24
|
end
|
24
25
|
|
26
|
+
def video_id_data
|
27
|
+
data && keys['video'] && data[keys['video']]
|
28
|
+
end
|
29
|
+
|
25
30
|
def normalize_stat(stat)
|
26
31
|
stat.to_i if stat
|
27
32
|
end
|
@@ -1,14 +1,31 @@
|
|
1
1
|
module Brainzz
|
2
2
|
class VideoStatsParams < AnalyticsParams
|
3
|
-
attr_reader :
|
3
|
+
attr_reader :video_ids
|
4
4
|
|
5
5
|
def initialize(params)
|
6
6
|
super
|
7
|
-
@
|
7
|
+
@video_ids = normalize(params[:video_ids])
|
8
8
|
end
|
9
9
|
|
10
10
|
def valid?
|
11
|
-
!!(super &&
|
11
|
+
!!(super && !video_ids.empty?)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def normalize(video_ids)
|
17
|
+
video_ids = [video_ids] if video_ids.is_a?(String)
|
18
|
+
|
19
|
+
return [] unless video_ids
|
20
|
+
|
21
|
+
ids = []
|
22
|
+
|
23
|
+
video_ids.each do |video_id|
|
24
|
+
id = super(video_id)
|
25
|
+
ids << id if id
|
26
|
+
end
|
27
|
+
|
28
|
+
ids
|
12
29
|
end
|
13
30
|
end
|
14
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brainzz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Travis Herrick
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-06-
|
13
|
+
date: 2015-06-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday
|