Avoid N+1 SQL queries with CanCanCan accessibility checks
This commit is contained in:
parent
f154c1838c
commit
b36a49a6cd
6 changed files with 14 additions and 12 deletions
|
|
@ -48,7 +48,7 @@ class Package < ApplicationRecord
|
|||
def self.with_screenshots
|
||||
# Query for all packages who's ID appears in a screenshot's "package_id" field
|
||||
subselect = Screenshot.select(:package_id)
|
||||
where(id: subselect )
|
||||
where(id: subselect)
|
||||
end
|
||||
|
||||
# Return a list of packages that have screenshots to be moderated
|
||||
|
|
@ -71,7 +71,7 @@ class Package < ApplicationRecord
|
|||
|
||||
# Return a query of all approved/public screenshots of this package
|
||||
def screenshots_pending
|
||||
self.screenshots.where('approved=false')
|
||||
self.screenshots.where(approved: false)
|
||||
end
|
||||
|
||||
# Return a list of packages that have unapproved screenshots
|
||||
|
|
|
|||
|
|
@ -63,9 +63,9 @@ class Screenshot < ApplicationRecord
|
|||
self.save!
|
||||
end
|
||||
|
||||
# Get the newest screenshot regardless of the package it belongs to
|
||||
def self.newest_upload
|
||||
self.order(created_at: :desc).where(approved: true).first
|
||||
# Get the newest screenshots regardless of the package it belongs to
|
||||
def self.newest
|
||||
self.order(created_at: :desc)
|
||||
end
|
||||
|
||||
# Return the part of the version up to the first - or +
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue