From 3381ce71904c3e35b82c83cd6e32626c0e653cc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E5=8D=9A=E4=BA=9E?= Date: Thu, 18 Nov 2021 11:12:46 +0800 Subject: [PATCH] fix error --- app/models/bulletin.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/bulletin.rb b/app/models/bulletin.rb index b056bd5..12c847f 100644 --- a/app/models/bulletin.rb +++ b/app/models/bulletin.rb @@ -85,7 +85,7 @@ class Bulletin before_destroy :destroy_email scope :open_in_future, ->{where(:is_hidden.ne=>true,:is_preview.ne => true,:postdate.gt=>Time.now).order(postdate: :asc)} - scope :can_display_and_sorted, ->{where(:is_hidden.ne=>true,:is_preview.ne => true).any_of({:postdate.lte=>Time.now, :deadline.gte=>Time.now},{:postdate.lte=>Time.now, :deadline=>nil},{:postdate=>nil}).order(is_top: :desc,postdate: :desc,id: :desc)} + scope :can_display_and_sorted, ->{where(:is_hidden.ne=>true,:is_preview.ne => true).any_of({:postdate.lte=>Time.now, :deadline.gte=>Time.now},{:postdate.lte=>Time.now, :deadline=>nil},{:postdate=>nil,:deadline.gte=>Time.now},{:postdate=>nil,:deadline=>nil}).order(is_top: :desc,postdate: :desc,id: :desc)} scope :is_approved, ->{where(:approved => true)} scope :is_approved_and_show, ->{where(:approved => true,:is_hidden.ne=>true,:is_preview.ne => true)} scope :filter_cats_and_tags, ->(cats,tags) {filter_by_widget_categories(cats,false).filter_by_tags(tags)} @@ -93,6 +93,7 @@ class Bulletin before_save :check_limit index({postdate: 1}, { unique: false, background: true }) index({is_top: -1,postdate: -1, _id: -1}, { unique: false, background: true }) + index({is_hidden: 1,is_preview: 1, is_top: -1,postdate: -1,_id: -1,deadline: -1}, { unique: false, background: true }) def get_org_model if self.is_preview org_model = nil