add filters to maintainers list api

This commit is contained in:
vladdruzh 2012-11-29 09:32:10 +04:00
parent 0545863642
commit 5899d5f28f
3 changed files with 6 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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