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