Currently the virtual attribute "image_url" in the screenshots model apparently runs one SQL query each to get the packages data.
33 lines
1 KiB
Ruby
33 lines
1 KiB
Ruby
class PackagesController < ApplicationController
|
|
def index
|
|
@packages = Package
|
|
|
|
if params[:with_screenshots]=='yes'
|
|
#@packages = @packages.joins(:screenshots).where('screenshots.approved = ?', true)
|
|
|
|
# Limit the packages to those that have approved screenshots.
|
|
# Also eager-load the screenshots.
|
|
@packages = @packages.includes(:screenshots).where("screenshots.approved"=>true)
|
|
#@packages = @packages.where("screenshots.approved"=>true)
|
|
end
|
|
|
|
#if params[:search]
|
|
#query = '%'+params[:search]+'%'
|
|
# TODO: Index on lower(…) is missing. Does not scale.
|
|
# TODO: Consider using a serious search engine like Xapian or ElasticSearch.
|
|
#@packages = @packages.where("lower(description) like lower(?) or lower(name) like lower(?)", query, query)
|
|
#end
|
|
|
|
#@packages = @packages.order('name').includes(:screenshots).limit(20)
|
|
@packages = @packages.order('name').limit(20)
|
|
end
|
|
|
|
def with_screenshots
|
|
end
|
|
|
|
def without_screenshots
|
|
end
|
|
|
|
def moderate
|
|
end
|
|
end
|