diff --git a/app/controllers/api/v1/maintainers_controller.rb b/app/controllers/api/v1/maintainers_controller.rb index a85203e4b..cda1761f1 100644 --- a/app/controllers/api/v1/maintainers_controller.rb +++ b/app/controllers/api/v1/maintainers_controller.rb @@ -3,11 +3,9 @@ class Api::V1::MaintainersController < Api::V1::BaseController load_and_authorize_resource :platform def index - @maintainers = BuildList::Package.actual.by_platform(@platform) - .includes(:project) - if name = params[:filter].try(:[], :package_name) - @maintainers = @maintainers.like_name(name) - end - @maintainers = @maintainers.paginate(paginate_params) + @maintainers = BuildList::Package.includes(:project) + .actual.by_platform(@platform) + .like_name(params[:filter].try(:[], :package_name)) + .paginate(paginate_params) end end diff --git a/app/controllers/platforms/maintainers_controller.rb b/app/controllers/platforms/maintainers_controller.rb index 10e200aa3..9abd417de 100644 --- a/app/controllers/platforms/maintainers_controller.rb +++ b/app/controllers/platforms/maintainers_controller.rb @@ -5,10 +5,9 @@ class Platforms::MaintainersController < ApplicationController load_and_authorize_resource :platform def index - @maintainers = BuildList::Package.actual.by_platform(@platform) - .includes(:project) - @maintainers = @maintainers.like_name(params[:q]) if params[:q].present? - @maintainers = @maintainers.paginate(:page => params[:page]) + @maintainers = BuildList::Package.includes(:project) + .actual.by_platform(@platform) + .like_name(params[:q]) + .paginate(:page => params[:page]) end - end diff --git a/app/models/build_list/package.rb b/app/models/build_list/package.rb index 108f9ea4e..891fe239b 100644 --- a/app/models/build_list/package.rb +++ b/app/models/build_list/package.rb @@ -19,7 +19,7 @@ class BuildList::Package < ActiveRecord::Base scope :by_platform, lambda {|platform| where(:platform_id => platform) } scope :by_name, lambda {|name| where(:name => name) } scope :by_package_type, lambda {|type| where(:package_type => type) } - scope :like_name, lambda {|name| where('name ILIKE ?', "%#{name}%")} + scope :like_name, lambda {|name| where('name ILIKE ?', "%#{name}%") if name.present?} def assignee project.maintainer