def projects
@status = params[:status] || 1
- scope = Project.status(@status).order('lft')
+ scope = Project.status(@status).sorted
scope = scope.like(params[:name]) if params[:name].present?
@projects = scope.to_a
# Lists visible projects
def index
+ scope = Project.visible.sorted
+
respond_to do |format|
format.html {
- scope = Project
unless params[:closed]
scope = scope.active
end
- @projects = scope.visible.order('lft').to_a
+ @projects = scope.to_a
}
format.api {
@offset, @limit = api_offset_and_limit
- @project_count = Project.visible.count
- @projects = Project.visible.offset(@offset).limit(@limit).order('lft').to_a
+ @project_count = scope.count
+ @projects = scope.offset(@offset).limit(@limit).to_a
}
format.atom {
- projects = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).to_a
+ projects = scope.reorder(:created_on => :desc).limit(Setting.feeds_limit.to_i).to_a
render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}")
}
end
where("LOWER(identifier) LIKE :p OR LOWER(name) LIKE :p", :p => pattern)
end
}
+ scope :sorted, lambda {order(:lft)}
def initialize(attributes=nil, *args)
super