Skip to content

Instantly share code, notes, and snippets.

@r00k
Created Feb 21, 2016
Embed
What would you like to do?
Not so hard after all.
def self.popular_this_week
Podcast.
joins(:downloads).
select("podcasts.*, COUNT(podcast_id) as download_count").
where("downloads.created_at >= ?", 1.week.ago.utc).
group("podcasts.id").
order("download_count DESC")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment