forked from saurabh/personal-journal
Update sort.
This commit is contained in:
parent
7421469f91
commit
d1379bf8cd
|
@ -25,7 +25,7 @@ class Admin::JournalPapersController < OrbitMemberController
|
|||
redirect_to :action=> 'index'
|
||||
end
|
||||
def merge
|
||||
@journals=JournalPaper.order_by(:year=>'desc').map{|value| value}.group_by{|v| [v[:paper_title],v[:journal_title]]}
|
||||
@journals=JournalPaper.sort_year_date.map{|value| value}.group_by{|v| [v[:paper_title],v[:journal_title]]}
|
||||
@journals.each do |key,value|
|
||||
if value.length<=1
|
||||
@journals.delete key
|
||||
|
@ -47,7 +47,7 @@ class Admin::JournalPapersController < OrbitMemberController
|
|||
end
|
||||
end
|
||||
def index
|
||||
@writing_journals = JournalPaper.order_by(:year=>'desc').page(params[:page]).per(10)
|
||||
@writing_journals = JournalPaper.sort_year_date.page(params[:page]).per(10)
|
||||
end
|
||||
|
||||
def new
|
||||
|
|
|
@ -3,7 +3,7 @@ class PersonalJournalsController < ApplicationController
|
|||
def index
|
||||
params = OrbitHelper.params
|
||||
page_data_count = OrbitHelper.page_data_count
|
||||
journal_papers = JournalPaper.where(is_hidden: false).sort_for_frontend.page(OrbitHelper.params[:page_no]).per(page_data_count)
|
||||
journal_papers = JournalPaper.sort_for_frontend.page(OrbitHelper.params[:page_no]).per(page_data_count)
|
||||
page = Page.where(page_id: params[:page_id]).first rescue nil
|
||||
if page.custom_string_field == 'table'
|
||||
fields_to_show = page.custom_array_field rescue []
|
||||
|
|
|
@ -47,8 +47,9 @@ class JournalPaper
|
|||
|
||||
before_validation :add_http
|
||||
# validates :paper_title, presence: true
|
||||
|
||||
scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(:year => "desc", :publication_date => "desc") }
|
||||
index({year: -1, :publication_date => -1, _id: -1}, { unique: false, background: false })
|
||||
scope :sort_year_date, ->{ order_by(:year => "desc", :publication_date => "desc", :id=>"desc") }
|
||||
scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(:year => "desc", :publication_date => "desc", :id=>"desc") }
|
||||
|
||||
def create_link
|
||||
title = []
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
<% end %>
|
||||
<%
|
||||
if has_access?
|
||||
@writing_journals = JournalPaper.where(member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
|
||||
@writing_journals = JournalPaper.where(member_profile_id: @member.id).sort_year_date.page(params[:page]).per(10)
|
||||
else
|
||||
@writing_journals = JournalPaper.where(is_hidden: false, member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
|
||||
@writing_journals = JournalPaper.where(is_hidden: false, member_profile_id: @member.id).sort_year_date.page(params[:page]).per(10)
|
||||
end
|
||||
%>
|
||||
<% if has_access? %>
|
||||
|
|
Loading…
Reference in New Issue