forked from saurabh/personal-diploma
Update sort.
This commit is contained in:
parent
ecf1dee968
commit
ee55f63fa8
|
@ -10,7 +10,7 @@ class Admin::DiplomasController < OrbitMemberController
|
|||
before_action :allow_admin_only, :only => [:index, :setting]
|
||||
|
||||
def index
|
||||
@diplomas = Diploma.order_by(:end_date=>'desc',:start_date=>'desc').page(params[:page]).per(10)
|
||||
@diplomas = Diploma.sort_date.page(params[:page]).per(10)
|
||||
end
|
||||
|
||||
def new
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class PersonalDiplomasController < ApplicationController
|
||||
def index
|
||||
diplomas = Diploma.where(:is_hidden=>false).order_by(:end_date=>'desc', :start_date=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
|
||||
diplomas = Diploma.sort_for_frontend.page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
|
||||
fields_to_show = Page.where(:page_id => params[:page_id]).first.custom_array_field rescue []
|
||||
if fields_to_show.blank?
|
||||
fields_to_show = [
|
||||
|
|
|
@ -25,7 +25,9 @@ class Diploma
|
|||
|
||||
before_validation :add_http
|
||||
|
||||
scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(:end_date => "desc", :start_date => "desc") }
|
||||
index({end_date: -1, start_date: -1, _id: -1}, { unique: false, background: false })
|
||||
scope :sort_date, ->{ order_by(:end_date => "desc", :start_date => "desc", :id => "desc") }
|
||||
scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(:end_date => "desc", :start_date => "desc", :id => "desc") }
|
||||
|
||||
def duration
|
||||
if !self.start_date.nil? or !self.end_date.nil?
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
<%
|
||||
if has_access?
|
||||
@diplomas = Diploma.where(member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
|
||||
@diplomas = Diploma.where(member_profile_id: @member.id).sort_date.page(params[:page]).per(10)
|
||||
else
|
||||
@diplomas = Diploma.where(is_hidden: false, member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
|
||||
@diplomas = Diploma.where(is_hidden: false, member_profile_id: @member.id).sort_date.page(params[:page]).per(10)
|
||||
end
|
||||
%>
|
||||
|
||||
|
|
Loading…
Reference in New Issue