debshots/app/controllers/packages_controller.rb
Christoph Haas 88dfb33721 Return results for packages only with screenshots.
Currently the packages controller is not working well. The JOIN is not
the best way apparently as the 'description' column exists for both the
"packages" and the "screenshots" table. So another way to query for
the data needs to be found.
2013-08-06 23:36:48 +02:00

27 lines
696 B
Ruby

class PackagesController < ApplicationController
def index
@packages = Package
if params[:with_screenshots]=='yes'
@packages = @packages.joins(:screenshots).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').limit(20)
end
def with_screenshots
end
def without_screenshots
end
def moderate
end
end