Last active
December 14, 2015 19:38
-
-
Save superbilk/5137493 to your computer and use it in GitHub Desktop.
How do I refactor this? DEPRECATION WARNING: Relation#calculate with finder options is deprecated. Please build a scope and then call calculate on it instead. (called from averages at /app/models/star.rb:7) Code is simplified.
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
class Star < ActiveRecord::Base | |
default_scope order: 'registered_at DESC' | |
scope :registered_before, ->(days) { where("registered_at >= ?", days.days.ago) } | |
def self.averages days = 90 | |
registered_before(days).average(:stars, group: "DATE(registered_at, '+1 day')") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment