How about a MusicVideo.count_by_date method?
def self.count_by_date
select [date, count] rows
dates_and_counts = connection.select_all(COUNT_BY_DATE_SQL)
transform to { date => count, … } hash
dates_and_counts.group_by { |row| row.first } end
You can probably do it with calculations API - worth taking a look - but hacking out the SQL this way is fine too.
jeremy