Update sort.
This commit is contained in:
parent
a92b6993c9
commit
26e9ef8d43
|
@ -26,7 +26,7 @@ class Admin::PatentsController < OrbitMemberController
|
||||||
redirect_to :action=> 'index'
|
redirect_to :action=> 'index'
|
||||||
end
|
end
|
||||||
def merge
|
def merge
|
||||||
@patents=Patent.order_by(:year=>'desc').map{|value| value}.group_by{|v| [v[:patent_title],v[:patent_no]]}
|
@patents=Patent.sort_year_date.map{|value| value}.group_by{|v| [v[:patent_title],v[:patent_no]]}
|
||||||
@patents.each do |key,value|
|
@patents.each do |key,value|
|
||||||
if value.length<=1
|
if value.length<=1
|
||||||
@patents.delete key
|
@patents.delete key
|
||||||
|
@ -49,7 +49,7 @@ class Admin::PatentsController < OrbitMemberController
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@patents = Patent.order_by(:year=>'desc').page(params[:page]).per(10)
|
@patents = Patent.sort_year_date.page(params[:page]).per(10)
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
|
|
@ -3,7 +3,7 @@ class PersonalPatentsController < 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
|
||||||
patents = Patent.where(is_hidden: false).sort_for_frontend.page(OrbitHelper.params[:page_no]).per(page_data_count)
|
patents = Patent.sort_for_frontend.page(OrbitHelper.params[:page_no]).per(page_data_count)
|
||||||
fields_to_show = Page.where(page_id: params[:page_id]).first.custom_array_field rescue []
|
fields_to_show = Page.where(page_id: params[:page_id]).first.custom_array_field rescue []
|
||||||
if fields_to_show.blank?
|
if fields_to_show.blank?
|
||||||
fields_to_show = %w[
|
fields_to_show = %w[
|
||||||
|
|
|
@ -34,7 +34,9 @@ class Patent
|
||||||
|
|
||||||
before_validation :add_http
|
before_validation :add_http
|
||||||
|
|
||||||
scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(:year => "desc", :application_date => "desc", :publish_date => "desc") }
|
index({year: -1, application_date: -1, publish_date: -1, _id: -1}, { unique: false, background: false })
|
||||||
|
scope :sort_year_date, ->{ order_by(:year => "desc", :application_date => "desc", :publish_date => "desc", :id => "desc") }
|
||||||
|
scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(:year => "desc", :application_date => "desc", :publish_date => "desc", :id => "desc") }
|
||||||
|
|
||||||
def member_profile()
|
def member_profile()
|
||||||
(super || MemberProfile.find(self.member_profile_id)) rescue nil
|
(super || MemberProfile.find(self.member_profile_id)) rescue nil
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
|
|
||||||
<%
|
<%
|
||||||
if has_access?
|
if has_access?
|
||||||
@patents = Patent.where(member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
|
@patents = Patent.where(member_profile_id: @member.id).sort_year_date.page(params[:page]).per(10)
|
||||||
else
|
else
|
||||||
@patents = Patent.where(is_hidden: false, member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
|
@patents = Patent.where(is_hidden: false, member_profile_id: @member.id).sort_year_date.page(params[:page]).per(10)
|
||||||
end
|
end
|
||||||
%>
|
%>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue