Created
February 21, 2016 04:12
-
-
Save r00k/01340add5cba8dee53df to your computer and use it in GitHub Desktop.
Not so hard after all.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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