forked from saurabh/personal-lab
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]
|
before_action :allow_admin_only, :only => [:index, :setting]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@labs = Lab.order_by(:year=>'desc').page(params[:page]).per(10)
|
@labs = Lab.sort_year.page(params[:page]).per(10)
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class PersonalLabsController < ApplicationController
|
class PersonalLabsController < ApplicationController
|
||||||
def index
|
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|
|
lab_list = labs.collect do |lab|
|
||||||
member = lab.member_profile
|
member = lab.member_profile
|
||||||
path = OrbitHelper.url_to_plugin_show(member.to_param, 'member') rescue '#'
|
path = OrbitHelper.url_to_plugin_show(member.to_param, 'member') rescue '#'
|
||||||
|
|
|
@ -29,7 +29,9 @@ class Lab
|
||||||
|
|
||||||
before_validation :add_http
|
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)
|
def get_plugin_data(fields_to_show)
|
||||||
plugin_datas = []
|
plugin_datas = []
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
|
|
||||||
<%
|
<%
|
||||||
if has_access?
|
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
|
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
|
end
|
||||||
%>
|
%>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue