Fullscreen/yt — pull request #97 by claudiofullscreen (2014-10-08 17:52:47+00:00)
Title: Allow statistics part on channels + viewer percentages

@stavro @Nuru This stems from my comment https://github.com/Fullscreen/yt/pull/31#issuecomment-58373026 so read that first.

In order to achieve what I describe there (having `select` and `includes` working on `.partnered_channels`), we first need the related Collection to accept those parameters and eager-load the requested data. This is what the current PR provides.

After the current PR, you will be able to do the following:

```ruby
yt_channels = yt_content_owner.partnered_channels.where(part: 'statistics')

ids = "contentOwner==#{yt_content_owner.owner_name}"
filters = "channel==#{yt_channels.map(&:id).join ','}"
viewer_percentages = Yt::Collections::ViewerPercentages.new(auth: content_owner).where ids: ids, filters: filters

yt_channels.each do |yt_channel|
channel = Channel.find_or_initialize_by slug: yt_channel.id
channel.reach = yt_channel.subscriber_count
channel.demographics = viewer_percentages[yt_channel.id]
channel.save
end
```

If the number of partnered channels is <= 50, then this works perfectly, and **only uses two queries**.
However, as @Nuru pointed out in https://github.com/Fullscreen/yt/pull/31#issuecomment-58394525 this approach needs to be slightly adapted if there are more partnered channels, because:

* we cannot collect all their IDs at once with `yt_channels.map(&:id)` (they are paginated)
* we cannot ask YouTube Analytics API for more than 200 channels in each request

Thoughts?