yt 0.22.0 → 0.22.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +1 -1
- data/lib/yt/associations/has_reports.rb +12 -9
- data/lib/yt/collections/reports.rb +6 -1
- data/lib/yt/version.rb +1 -1
- data/spec/requests/as_content_owner/channel_spec.rb +921 -1
- data/spec/requests/as_content_owner/playlist_spec.rb +336 -0
- data/spec/requests/as_content_owner/video_spec.rb +792 -2
- 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: 5756c73d548ca942b1ea77046632204c4bd571c0
|
4
|
+
data.tar.gz: 3dc5604dc683f5207397a8438a89753e11f77104
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6db2497ab1f4e7fa497d1dcaa5ec259a8623e09b03758ad1db84009a06a7c40bf27e1abcb70118cf5e6e475b63e4004883bde843fd09539f48ddad79b55e1481
|
7
|
+
data.tar.gz: 4f559c21aa27f9feb93ccfa2eaefc05530c5dc0956c3b7b52eae95cfb09296e4f1eba4585bc9d4f54c92bfdf16db97d74cce7c305fec6cd62c595aa5eba9a7a5
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,12 @@ For more information about changelogs, check
|
|
6
6
|
[Keep a Changelog](http://keepachangelog.com) and
|
7
7
|
[Vandamme](http://tech-angels.github.io/vandamme).
|
8
8
|
|
9
|
+
## 0.22.1 - 2015-05-13
|
10
|
+
|
11
|
+
* [FEATURE] New `by: :country` option for channel, video and playlist reports
|
12
|
+
* [FEATURE] New `by: :state` option for channel, video and playlist reports
|
13
|
+
* [FEATURE] New `:in` option to limit reports to a country
|
14
|
+
|
9
15
|
## 0.22.0 - 2015-04-30
|
10
16
|
|
11
17
|
**How to upgrade**
|
data/README.md
CHANGED
@@ -41,7 +41,7 @@ To install on your system, run
|
|
41
41
|
|
42
42
|
To use inside a bundled Ruby project, add this line to the Gemfile:
|
43
43
|
|
44
|
-
gem 'yt', '~> 0.22.
|
44
|
+
gem 'yt', '~> 0.22.1'
|
45
45
|
|
46
46
|
Since the gem follows [Semantic Versioning](http://semver.org),
|
47
47
|
indicating the full version in your Gemfile (~> *major*.*minor*.*patch*)
|
@@ -22,7 +22,7 @@ module Yt
|
|
22
22
|
# for the entire time-range (under the key +:total+).
|
23
23
|
# @example Get the $1 for the whole last week:
|
24
24
|
# resource.$1 since: 2.weeks.ago, until: 1.week.ago, by: :range
|
25
|
-
# # => {
|
25
|
+
# # => {total: 564.0}
|
26
26
|
# @macro report
|
27
27
|
|
28
28
|
# @!macro [new] report_by_day
|
@@ -146,28 +146,31 @@ module Yt
|
|
146
146
|
define_method metric do |options = {}|
|
147
147
|
from = options[:since] || options[:from] || (metric == :viewer_percentage ? 3.months.ago : 5.days.ago)
|
148
148
|
to = options[:until] || options[:to] || (metric == :viewer_percentage ? Date.today : 1.day.ago)
|
149
|
+
location = options[:in]
|
150
|
+
country = location.is_a?(Hash) ? location[:country] : location
|
151
|
+
|
149
152
|
range = Range.new *[from, to].map(&:to_date)
|
150
153
|
dimension = options[:by] || (metric == :viewer_percentage ? :gender_age_group : :day)
|
151
154
|
|
152
|
-
ivar = instance_variable_get "@#{metric}_#{dimension}"
|
153
|
-
instance_variable_set "@#{metric}_#{dimension}", ivar || {}
|
155
|
+
ivar = instance_variable_get "@#{metric}_#{dimension}_#{country}"
|
156
|
+
instance_variable_set "@#{metric}_#{dimension}_#{country}", ivar || {}
|
154
157
|
|
155
158
|
case dimension
|
156
159
|
when :day
|
157
160
|
Hash[*range.flat_map do |date|
|
158
|
-
[date, instance_variable_get("@#{metric}_#{dimension}")[date] ||= send("range_#{metric}", range, dimension)[date]]
|
161
|
+
[date, instance_variable_get("@#{metric}_#{dimension}_#{country}")[date] ||= send("range_#{metric}", range, dimension, country)[date]]
|
159
162
|
end]
|
160
163
|
else
|
161
|
-
instance_variable_get("@#{metric}_#{dimension}")[range] ||= send("range_#{metric}", range, dimension)
|
164
|
+
instance_variable_get("@#{metric}_#{dimension}_#{country}")[range] ||= send("range_#{metric}", range, dimension, country)
|
162
165
|
end
|
163
166
|
end
|
164
167
|
end
|
165
168
|
|
166
169
|
def define_range_metric_method(metric, type)
|
167
|
-
define_method "range_#{metric}" do |date_range, dimension|
|
168
|
-
ivar = instance_variable_get "@range_#{metric}_#{dimension}"
|
169
|
-
instance_variable_set "@range_#{metric}_#{dimension}", ivar || {}
|
170
|
-
instance_variable_get("@range_#{metric}_#{dimension}")[date_range] ||= send("all_#{metric}").within date_range, dimension, type
|
170
|
+
define_method "range_#{metric}" do |date_range, dimension, country|
|
171
|
+
ivar = instance_variable_get "@range_#{metric}_#{dimension}_#{country}"
|
172
|
+
instance_variable_set "@range_#{metric}_#{dimension}_#{country}", ivar || {}
|
173
|
+
instance_variable_get("@range_#{metric}_#{dimension}_#{country}")[date_range] ||= send("all_#{metric}").within date_range, country, dimension, type
|
171
174
|
end
|
172
175
|
private "range_#{metric}"
|
173
176
|
end
|
@@ -13,6 +13,8 @@ module Yt
|
|
13
13
|
hash[:video] = {name: 'video', parse: ->(video_id, value) { [Yt::Video.new(id: video_id, auth: @auth), value] } }
|
14
14
|
hash[:playlist] = {name: 'playlist', parse: ->(playlist_id, value) { [Yt::Playlist.new(id: playlist_id, auth: @auth), value] } }
|
15
15
|
hash[:device_type] = {name: 'deviceType', parse: ->(type, value) { [type.downcase.to_sym, value] } }
|
16
|
+
hash[:country] = {name: 'country', parse: ->(country_code, *values) { [country_code, values.last] } }
|
17
|
+
hash[:state] = {name: 'province', parse: ->(country_and_state_code, *values) { [country_and_state_code[3..-1], values.last] } }
|
16
18
|
hash[:gender_age_group] = {name: 'gender,ageGroup', parse: ->(gender, *values) { [gender.downcase.to_sym, *values] }}
|
17
19
|
hash[:gender] = {name: 'gender', parse: ->(gender, value) { [gender.downcase.to_sym, value] } }
|
18
20
|
hash[:age_group] = {name: 'ageGroup', parse: ->(age_group, value) { [age_group[3..-1], value] } }
|
@@ -48,9 +50,10 @@ module Yt
|
|
48
50
|
|
49
51
|
attr_writer :metric
|
50
52
|
|
51
|
-
def within(days_range, dimension, type, try_again = true)
|
53
|
+
def within(days_range, country, dimension, type, try_again = true)
|
52
54
|
@days_range = days_range
|
53
55
|
@dimension = dimension
|
56
|
+
@country = country
|
54
57
|
if dimension == :gender_age_group # array of array
|
55
58
|
Hash.new{|h,k| h[k] = Hash.new 0.0}.tap do |hash|
|
56
59
|
each{|gender, age_group, value| hash[gender][age_group[3..-1]] = value}
|
@@ -101,6 +104,8 @@ module Yt
|
|
101
104
|
params['max-results'] = 25 if @dimension == :embedded_player_location
|
102
105
|
params['max-results'] = 25 if @dimension == :related_video
|
103
106
|
params['sort'] = "-#{@metric.to_s.camelize(:lower)}" if @dimension.in? [:video, :playlist, :embedded_player_location, :related_video]
|
107
|
+
params[:filters] = ((params[:filters] || '').split(';') + ["country==US"]).compact.uniq.join(';') if @dimension == :state
|
108
|
+
params[:filters] = ((params[:filters] || '').split(';') + ["country==#{@country}"]).compact.uniq.join(';') if @country
|
104
109
|
params[:filters] = ((params[:filters] || '').split(';') + ['isCurated==1']).compact.uniq.join(';') if @dimension == :playlist
|
105
110
|
params[:filters] = ((params[:filters] || '').split(';') + ['insightPlaybackLocationType==EMBEDDED']).compact.uniq.join(';') if @dimension == :embedded_player_location
|
106
111
|
params[:filters] = ((params[:filters] || '').split(';') + ['insightTrafficSourceType==RELATED_VIDEO']).compact.uniq.join(';') if @dimension == :related_video
|
data/lib/yt/version.rb
CHANGED
@@ -35,6 +35,40 @@ describe Yt::Channel, :partner do
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
+
describe 'earnings can be retrieved for a single country' do
|
39
|
+
let(:country_code) { 'US' }
|
40
|
+
let(:earnings) { channel.earnings since: date, by: by, in: location }
|
41
|
+
let(:date) { 4.days.ago }
|
42
|
+
|
43
|
+
context 'and grouped by day' do
|
44
|
+
let(:by) { :day }
|
45
|
+
|
46
|
+
context 'with the :in option set to the country code' do
|
47
|
+
let(:location) { country_code }
|
48
|
+
it { expect(earnings.keys.min).to eq date.to_date }
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'with the :in option set to {country: country code}' do
|
52
|
+
let(:location) { {country: country_code} }
|
53
|
+
it { expect(earnings.keys.min).to eq date.to_date }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'and grouped by country' do
|
58
|
+
let(:by) { :country }
|
59
|
+
|
60
|
+
context 'with the :in option set to the country code' do
|
61
|
+
let(:location) { country_code }
|
62
|
+
it { expect(earnings.keys).to eq [country_code] }
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'with the :in option set to {country: country code}' do
|
66
|
+
let(:location) { {country: country_code} }
|
67
|
+
it { expect(earnings.keys).to eq [country_code] }
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
38
72
|
describe 'earnings can be retrieved for a range of days' do
|
39
73
|
let(:date) { 4.days.ago }
|
40
74
|
|
@@ -81,6 +115,17 @@ describe Yt::Channel, :partner do
|
|
81
115
|
end
|
82
116
|
end
|
83
117
|
|
118
|
+
describe 'earnings can be grouped by country' do
|
119
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
120
|
+
|
121
|
+
specify 'with the :by option set to :country' do
|
122
|
+
earnings = channel.earnings range.merge by: :country
|
123
|
+
expect(earnings.keys).to all(be_a String)
|
124
|
+
expect(earnings.keys.map(&:length).uniq).to eq [2]
|
125
|
+
expect(earnings.values).to all(be_a Float)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
84
129
|
describe 'views can be retrieved for a specific day' do
|
85
130
|
context 'in which the channel was partnered' do
|
86
131
|
let(:views) { channel.views_on 5.days.ago}
|
@@ -93,6 +138,57 @@ describe Yt::Channel, :partner do
|
|
93
138
|
end
|
94
139
|
end
|
95
140
|
|
141
|
+
describe 'views can be retrieved for a single country' do
|
142
|
+
let(:country_code) { 'US' }
|
143
|
+
let(:views) { channel.views since: date, by: by, in: location }
|
144
|
+
let(:date) { 4.days.ago }
|
145
|
+
|
146
|
+
context 'and grouped by day' do
|
147
|
+
let(:by) { :day }
|
148
|
+
|
149
|
+
context 'with the :in option set to the country code' do
|
150
|
+
let(:location) { country_code }
|
151
|
+
it { expect(views.keys.min).to eq date.to_date }
|
152
|
+
end
|
153
|
+
|
154
|
+
context 'with the :in option set to {country: country code}' do
|
155
|
+
let(:location) { {country: country_code} }
|
156
|
+
it { expect(views.keys.min).to eq date.to_date }
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
context 'and grouped by country' do
|
161
|
+
let(:by) { :country }
|
162
|
+
|
163
|
+
context 'with the :in option set to the country code' do
|
164
|
+
let(:location) { country_code }
|
165
|
+
it { expect(views.keys).to eq [country_code] }
|
166
|
+
end
|
167
|
+
|
168
|
+
context 'with the :in option set to {country: country code}' do
|
169
|
+
let(:location) { {country: country_code} }
|
170
|
+
it { expect(views.keys).to eq [country_code] }
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
# describe 'views can be retrieved for a single US state' do
|
176
|
+
# let(:state_code) { 'TX' }
|
177
|
+
#
|
178
|
+
# specify 'with the :in option set to {state: state_code}' do
|
179
|
+
# require 'pry'; binding.pry; true;
|
180
|
+
# views = channel.views in: {state: state_code}
|
181
|
+
#
|
182
|
+
# expect(views.keys).to eq [state_code]
|
183
|
+
# end
|
184
|
+
#
|
185
|
+
# specify 'with the :in option set to {country: "US", state: state_code}' do
|
186
|
+
# views = channel.views by: :state, in: {country: "US", state: state_code}
|
187
|
+
# p views
|
188
|
+
# expect(views.keys).to eq [state_code]
|
189
|
+
# end
|
190
|
+
# end
|
191
|
+
|
96
192
|
describe 'views can be retrieved for a range of days' do
|
97
193
|
let(:date) { 4.days.ago }
|
98
194
|
|
@@ -204,6 +300,28 @@ describe Yt::Channel, :partner do
|
|
204
300
|
end
|
205
301
|
end
|
206
302
|
|
303
|
+
describe 'views can be grouped by country' do
|
304
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
305
|
+
|
306
|
+
specify 'with the :by option set to :country' do
|
307
|
+
views = channel.views range.merge by: :country
|
308
|
+
expect(views.keys).to all(be_a String)
|
309
|
+
expect(views.keys.map(&:length).uniq).to eq [2]
|
310
|
+
expect(views.values).to all(be_an Integer)
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
describe 'views can be grouped by state' do
|
315
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
316
|
+
|
317
|
+
specify 'with the :by option set to :state' do
|
318
|
+
views = channel.views range.merge by: :state
|
319
|
+
expect(views.keys).to all(be_a String)
|
320
|
+
expect(views.keys.map(&:length).uniq).to eq [2]
|
321
|
+
expect(views.values).to all(be_an Integer)
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
207
325
|
describe 'comments can be retrieved for a specific day' do
|
208
326
|
context 'in which the channel was partnered' do
|
209
327
|
let(:comments) { channel.comments_on 5.days.ago}
|
@@ -216,6 +334,40 @@ describe Yt::Channel, :partner do
|
|
216
334
|
end
|
217
335
|
end
|
218
336
|
|
337
|
+
describe 'comments can be retrieved for a single country' do
|
338
|
+
let(:country_code) { 'US' }
|
339
|
+
let(:comments) { channel.comments since: date, by: by, in: location }
|
340
|
+
let(:date) { 4.days.ago }
|
341
|
+
|
342
|
+
context 'and grouped by day' do
|
343
|
+
let(:by) { :day }
|
344
|
+
|
345
|
+
context 'with the :in option set to the country code' do
|
346
|
+
let(:location) { country_code }
|
347
|
+
it { expect(comments.keys.min).to eq date.to_date }
|
348
|
+
end
|
349
|
+
|
350
|
+
context 'with the :in option set to {country: country code}' do
|
351
|
+
let(:location) { {country: country_code} }
|
352
|
+
it { expect(comments.keys.min).to eq date.to_date }
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
356
|
+
context 'and grouped by country' do
|
357
|
+
let(:by) { :country }
|
358
|
+
|
359
|
+
context 'with the :in option set to the country code' do
|
360
|
+
let(:location) { country_code }
|
361
|
+
it { expect(comments.keys).to eq [country_code] }
|
362
|
+
end
|
363
|
+
|
364
|
+
context 'with the :in option set to {country: country code}' do
|
365
|
+
let(:location) { {country: country_code} }
|
366
|
+
it { expect(comments.keys).to eq [country_code] }
|
367
|
+
end
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
219
371
|
describe 'comments can be retrieved for a range of days' do
|
220
372
|
let(:date) { 4.days.ago }
|
221
373
|
|
@@ -261,6 +413,17 @@ describe Yt::Channel, :partner do
|
|
261
413
|
end
|
262
414
|
end
|
263
415
|
|
416
|
+
describe 'comments can be grouped by country' do
|
417
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
418
|
+
|
419
|
+
specify 'with the :by option set to :country' do
|
420
|
+
comments = channel.comments range.merge by: :country
|
421
|
+
expect(comments.keys).to all(be_a String)
|
422
|
+
expect(comments.keys.map(&:length).uniq).to eq [2]
|
423
|
+
expect(comments.values).to all(be_an Integer)
|
424
|
+
end
|
425
|
+
end
|
426
|
+
|
264
427
|
describe 'likes can be retrieved for a specific day' do
|
265
428
|
context 'in which the channel was partnered' do
|
266
429
|
let(:likes) { channel.likes_on 5.days.ago}
|
@@ -273,6 +436,40 @@ describe Yt::Channel, :partner do
|
|
273
436
|
end
|
274
437
|
end
|
275
438
|
|
439
|
+
describe 'likes can be retrieved for a single country' do
|
440
|
+
let(:country_code) { 'US' }
|
441
|
+
let(:likes) { channel.likes since: date, by: by, in: location }
|
442
|
+
let(:date) { 4.days.ago }
|
443
|
+
|
444
|
+
context 'and grouped by day' do
|
445
|
+
let(:by) { :day }
|
446
|
+
|
447
|
+
context 'with the :in option set to the country code' do
|
448
|
+
let(:location) { country_code }
|
449
|
+
it { expect(likes.keys.min).to eq date.to_date }
|
450
|
+
end
|
451
|
+
|
452
|
+
context 'with the :in option set to {country: country code}' do
|
453
|
+
let(:location) { {country: country_code} }
|
454
|
+
it { expect(likes.keys.min).to eq date.to_date }
|
455
|
+
end
|
456
|
+
end
|
457
|
+
|
458
|
+
context 'and grouped by country' do
|
459
|
+
let(:by) { :country }
|
460
|
+
|
461
|
+
context 'with the :in option set to the country code' do
|
462
|
+
let(:location) { country_code }
|
463
|
+
it { expect(likes.keys).to eq [country_code] }
|
464
|
+
end
|
465
|
+
|
466
|
+
context 'with the :in option set to {country: country code}' do
|
467
|
+
let(:location) { {country: country_code} }
|
468
|
+
it { expect(likes.keys).to eq [country_code] }
|
469
|
+
end
|
470
|
+
end
|
471
|
+
end
|
472
|
+
|
276
473
|
describe 'likes can be retrieved for a range of days' do
|
277
474
|
let(:date) { 4.days.ago }
|
278
475
|
|
@@ -318,6 +515,17 @@ describe Yt::Channel, :partner do
|
|
318
515
|
end
|
319
516
|
end
|
320
517
|
|
518
|
+
describe 'likes can be grouped by country' do
|
519
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
520
|
+
|
521
|
+
specify 'with the :by option set to :country' do
|
522
|
+
likes = channel.likes range.merge by: :country
|
523
|
+
expect(likes.keys).to all(be_a String)
|
524
|
+
expect(likes.keys.map(&:length).uniq).to eq [2]
|
525
|
+
expect(likes.values).to all(be_an Integer)
|
526
|
+
end
|
527
|
+
end
|
528
|
+
|
321
529
|
describe 'dislikes can be retrieved for a specific day' do
|
322
530
|
context 'in which the channel was partnered' do
|
323
531
|
let(:dislikes) { channel.dislikes_on 5.days.ago}
|
@@ -330,6 +538,40 @@ describe Yt::Channel, :partner do
|
|
330
538
|
end
|
331
539
|
end
|
332
540
|
|
541
|
+
describe 'dislikes can be retrieved for a single country' do
|
542
|
+
let(:country_code) { 'US' }
|
543
|
+
let(:dislikes) { channel.dislikes since: date, by: by, in: location }
|
544
|
+
let(:date) { 4.days.ago }
|
545
|
+
|
546
|
+
context 'and grouped by day' do
|
547
|
+
let(:by) { :day }
|
548
|
+
|
549
|
+
context 'with the :in option set to the country code' do
|
550
|
+
let(:location) { country_code }
|
551
|
+
it { expect(dislikes.keys.min).to eq date.to_date }
|
552
|
+
end
|
553
|
+
|
554
|
+
context 'with the :in option set to {country: country code}' do
|
555
|
+
let(:location) { {country: country_code} }
|
556
|
+
it { expect(dislikes.keys.min).to eq date.to_date }
|
557
|
+
end
|
558
|
+
end
|
559
|
+
|
560
|
+
context 'and grouped by country' do
|
561
|
+
let(:by) { :country }
|
562
|
+
|
563
|
+
context 'with the :in option set to the country code' do
|
564
|
+
let(:location) { country_code }
|
565
|
+
it { expect(dislikes.keys).to eq [country_code] }
|
566
|
+
end
|
567
|
+
|
568
|
+
context 'with the :in option set to {country: country code}' do
|
569
|
+
let(:location) { {country: country_code} }
|
570
|
+
it { expect(dislikes.keys).to eq [country_code] }
|
571
|
+
end
|
572
|
+
end
|
573
|
+
end
|
574
|
+
|
333
575
|
describe 'dislikes can be retrieved for a range of days' do
|
334
576
|
let(:date) { 4.days.ago }
|
335
577
|
|
@@ -375,9 +617,21 @@ describe Yt::Channel, :partner do
|
|
375
617
|
end
|
376
618
|
end
|
377
619
|
|
620
|
+
describe 'dislikes can be grouped by country' do
|
621
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
622
|
+
|
623
|
+
specify 'with the :by option set to :country' do
|
624
|
+
dislikes = channel.dislikes range.merge by: :country
|
625
|
+
expect(dislikes.keys).to all(be_a String)
|
626
|
+
expect(dislikes.keys.map(&:length).uniq).to eq [2]
|
627
|
+
expect(dislikes.values).to all(be_an Integer)
|
628
|
+
end
|
629
|
+
end
|
630
|
+
|
378
631
|
describe 'shares can be retrieved for a specific day' do
|
379
632
|
context 'in which the channel was partnered' do
|
380
|
-
let(:
|
633
|
+
let(:date) { Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 95 }
|
634
|
+
let(:shares) { channel.shares_on date }
|
381
635
|
it { expect(shares).to be_an Integer }
|
382
636
|
end
|
383
637
|
|
@@ -387,6 +641,40 @@ describe Yt::Channel, :partner do
|
|
387
641
|
end
|
388
642
|
end
|
389
643
|
|
644
|
+
describe 'shares can be retrieved for a single country' do
|
645
|
+
let(:country_code) { 'US' }
|
646
|
+
let(:shares) { channel.shares since: date, by: by, in: location }
|
647
|
+
let(:date) { 4.days.ago }
|
648
|
+
|
649
|
+
context 'and grouped by day' do
|
650
|
+
let(:by) { :day }
|
651
|
+
|
652
|
+
context 'with the :in option set to the country code' do
|
653
|
+
let(:location) { country_code }
|
654
|
+
it { expect(shares.keys.min).to eq date.to_date }
|
655
|
+
end
|
656
|
+
|
657
|
+
context 'with the :in option set to {country: country code}' do
|
658
|
+
let(:location) { {country: country_code} }
|
659
|
+
it { expect(shares.keys.min).to eq date.to_date }
|
660
|
+
end
|
661
|
+
end
|
662
|
+
|
663
|
+
context 'and grouped by country' do
|
664
|
+
let(:by) { :country }
|
665
|
+
|
666
|
+
context 'with the :in option set to the country code' do
|
667
|
+
let(:location) { country_code }
|
668
|
+
it { expect(shares.keys).to eq [country_code] }
|
669
|
+
end
|
670
|
+
|
671
|
+
context 'with the :in option set to {country: country code}' do
|
672
|
+
let(:location) { {country: country_code} }
|
673
|
+
it { expect(shares.keys).to eq [country_code] }
|
674
|
+
end
|
675
|
+
end
|
676
|
+
end
|
677
|
+
|
390
678
|
describe 'shares can be retrieved for a range of days' do
|
391
679
|
let(:date) { 4.days.ago }
|
392
680
|
|
@@ -432,6 +720,17 @@ describe Yt::Channel, :partner do
|
|
432
720
|
end
|
433
721
|
end
|
434
722
|
|
723
|
+
describe 'shares can be grouped by country' do
|
724
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
725
|
+
|
726
|
+
specify 'with the :by option set to :country' do
|
727
|
+
shares = channel.shares range.merge by: :country
|
728
|
+
expect(shares.keys).to all(be_a String)
|
729
|
+
expect(shares.keys.map(&:length).uniq).to eq [2]
|
730
|
+
expect(shares.values).to all(be_an Integer)
|
731
|
+
end
|
732
|
+
end
|
733
|
+
|
435
734
|
describe 'gained subscribers can be retrieved for a specific day' do
|
436
735
|
context 'in which the channel was partnered' do
|
437
736
|
let(:subscribers_gained) { channel.subscribers_gained_on 5.days.ago}
|
@@ -444,6 +743,40 @@ describe Yt::Channel, :partner do
|
|
444
743
|
end
|
445
744
|
end
|
446
745
|
|
746
|
+
describe 'gained subscribers can be retrieved for a single country' do
|
747
|
+
let(:country_code) { 'US' }
|
748
|
+
let(:subscribers_gained) { channel.subscribers_gained since: date, by: by, in: location }
|
749
|
+
let(:date) { 4.days.ago }
|
750
|
+
|
751
|
+
context 'and grouped by day' do
|
752
|
+
let(:by) { :day }
|
753
|
+
|
754
|
+
context 'with the :in option set to the country code' do
|
755
|
+
let(:location) { country_code }
|
756
|
+
it { expect(subscribers_gained.keys.min).to eq date.to_date }
|
757
|
+
end
|
758
|
+
|
759
|
+
context 'with the :in option set to {country: country code}' do
|
760
|
+
let(:location) { {country: country_code} }
|
761
|
+
it { expect(subscribers_gained.keys.min).to eq date.to_date }
|
762
|
+
end
|
763
|
+
end
|
764
|
+
|
765
|
+
context 'and grouped by country' do
|
766
|
+
let(:by) { :country }
|
767
|
+
|
768
|
+
context 'with the :in option set to the country code' do
|
769
|
+
let(:location) { country_code }
|
770
|
+
it { expect(subscribers_gained.keys).to eq [country_code] }
|
771
|
+
end
|
772
|
+
|
773
|
+
context 'with the :in option set to {country: country code}' do
|
774
|
+
let(:location) { {country: country_code} }
|
775
|
+
it { expect(subscribers_gained.keys).to eq [country_code] }
|
776
|
+
end
|
777
|
+
end
|
778
|
+
end
|
779
|
+
|
447
780
|
describe 'gained subscribers can be retrieved for a range of days' do
|
448
781
|
let(:date) { 4.days.ago }
|
449
782
|
|
@@ -489,6 +822,17 @@ describe Yt::Channel, :partner do
|
|
489
822
|
end
|
490
823
|
end
|
491
824
|
|
825
|
+
describe 'gained subscribers can be grouped by country' do
|
826
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
827
|
+
|
828
|
+
specify 'with the :by option set to :country' do
|
829
|
+
subscribers_gained = channel.subscribers_gained range.merge by: :country
|
830
|
+
expect(subscribers_gained.keys).to all(be_a String)
|
831
|
+
expect(subscribers_gained.keys.map(&:length).uniq).to eq [2]
|
832
|
+
expect(subscribers_gained.values).to all(be_an Integer)
|
833
|
+
end
|
834
|
+
end
|
835
|
+
|
492
836
|
describe 'lost subscribers can be retrieved for a specific day' do
|
493
837
|
context 'in which the channel was partnered' do
|
494
838
|
let(:subscribers_lost) { channel.subscribers_lost_on 5.days.ago}
|
@@ -501,6 +845,40 @@ describe Yt::Channel, :partner do
|
|
501
845
|
end
|
502
846
|
end
|
503
847
|
|
848
|
+
describe 'lost subscribers can be retrieved for a single country' do
|
849
|
+
let(:country_code) { 'US' }
|
850
|
+
let(:subscribers_lost) { channel.subscribers_lost since: date, by: by, in: location }
|
851
|
+
let(:date) { 4.days.ago }
|
852
|
+
|
853
|
+
context 'and grouped by day' do
|
854
|
+
let(:by) { :day }
|
855
|
+
|
856
|
+
context 'with the :in option set to the country code' do
|
857
|
+
let(:location) { country_code }
|
858
|
+
it { expect(subscribers_lost.keys.min).to eq date.to_date }
|
859
|
+
end
|
860
|
+
|
861
|
+
context 'with the :in option set to {country: country code}' do
|
862
|
+
let(:location) { {country: country_code} }
|
863
|
+
it { expect(subscribers_lost.keys.min).to eq date.to_date }
|
864
|
+
end
|
865
|
+
end
|
866
|
+
|
867
|
+
context 'and grouped by country' do
|
868
|
+
let(:by) { :country }
|
869
|
+
|
870
|
+
context 'with the :in option set to the country code' do
|
871
|
+
let(:location) { country_code }
|
872
|
+
it { expect(subscribers_lost.keys).to eq [country_code] }
|
873
|
+
end
|
874
|
+
|
875
|
+
context 'with the :in option set to {country: country code}' do
|
876
|
+
let(:location) { {country: country_code} }
|
877
|
+
it { expect(subscribers_lost.keys).to eq [country_code] }
|
878
|
+
end
|
879
|
+
end
|
880
|
+
end
|
881
|
+
|
504
882
|
describe 'lost subscribers can be retrieved for a range of days' do
|
505
883
|
let(:date) { 4.days.ago }
|
506
884
|
|
@@ -546,6 +924,17 @@ describe Yt::Channel, :partner do
|
|
546
924
|
end
|
547
925
|
end
|
548
926
|
|
927
|
+
describe 'lost subscribers can be grouped by country' do
|
928
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
929
|
+
|
930
|
+
specify 'with the :by option set to :country' do
|
931
|
+
subscribers_lost = channel.subscribers_lost range.merge by: :country
|
932
|
+
expect(subscribers_lost.keys).to all(be_a String)
|
933
|
+
expect(subscribers_lost.keys.map(&:length).uniq).to eq [2]
|
934
|
+
expect(subscribers_lost.values).to all(be_an Integer)
|
935
|
+
end
|
936
|
+
end
|
937
|
+
|
549
938
|
describe 'added favorites can be retrieved for a specific day' do
|
550
939
|
context 'in which the channel was partnered' do
|
551
940
|
let(:favorites_added) { channel.favorites_added_on 5.days.ago}
|
@@ -558,6 +947,40 @@ describe Yt::Channel, :partner do
|
|
558
947
|
end
|
559
948
|
end
|
560
949
|
|
950
|
+
describe 'favorites added can be retrieved for a single country' do
|
951
|
+
let(:country_code) { 'US' }
|
952
|
+
let(:favorites_added) { channel.favorites_added since: date, by: by, in: location }
|
953
|
+
let(:date) { 4.days.ago }
|
954
|
+
|
955
|
+
context 'and grouped by day' do
|
956
|
+
let(:by) { :day }
|
957
|
+
|
958
|
+
context 'with the :in option set to the country code' do
|
959
|
+
let(:location) { country_code }
|
960
|
+
it { expect(favorites_added.keys.min).to eq date.to_date }
|
961
|
+
end
|
962
|
+
|
963
|
+
context 'with the :in option set to {country: country code}' do
|
964
|
+
let(:location) { {country: country_code} }
|
965
|
+
it { expect(favorites_added.keys.min).to eq date.to_date }
|
966
|
+
end
|
967
|
+
end
|
968
|
+
|
969
|
+
context 'and grouped by country' do
|
970
|
+
let(:by) { :country }
|
971
|
+
|
972
|
+
context 'with the :in option set to the country code' do
|
973
|
+
let(:location) { country_code }
|
974
|
+
it { expect(favorites_added.keys).to eq [country_code] }
|
975
|
+
end
|
976
|
+
|
977
|
+
context 'with the :in option set to {country: country code}' do
|
978
|
+
let(:location) { {country: country_code} }
|
979
|
+
it { expect(favorites_added.keys).to eq [country_code] }
|
980
|
+
end
|
981
|
+
end
|
982
|
+
end
|
983
|
+
|
561
984
|
describe 'added favorites can be retrieved for a range of days' do
|
562
985
|
let(:date) { 4.days.ago }
|
563
986
|
|
@@ -603,6 +1026,17 @@ describe Yt::Channel, :partner do
|
|
603
1026
|
end
|
604
1027
|
end
|
605
1028
|
|
1029
|
+
describe 'added favorites can be grouped by country' do
|
1030
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
1031
|
+
|
1032
|
+
specify 'with the :by option set to :country' do
|
1033
|
+
favorites_added = channel.favorites_added range.merge by: :country
|
1034
|
+
expect(favorites_added.keys).to all(be_a String)
|
1035
|
+
expect(favorites_added.keys.map(&:length).uniq).to eq [2]
|
1036
|
+
expect(favorites_added.values).to all(be_an Integer)
|
1037
|
+
end
|
1038
|
+
end
|
1039
|
+
|
606
1040
|
describe 'removed favorites can be retrieved for a specific day' do
|
607
1041
|
context 'in which the channel was partnered' do
|
608
1042
|
let(:favorites_removed) { channel.favorites_removed_on 5.days.ago}
|
@@ -615,6 +1049,40 @@ describe Yt::Channel, :partner do
|
|
615
1049
|
end
|
616
1050
|
end
|
617
1051
|
|
1052
|
+
describe 'favorites removed can be retrieved for a single country' do
|
1053
|
+
let(:country_code) { 'US' }
|
1054
|
+
let(:favorites_removed) { channel.favorites_removed since: date, by: by, in: location }
|
1055
|
+
let(:date) { 4.days.ago }
|
1056
|
+
|
1057
|
+
context 'and grouped by day' do
|
1058
|
+
let(:by) { :day }
|
1059
|
+
|
1060
|
+
context 'with the :in option set to the country code' do
|
1061
|
+
let(:location) { country_code }
|
1062
|
+
it { expect(favorites_removed.keys.min).to eq date.to_date }
|
1063
|
+
end
|
1064
|
+
|
1065
|
+
context 'with the :in option set to {country: country code}' do
|
1066
|
+
let(:location) { {country: country_code} }
|
1067
|
+
it { expect(favorites_removed.keys.min).to eq date.to_date }
|
1068
|
+
end
|
1069
|
+
end
|
1070
|
+
|
1071
|
+
context 'and grouped by country' do
|
1072
|
+
let(:by) { :country }
|
1073
|
+
|
1074
|
+
context 'with the :in option set to the country code' do
|
1075
|
+
let(:location) { country_code }
|
1076
|
+
it { expect(favorites_removed.keys).to eq [country_code] }
|
1077
|
+
end
|
1078
|
+
|
1079
|
+
context 'with the :in option set to {country: country code}' do
|
1080
|
+
let(:location) { {country: country_code} }
|
1081
|
+
it { expect(favorites_removed.keys).to eq [country_code] }
|
1082
|
+
end
|
1083
|
+
end
|
1084
|
+
end
|
1085
|
+
|
618
1086
|
describe 'removed favorites can be retrieved for a range of days' do
|
619
1087
|
let(:date) { 4.days.ago }
|
620
1088
|
|
@@ -660,6 +1128,17 @@ describe Yt::Channel, :partner do
|
|
660
1128
|
end
|
661
1129
|
end
|
662
1130
|
|
1131
|
+
describe 'removed favorites can be grouped by country' do
|
1132
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
1133
|
+
|
1134
|
+
specify 'with the :by option set to :country' do
|
1135
|
+
favorites_removed = channel.favorites_removed range.merge by: :country
|
1136
|
+
expect(favorites_removed.keys).to all(be_a String)
|
1137
|
+
expect(favorites_removed.keys.map(&:length).uniq).to eq [2]
|
1138
|
+
expect(favorites_removed.values).to all(be_an Integer)
|
1139
|
+
end
|
1140
|
+
end
|
1141
|
+
|
663
1142
|
describe 'estimated minutes watched can be retrieved for a specific day' do
|
664
1143
|
context 'in which the channel was partnered' do
|
665
1144
|
let(:estimated_minutes_watched) { channel.estimated_minutes_watched_on 5.days.ago}
|
@@ -672,6 +1151,40 @@ describe Yt::Channel, :partner do
|
|
672
1151
|
end
|
673
1152
|
end
|
674
1153
|
|
1154
|
+
describe 'estimated minutes watched can be retrieved for a single country' do
|
1155
|
+
let(:country_code) { 'US' }
|
1156
|
+
let(:estimated_minutes_watched) { channel.estimated_minutes_watched since: date, by: by, in: location }
|
1157
|
+
let(:date) { 4.days.ago }
|
1158
|
+
|
1159
|
+
context 'and grouped by day' do
|
1160
|
+
let(:by) { :day }
|
1161
|
+
|
1162
|
+
context 'with the :in option set to the country code' do
|
1163
|
+
let(:location) { country_code }
|
1164
|
+
it { expect(estimated_minutes_watched.keys.min).to eq date.to_date }
|
1165
|
+
end
|
1166
|
+
|
1167
|
+
context 'with the :in option set to {country: country code}' do
|
1168
|
+
let(:location) { {country: country_code} }
|
1169
|
+
it { expect(estimated_minutes_watched.keys.min).to eq date.to_date }
|
1170
|
+
end
|
1171
|
+
end
|
1172
|
+
|
1173
|
+
context 'and grouped by country' do
|
1174
|
+
let(:by) { :country }
|
1175
|
+
|
1176
|
+
context 'with the :in option set to the country code' do
|
1177
|
+
let(:location) { country_code }
|
1178
|
+
it { expect(estimated_minutes_watched.keys).to eq [country_code] }
|
1179
|
+
end
|
1180
|
+
|
1181
|
+
context 'with the :in option set to {country: country code}' do
|
1182
|
+
let(:location) { {country: country_code} }
|
1183
|
+
it { expect(estimated_minutes_watched.keys).to eq [country_code] }
|
1184
|
+
end
|
1185
|
+
end
|
1186
|
+
end
|
1187
|
+
|
675
1188
|
describe 'estimated minutes watched can be retrieved for a range of days' do
|
676
1189
|
let(:date) { 4.days.ago }
|
677
1190
|
|
@@ -783,6 +1296,28 @@ describe Yt::Channel, :partner do
|
|
783
1296
|
end
|
784
1297
|
end
|
785
1298
|
|
1299
|
+
describe 'estimated minutes watched can be grouped by country' do
|
1300
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
1301
|
+
|
1302
|
+
specify 'with the :by option set to :country' do
|
1303
|
+
minutes = channel.estimated_minutes_watched range.merge by: :country
|
1304
|
+
expect(minutes.keys).to all(be_a String)
|
1305
|
+
expect(minutes.keys.map(&:length).uniq).to eq [2]
|
1306
|
+
expect(minutes.values).to all(be_a Float)
|
1307
|
+
end
|
1308
|
+
end
|
1309
|
+
|
1310
|
+
describe 'estimated minutes watched can be grouped by state' do
|
1311
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
1312
|
+
|
1313
|
+
specify 'with the :by option set to :state' do
|
1314
|
+
minutes = channel.estimated_minutes_watched range.merge by: :state
|
1315
|
+
expect(minutes.keys).to all(be_a String)
|
1316
|
+
expect(minutes.keys.map(&:length).uniq).to eq [2]
|
1317
|
+
expect(minutes.values).to all(be_a Float)
|
1318
|
+
end
|
1319
|
+
end
|
1320
|
+
|
786
1321
|
describe 'average view duration can be retrieved for a specific day' do
|
787
1322
|
context 'in which the channel was partnered' do
|
788
1323
|
let(:average_view_duration) { channel.average_view_duration_on 5.days.ago}
|
@@ -795,6 +1330,40 @@ describe Yt::Channel, :partner do
|
|
795
1330
|
end
|
796
1331
|
end
|
797
1332
|
|
1333
|
+
describe 'average view duration can be retrieved for a single country' do
|
1334
|
+
let(:country_code) { 'US' }
|
1335
|
+
let(:average_view_duration) { channel.average_view_duration since: date, by: by, in: location }
|
1336
|
+
let(:date) { 4.days.ago }
|
1337
|
+
|
1338
|
+
context 'and grouped by day' do
|
1339
|
+
let(:by) { :day }
|
1340
|
+
|
1341
|
+
context 'with the :in option set to the country code' do
|
1342
|
+
let(:location) { country_code }
|
1343
|
+
it { expect(average_view_duration.keys.min).to eq date.to_date }
|
1344
|
+
end
|
1345
|
+
|
1346
|
+
context 'with the :in option set to {country: country code}' do
|
1347
|
+
let(:location) { {country: country_code} }
|
1348
|
+
it { expect(average_view_duration.keys.min).to eq date.to_date }
|
1349
|
+
end
|
1350
|
+
end
|
1351
|
+
|
1352
|
+
context 'and grouped by country' do
|
1353
|
+
let(:by) { :country }
|
1354
|
+
|
1355
|
+
context 'with the :in option set to the country code' do
|
1356
|
+
let(:location) { country_code }
|
1357
|
+
it { expect(average_view_duration.keys).to eq [country_code] }
|
1358
|
+
end
|
1359
|
+
|
1360
|
+
context 'with the :in option set to {country: country code}' do
|
1361
|
+
let(:location) { {country: country_code} }
|
1362
|
+
it { expect(average_view_duration.keys).to eq [country_code] }
|
1363
|
+
end
|
1364
|
+
end
|
1365
|
+
end
|
1366
|
+
|
798
1367
|
describe 'average view duration can be retrieved for a range of days' do
|
799
1368
|
let(:date) { 4.days.ago }
|
800
1369
|
|
@@ -840,6 +1409,28 @@ describe Yt::Channel, :partner do
|
|
840
1409
|
end
|
841
1410
|
end
|
842
1411
|
|
1412
|
+
describe 'average view duration can be grouped by country' do
|
1413
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
1414
|
+
|
1415
|
+
specify 'with the :by option set to :country' do
|
1416
|
+
duration = channel.average_view_duration range.merge by: :country
|
1417
|
+
expect(duration.keys).to all(be_a String)
|
1418
|
+
expect(duration.keys.map(&:length).uniq).to eq [2]
|
1419
|
+
expect(duration.values).to all(be_a Float)
|
1420
|
+
end
|
1421
|
+
end
|
1422
|
+
|
1423
|
+
describe 'average view duration can be grouped by state' do
|
1424
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
1425
|
+
|
1426
|
+
specify 'with the :by option set to :state' do
|
1427
|
+
duration = channel.average_view_duration range.merge by: :state
|
1428
|
+
expect(duration.keys).to all(be_a String)
|
1429
|
+
expect(duration.keys.map(&:length).uniq).to eq [2]
|
1430
|
+
expect(duration.values).to all(be_a Float)
|
1431
|
+
end
|
1432
|
+
end
|
1433
|
+
|
843
1434
|
describe 'average view percentage can be retrieved for a specific day' do
|
844
1435
|
context 'in which the channel was partnered' do
|
845
1436
|
let(:average_view_percentage) { channel.average_view_percentage_on 5.days.ago}
|
@@ -852,6 +1443,40 @@ describe Yt::Channel, :partner do
|
|
852
1443
|
end
|
853
1444
|
end
|
854
1445
|
|
1446
|
+
describe 'average view percentage can be retrieved for a single country' do
|
1447
|
+
let(:country_code) { 'US' }
|
1448
|
+
let(:average_view_percentage) { channel.average_view_percentage since: date, by: by, in: location }
|
1449
|
+
let(:date) { 4.days.ago }
|
1450
|
+
|
1451
|
+
context 'and grouped by day' do
|
1452
|
+
let(:by) { :day }
|
1453
|
+
|
1454
|
+
context 'with the :in option set to the country code' do
|
1455
|
+
let(:location) { country_code }
|
1456
|
+
it { expect(average_view_percentage.keys.min).to eq date.to_date }
|
1457
|
+
end
|
1458
|
+
|
1459
|
+
context 'with the :in option set to {country: country code}' do
|
1460
|
+
let(:location) { {country: country_code} }
|
1461
|
+
it { expect(average_view_percentage.keys.min).to eq date.to_date }
|
1462
|
+
end
|
1463
|
+
end
|
1464
|
+
|
1465
|
+
context 'and grouped by country' do
|
1466
|
+
let(:by) { :country }
|
1467
|
+
|
1468
|
+
context 'with the :in option set to the country code' do
|
1469
|
+
let(:location) { country_code }
|
1470
|
+
it { expect(average_view_percentage.keys).to eq [country_code] }
|
1471
|
+
end
|
1472
|
+
|
1473
|
+
context 'with the :in option set to {country: country code}' do
|
1474
|
+
let(:location) { {country: country_code} }
|
1475
|
+
it { expect(average_view_percentage.keys).to eq [country_code] }
|
1476
|
+
end
|
1477
|
+
end
|
1478
|
+
end
|
1479
|
+
|
855
1480
|
describe 'average view percentage can be retrieved for a range of days' do
|
856
1481
|
let(:date) { 4.days.ago }
|
857
1482
|
|
@@ -897,6 +1522,28 @@ describe Yt::Channel, :partner do
|
|
897
1522
|
end
|
898
1523
|
end
|
899
1524
|
|
1525
|
+
describe 'average view percentage can be grouped by country' do
|
1526
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
1527
|
+
|
1528
|
+
specify 'with the :by option set to :country' do
|
1529
|
+
percentage = channel.average_view_percentage range.merge by: :country
|
1530
|
+
expect(percentage.keys).to all(be_a String)
|
1531
|
+
expect(percentage.keys.map(&:length).uniq).to eq [2]
|
1532
|
+
expect(percentage.values).to all(be_a Float)
|
1533
|
+
end
|
1534
|
+
end
|
1535
|
+
|
1536
|
+
describe 'average view percentage can be grouped by state' do
|
1537
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
1538
|
+
|
1539
|
+
specify 'with the :by option set to :state' do
|
1540
|
+
percentage = channel.average_view_percentage range.merge by: :state
|
1541
|
+
expect(percentage.keys).to all(be_a String)
|
1542
|
+
expect(percentage.keys.map(&:length).uniq).to eq [2]
|
1543
|
+
expect(percentage.values).to all(be_a Float)
|
1544
|
+
end
|
1545
|
+
end
|
1546
|
+
|
900
1547
|
describe 'impressions can be retrieved for a specific day' do
|
901
1548
|
context 'in which the channel was partnered' do
|
902
1549
|
let(:impressions) { channel.impressions_on 20.days.ago}
|
@@ -909,6 +1556,40 @@ describe Yt::Channel, :partner do
|
|
909
1556
|
end
|
910
1557
|
end
|
911
1558
|
|
1559
|
+
describe 'impressions can be retrieved for a single country' do
|
1560
|
+
let(:country_code) { 'US' }
|
1561
|
+
let(:impressions) { channel.impressions since: date, by: by, in: location }
|
1562
|
+
let(:date) { 4.days.ago }
|
1563
|
+
|
1564
|
+
context 'and grouped by day' do
|
1565
|
+
let(:by) { :day }
|
1566
|
+
|
1567
|
+
context 'with the :in option set to the country code' do
|
1568
|
+
let(:location) { country_code }
|
1569
|
+
it { expect(impressions.keys.min).to eq date.to_date }
|
1570
|
+
end
|
1571
|
+
|
1572
|
+
context 'with the :in option set to {country: country code}' do
|
1573
|
+
let(:location) { {country: country_code} }
|
1574
|
+
it { expect(impressions.keys.min).to eq date.to_date }
|
1575
|
+
end
|
1576
|
+
end
|
1577
|
+
|
1578
|
+
context 'and grouped by country' do
|
1579
|
+
let(:by) { :country }
|
1580
|
+
|
1581
|
+
context 'with the :in option set to the country code' do
|
1582
|
+
let(:location) { country_code }
|
1583
|
+
it { expect(impressions.keys).to eq [country_code] }
|
1584
|
+
end
|
1585
|
+
|
1586
|
+
context 'with the :in option set to {country: country code}' do
|
1587
|
+
let(:location) { {country: country_code} }
|
1588
|
+
it { expect(impressions.keys).to eq [country_code] }
|
1589
|
+
end
|
1590
|
+
end
|
1591
|
+
end
|
1592
|
+
|
912
1593
|
describe 'impressions can be retrieved for a range of days' do
|
913
1594
|
let(:date) { 4.days.ago }
|
914
1595
|
|
@@ -954,6 +1635,17 @@ describe Yt::Channel, :partner do
|
|
954
1635
|
end
|
955
1636
|
end
|
956
1637
|
|
1638
|
+
describe 'impressions can be grouped by country' do
|
1639
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
1640
|
+
|
1641
|
+
specify 'with the :by option set to :country' do
|
1642
|
+
impressions = channel.impressions range.merge by: :country
|
1643
|
+
expect(impressions.keys).to all(be_a String)
|
1644
|
+
expect(impressions.keys.map(&:length).uniq).to eq [2]
|
1645
|
+
expect(impressions.values).to all(be_an Integer)
|
1646
|
+
end
|
1647
|
+
end
|
1648
|
+
|
957
1649
|
describe 'monetized playbacks can be retrieved for a specific day' do
|
958
1650
|
context 'in which the channel was partnered' do
|
959
1651
|
let(:monetized_playbacks) { channel.monetized_playbacks_on 20.days.ago}
|
@@ -966,6 +1658,40 @@ describe Yt::Channel, :partner do
|
|
966
1658
|
end
|
967
1659
|
end
|
968
1660
|
|
1661
|
+
describe 'monetized playbacks can be retrieved for a single country' do
|
1662
|
+
let(:country_code) { 'US' }
|
1663
|
+
let(:monetized_playbacks) { channel.monetized_playbacks since: date, by: by, in: location }
|
1664
|
+
let(:date) { 4.days.ago }
|
1665
|
+
|
1666
|
+
context 'and grouped by day' do
|
1667
|
+
let(:by) { :day }
|
1668
|
+
|
1669
|
+
context 'with the :in option set to the country code' do
|
1670
|
+
let(:location) { country_code }
|
1671
|
+
it { expect(monetized_playbacks.keys.min).to eq date.to_date }
|
1672
|
+
end
|
1673
|
+
|
1674
|
+
context 'with the :in option set to {country: country code}' do
|
1675
|
+
let(:location) { {country: country_code} }
|
1676
|
+
it { expect(monetized_playbacks.keys.min).to eq date.to_date }
|
1677
|
+
end
|
1678
|
+
end
|
1679
|
+
|
1680
|
+
context 'and grouped by country' do
|
1681
|
+
let(:by) { :country }
|
1682
|
+
|
1683
|
+
context 'with the :in option set to the country code' do
|
1684
|
+
let(:location) { country_code }
|
1685
|
+
it { expect(monetized_playbacks.keys).to eq [country_code] }
|
1686
|
+
end
|
1687
|
+
|
1688
|
+
context 'with the :in option set to {country: country code}' do
|
1689
|
+
let(:location) { {country: country_code} }
|
1690
|
+
it { expect(monetized_playbacks.keys).to eq [country_code] }
|
1691
|
+
end
|
1692
|
+
end
|
1693
|
+
end
|
1694
|
+
|
969
1695
|
describe 'monetized playbacks can be retrieved for a range of days' do
|
970
1696
|
let(:date) { 4.days.ago }
|
971
1697
|
|
@@ -1011,6 +1737,51 @@ describe Yt::Channel, :partner do
|
|
1011
1737
|
end
|
1012
1738
|
end
|
1013
1739
|
|
1740
|
+
describe 'monetized playbacks can be grouped by country' do
|
1741
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
1742
|
+
|
1743
|
+
specify 'with the :by option set to :country' do
|
1744
|
+
playbacks = channel.monetized_playbacks range.merge by: :country
|
1745
|
+
expect(playbacks.keys).to all(be_a String)
|
1746
|
+
expect(playbacks.keys.map(&:length).uniq).to eq [2]
|
1747
|
+
expect(playbacks.values).to all(be_an Integer)
|
1748
|
+
end
|
1749
|
+
end
|
1750
|
+
|
1751
|
+
describe 'annotation clicks can be retrieved for a single country' do
|
1752
|
+
let(:country_code) { 'US' }
|
1753
|
+
let(:annotation_clicks) { channel.annotation_clicks since: date, by: by, in: location }
|
1754
|
+
let(:date) { 4.days.ago }
|
1755
|
+
|
1756
|
+
context 'and grouped by day' do
|
1757
|
+
let(:by) { :day }
|
1758
|
+
|
1759
|
+
context 'with the :in option set to the country code' do
|
1760
|
+
let(:location) { country_code }
|
1761
|
+
it { expect(annotation_clicks.keys.min).to eq date.to_date }
|
1762
|
+
end
|
1763
|
+
|
1764
|
+
context 'with the :in option set to {country: country code}' do
|
1765
|
+
let(:location) { {country: country_code} }
|
1766
|
+
it { expect(annotation_clicks.keys.min).to eq date.to_date }
|
1767
|
+
end
|
1768
|
+
end
|
1769
|
+
|
1770
|
+
context 'and grouped by country' do
|
1771
|
+
let(:by) { :country }
|
1772
|
+
|
1773
|
+
context 'with the :in option set to the country code' do
|
1774
|
+
let(:location) { country_code }
|
1775
|
+
it { expect(annotation_clicks.keys).to eq [country_code] }
|
1776
|
+
end
|
1777
|
+
|
1778
|
+
context 'with the :in option set to {country: country code}' do
|
1779
|
+
let(:location) { {country: country_code} }
|
1780
|
+
it { expect(annotation_clicks.keys).to eq [country_code] }
|
1781
|
+
end
|
1782
|
+
end
|
1783
|
+
end
|
1784
|
+
|
1014
1785
|
describe 'annotation clicks can be retrieved for a range of days' do
|
1015
1786
|
let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
|
1016
1787
|
let(:date_to) { Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5 }
|
@@ -1048,6 +1819,62 @@ describe Yt::Channel, :partner do
|
|
1048
1819
|
end
|
1049
1820
|
end
|
1050
1821
|
|
1822
|
+
describe 'annotation clicks can be grouped by country' do
|
1823
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
1824
|
+
|
1825
|
+
specify 'with the :by option set to :country' do
|
1826
|
+
clicks = channel.annotation_clicks range.merge by: :country
|
1827
|
+
expect(clicks.keys).to all(be_a String)
|
1828
|
+
expect(clicks.keys.map(&:length).uniq).to eq [2]
|
1829
|
+
expect(clicks.values).to all(be_an Integer)
|
1830
|
+
end
|
1831
|
+
end
|
1832
|
+
|
1833
|
+
describe 'annotation clicks can be grouped by state' do
|
1834
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
1835
|
+
|
1836
|
+
specify 'with the :by option set to :state' do
|
1837
|
+
clicks = channel.annotation_clicks range.merge by: :state
|
1838
|
+
expect(clicks.keys).to all(be_a String)
|
1839
|
+
expect(clicks.keys.map(&:length).uniq).to eq [2]
|
1840
|
+
expect(clicks.values).to all(be_an Integer)
|
1841
|
+
end
|
1842
|
+
end
|
1843
|
+
|
1844
|
+
describe 'annotation click-through rate can be retrieved for a single country' do
|
1845
|
+
let(:country_code) { 'US' }
|
1846
|
+
let(:annotation_click_through_rate) { channel.annotation_click_through_rate since: date, by: by, in: location }
|
1847
|
+
let(:date) { 4.days.ago }
|
1848
|
+
|
1849
|
+
context 'and grouped by day' do
|
1850
|
+
let(:by) { :day }
|
1851
|
+
|
1852
|
+
context 'with the :in option set to the country code' do
|
1853
|
+
let(:location) { country_code }
|
1854
|
+
it { expect(annotation_click_through_rate.keys.min).to eq date.to_date }
|
1855
|
+
end
|
1856
|
+
|
1857
|
+
context 'with the :in option set to {country: country code}' do
|
1858
|
+
let(:location) { {country: country_code} }
|
1859
|
+
it { expect(annotation_click_through_rate.keys.min).to eq date.to_date }
|
1860
|
+
end
|
1861
|
+
end
|
1862
|
+
|
1863
|
+
context 'and grouped by country' do
|
1864
|
+
let(:by) { :country }
|
1865
|
+
|
1866
|
+
context 'with the :in option set to the country code' do
|
1867
|
+
let(:location) { country_code }
|
1868
|
+
it { expect(annotation_click_through_rate.keys).to eq [country_code] }
|
1869
|
+
end
|
1870
|
+
|
1871
|
+
context 'with the :in option set to {country: country code}' do
|
1872
|
+
let(:location) { {country: country_code} }
|
1873
|
+
it { expect(annotation_click_through_rate.keys).to eq [country_code] }
|
1874
|
+
end
|
1875
|
+
end
|
1876
|
+
end
|
1877
|
+
|
1051
1878
|
describe 'annotation click-through rate can be retrieved for a range of days' do
|
1052
1879
|
let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
|
1053
1880
|
let(:date_to) { Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5 }
|
@@ -1085,6 +1912,62 @@ describe Yt::Channel, :partner do
|
|
1085
1912
|
end
|
1086
1913
|
end
|
1087
1914
|
|
1915
|
+
describe 'annotation click-through rate can be grouped by country' do
|
1916
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
1917
|
+
|
1918
|
+
specify 'with the :by option set to :country' do
|
1919
|
+
rate = channel.annotation_click_through_rate range.merge by: :country
|
1920
|
+
expect(rate.keys).to all(be_a String)
|
1921
|
+
expect(rate.keys.map(&:length).uniq).to eq [2]
|
1922
|
+
expect(rate.values).to all(be_a Float)
|
1923
|
+
end
|
1924
|
+
end
|
1925
|
+
|
1926
|
+
describe 'annotation click-through rate can be grouped by state' do
|
1927
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
1928
|
+
|
1929
|
+
specify 'with the :by option set to :state' do
|
1930
|
+
rate = channel.annotation_click_through_rate range.merge by: :state
|
1931
|
+
expect(rate.keys).to all(be_a String)
|
1932
|
+
expect(rate.keys.map(&:length).uniq).to eq [2]
|
1933
|
+
expect(rate.values).to all(be_a Float)
|
1934
|
+
end
|
1935
|
+
end
|
1936
|
+
|
1937
|
+
describe 'annotation close rate can be retrieved for a single country' do
|
1938
|
+
let(:country_code) { 'US' }
|
1939
|
+
let(:annotation_close_rate) { channel.annotation_close_rate since: date, by: by, in: location }
|
1940
|
+
let(:date) { 4.days.ago }
|
1941
|
+
|
1942
|
+
context 'and grouped by day' do
|
1943
|
+
let(:by) { :day }
|
1944
|
+
|
1945
|
+
context 'with the :in option set to the country code' do
|
1946
|
+
let(:location) { country_code }
|
1947
|
+
it { expect(annotation_close_rate.keys.min).to eq date.to_date }
|
1948
|
+
end
|
1949
|
+
|
1950
|
+
context 'with the :in option set to {country: country code}' do
|
1951
|
+
let(:location) { {country: country_code} }
|
1952
|
+
it { expect(annotation_close_rate.keys.min).to eq date.to_date }
|
1953
|
+
end
|
1954
|
+
end
|
1955
|
+
|
1956
|
+
context 'and grouped by country' do
|
1957
|
+
let(:by) { :country }
|
1958
|
+
|
1959
|
+
context 'with the :in option set to the country code' do
|
1960
|
+
let(:location) { country_code }
|
1961
|
+
it { expect(annotation_close_rate.keys).to eq [country_code] }
|
1962
|
+
end
|
1963
|
+
|
1964
|
+
context 'with the :in option set to {country: country code}' do
|
1965
|
+
let(:location) { {country: country_code} }
|
1966
|
+
it { expect(annotation_close_rate.keys).to eq [country_code] }
|
1967
|
+
end
|
1968
|
+
end
|
1969
|
+
end
|
1970
|
+
|
1088
1971
|
describe 'annotation close rate can be retrieved for a range of days' do
|
1089
1972
|
let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
|
1090
1973
|
let(:date_to) { Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5 }
|
@@ -1122,6 +2005,43 @@ describe Yt::Channel, :partner do
|
|
1122
2005
|
end
|
1123
2006
|
end
|
1124
2007
|
|
2008
|
+
describe 'annotation close rate can be grouped by country' do
|
2009
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
2010
|
+
|
2011
|
+
specify 'with the :by option set to :country' do
|
2012
|
+
rate = channel.annotation_close_rate range.merge by: :country
|
2013
|
+
expect(rate.keys).to all(be_a String)
|
2014
|
+
expect(rate.keys.map(&:length).uniq).to eq [2]
|
2015
|
+
expect(rate.values).to all(be_a Float)
|
2016
|
+
end
|
2017
|
+
end
|
2018
|
+
|
2019
|
+
describe 'annotation close rate can be grouped by state' do
|
2020
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
2021
|
+
|
2022
|
+
specify 'with the :by option set to :state' do
|
2023
|
+
rate = channel.annotation_close_rate range.merge by: :state
|
2024
|
+
expect(rate.keys).to all(be_a String)
|
2025
|
+
expect(rate.keys.map(&:length).uniq).to eq [2]
|
2026
|
+
expect(rate.values).to all(be_a Float)
|
2027
|
+
end
|
2028
|
+
end
|
2029
|
+
|
2030
|
+
describe 'viewer percentage can be retrieved for a single country' do
|
2031
|
+
let(:country_code) { 'US' }
|
2032
|
+
let(:viewer_percentage) { channel.viewer_percentage in: location }
|
2033
|
+
|
2034
|
+
context 'with the :in option set to the country code' do
|
2035
|
+
let(:location) { country_code }
|
2036
|
+
it { expect(viewer_percentage.keys).to match_array [:female, :male] }
|
2037
|
+
end
|
2038
|
+
|
2039
|
+
context 'with the :in option set to {country: country code}' do
|
2040
|
+
let(:location) { {country: country_code} }
|
2041
|
+
it { expect(viewer_percentage.keys).to match_array [:female, :male] }
|
2042
|
+
end
|
2043
|
+
end
|
2044
|
+
|
1125
2045
|
describe 'viewer percentage can be retrieved for a range of days' do
|
1126
2046
|
let(:viewer_percentage) { channel.viewer_percentage since: 1.year.ago, until: 10.days.ago}
|
1127
2047
|
it { expect(viewer_percentage).to be_a Hash }
|