Creating query to get screenshots visible to a user

This commit is contained in:
Christoph Haas 2016-03-05 15:55:24 +01:00
parent 53b297da1e
commit 6192e1bc3b
3 changed files with 19 additions and 16 deletions

View file

@ -33,20 +33,8 @@ class Package < ActiveRecord::Base
end
# Return a query of all approved/public screenshots of this package
def self.query_approved
def self.screenshots_approved
self.screenshots.find_by(approved: true)
end
# Return a query of all screenshots that the current user may see
# Consists of:
# - approved (public) screenshots
# - screenshots uploaded by the user (determined by cookie session)
working on it
def self.query_visible_to_user
approved_screenshots = Screenshot.find_by()
subselect = Screenshot.select(:package_id)
where.not(id: subselect)
end
end