Package.without_screenshots_most_visits added

This commit is contained in:
Christoph Haas 2016-08-17 09:28:06 +02:00
parent 046897f1c6
commit dbca1e0a19

View file

@ -40,6 +40,12 @@ class Package < ActiveRecord::Base
where.not(id: subselect)
end
# Packages that need screenshots and have most visits.
# These packages are most likely to need a screenshot.
def self.without_screenshots_most_visits
self.without_screenshots.order(visits: :desc)
end
# Return a query of all approved/public screenshots of this package
def screenshots_approved
self.screenshots.find_by(approved: true)