|
|
@ -18,9 +18,11 @@ class Movie < ApplicationRecord
|
|
|
|
def flop?
|
|
|
|
def flop?
|
|
|
|
total_gross.blank? || total_gross < 225_000_000
|
|
|
|
total_gross.blank? || total_gross < 225_000_000
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def self.released
|
|
|
|
|
|
|
|
where("released_on < ?", Time.now).order(released_on: :desc)
|
|
|
|
scope :released, -> { where("released_on < ?", Time.now).order("released_on desc") }
|
|
|
|
end
|
|
|
|
scope :upcoming, -> { where("released_on > ?", Time.now).order("released_on asc") }
|
|
|
|
|
|
|
|
scope :recent, ->(max=5) { released.limit(max) }
|
|
|
|
|
|
|
|
|
|
|
|
def average_stars
|
|
|
|
def average_stars
|
|
|
|
reviews.average(:stars) || 0.0
|
|
|
|
reviews.average(:stars) || 0.0
|
|
|
|
end
|
|
|
|
end
|
|
|
|