refactor
This commit is contained in:
parent
c42fcc824a
commit
0545863642
|
@ -1,18 +1,10 @@
|
|||
class Api::V1::MaintainersController < Api::V1::BaseController
|
||||
before_filter :authenticate_user! unless APP_CONFIG['anonymous_access']
|
||||
before_filter :find_platform
|
||||
load_and_authorize_resource :platform
|
||||
|
||||
def index
|
||||
@maintainers = BuildList::Package.actual.by_platform(@platform)
|
||||
.order('lower(name) ASC, length(name) ASC')
|
||||
.includes(:project)
|
||||
.paginate(paginate_params)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_platform
|
||||
@platform = Platform.find(params[:platform_id])
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -6,7 +6,6 @@ class Platforms::MaintainersController < ApplicationController
|
|||
|
||||
def index
|
||||
@maintainers = BuildList::Package.actual.by_platform(@platform)
|
||||
.order('lower(name) ASC, length(name) ASC')
|
||||
.includes(:project)
|
||||
@maintainers = @maintainers.where('name ILIKE ?', "%#{params[:q]}%") if params[:q].present?
|
||||
@maintainers = @maintainers.paginate(:page => params[:page])
|
||||
|
|
|
@ -12,6 +12,8 @@ class BuildList::Package < ActiveRecord::Base
|
|||
:presence => true
|
||||
validates :package_type, :inclusion => PACKAGE_TYPES
|
||||
|
||||
default_scope order('lower(name) ASC, length(name) ASC')
|
||||
|
||||
# Fetches only actual (last publised) packages.
|
||||
scope :actual, where(:actual => true)
|
||||
scope :by_platform, lambda {|platform| where(:platform_id => platform) }
|
||||
|
|
Loading…
Reference in New Issue