Update sort.
This commit is contained in:
parent
161508f43a
commit
f1b91eea20
|
@ -10,7 +10,7 @@ class Admin::LabsController < OrbitMemberController
|
|||
before_action :allow_admin_only, :only => [:index, :setting]
|
||||
|
||||
def index
|
||||
@labs = Lab.order_by(:year=>'desc').page(params[:page]).per(10)
|
||||
@labs = Lab.sort_year.page(params[:page]).per(10)
|
||||
end
|
||||
|
||||
def new
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class PersonalLabsController < ApplicationController
|
||||
def index
|
||||
labs = Lab.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
|
||||
labs = Lab.sort_for_frontend.page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
|
||||
lab_list = labs.collect do |lab|
|
||||
member = lab.member_profile
|
||||
path = OrbitHelper.url_to_plugin_show(member.to_param, 'member') rescue '#'
|
||||
|
|
|
@ -29,7 +29,9 @@ class Lab
|
|||
|
||||
before_validation :add_http
|
||||
|
||||
scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(:year => "desc") }
|
||||
index({year: -1, _id: -1}, { unique: false, background: false })
|
||||
scope :sort_year, ->{ order_by(:year => "desc", :id=>"desc") }
|
||||
scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(:year => "desc", :id=>"desc") }
|
||||
|
||||
def get_plugin_data(fields_to_show)
|
||||
plugin_datas = []
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
<%
|
||||
if has_access?
|
||||
@labs = Lab.where(member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
|
||||
@labs = Lab.where(member_profile_id: @member.id).sort_year.page(params[:page]).per(10)
|
||||
else
|
||||
@labs = Lab.where(is_hidden: false, member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
|
||||
@labs = Lab.where(is_hidden: false, member_profile_id: @member.id).sort_year.page(params[:page]).per(10)
|
||||
end
|
||||
%>
|
||||
|
||||
|
|
Loading…
Reference in New Issue