diff --git a/app/controllers/api/v1/maintainers_controller.rb b/app/controllers/api/v1/maintainers_controller.rb index 625a63134..a85203e4b 100644 --- a/app/controllers/api/v1/maintainers_controller.rb +++ b/app/controllers/api/v1/maintainers_controller.rb @@ -5,6 +5,9 @@ class Api::V1::MaintainersController < Api::V1::BaseController def index @maintainers = BuildList::Package.actual.by_platform(@platform) .includes(:project) - .paginate(paginate_params) + if name = params[:filter].try(:[], :package_name) + @maintainers = @maintainers.like_name(name) + end + @maintainers = @maintainers.paginate(paginate_params) end end diff --git a/app/controllers/platforms/maintainers_controller.rb b/app/controllers/platforms/maintainers_controller.rb index 5c3e49a84..10e200aa3 100644 --- a/app/controllers/platforms/maintainers_controller.rb +++ b/app/controllers/platforms/maintainers_controller.rb @@ -7,7 +7,7 @@ class Platforms::MaintainersController < ApplicationController def index @maintainers = BuildList::Package.actual.by_platform(@platform) .includes(:project) - @maintainers = @maintainers.where('name ILIKE ?', "%#{params[:q]}%") if params[:q].present? + @maintainers = @maintainers.like_name(params[:q]) if params[:q].present? @maintainers = @maintainers.paginate(:page => params[:page]) end diff --git a/app/models/build_list/package.rb b/app/models/build_list/package.rb index 6a3dcb79c..108f9ea4e 100644 --- a/app/models/build_list/package.rb +++ b/app/models/build_list/package.rb @@ -19,6 +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}%")} def assignee project.maintainer