Update sort.
This commit is contained in:
parent
63b8a639b8
commit
556858858f
|
@ -24,9 +24,9 @@ class Admin::WritingsController < OrbitMemberController
|
|||
end
|
||||
if params[:clear] != 'true'
|
||||
if(params[:new_filter] != nil && params[:new_filter][:type] == 'category')
|
||||
@writings = Writing.where(:category_id.in=> @filter['category']).order_by(:year=>'desc',:month=>'desc',:id=>'desc').page(params[:page]).per(10)
|
||||
@writings = Writing.where(:category_id.in=> @filter['category']).sort_year_month.page(params[:page]).per(10)
|
||||
else
|
||||
@writings = Writing.order_by(:year=>'desc',:month=>'desc',:id=>'desc').page(params[:page]).per(10)
|
||||
@writings = Writing.sort_year_month.page(params[:page]).per(10)
|
||||
end
|
||||
else
|
||||
redirect_to admin_writings_url
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class PersonalWritingsController < ApplicationController
|
||||
def index
|
||||
writings = Writing.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
|
||||
writings = Writing.sort_for_frontend.page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
|
||||
writing_list = writings.collect do |writing|
|
||||
{
|
||||
"year" => writing.year,
|
||||
|
|
|
@ -20,8 +20,9 @@ class Writing
|
|||
accepts_nested_attributes_for :writing_files, :allow_destroy => true
|
||||
|
||||
before_validation :add_http
|
||||
|
||||
scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(:year => "desc") }
|
||||
index({year: -1, month: -1, _id: -1}, { unique: false, background: false })
|
||||
scope :sort_year_month, ->{ order_by(:year=>'desc',:month=>'desc',:id=>'desc') }
|
||||
scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(:year=>"desc",:month=>'desc',:id=>"desc") }
|
||||
|
||||
def get_plugin_data(fields_to_show)
|
||||
plugin_datas = []
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
<%
|
||||
if has_access?
|
||||
@writings = Writing.where(member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
|
||||
@writings = Writing.where(member_profile_id: @member.id).sort_year_month.page(params[:page]).per(10)
|
||||
else
|
||||
@writings = Writing.where(is_hidden: false, member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
|
||||
@writings = Writing.where(is_hidden: false, member_profile_id: @member.id).sort_year_month.page(params[:page]).per(10)
|
||||
end
|
||||
%>
|
||||
|
||||
|
|
Loading…
Reference in New Issue