fix error

This commit is contained in:
chiu 2021-09-19 22:21:19 +08:00
parent 3ddfe2ea14
commit 3f479c99d2
1 changed files with 3 additions and 3 deletions

View File

@ -82,7 +82,7 @@ class EventNews
scope :open_in_future, ->{where(:is_hidden.ne=>true,:is_preview.ne => true,:postdate.gt=>Time.now).order(postdate: :asc)} 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, event_date: :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}).order(is_top: :desc,postdate: :desc, event_date: :desc,id: :desc)}
scope :can_display_and_sorted_according_today, ->{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, event_date: :asc,id: :desc).where(:event_date.gte => Date.today.to_time)} scope :can_display_and_sorted_according_today, ->{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, event_date: :asc,postdate: :desc,id: :desc).where(:event_date.gte => Date.today.to_time)}
scope :is_approved, ->{where(:approved => true)} scope :is_approved, ->{where(:approved => true)}
scope :is_approved_and_show, ->{where(:approved => true,:is_hidden.ne=>true,:is_preview.ne => 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)} scope :filter_cats_and_tags, ->(cats,tags) {filter_by_widget_categories(cats,false).filter_by_tags(tags)}
@ -90,7 +90,7 @@ class EventNews
before_save :check_limit before_save :check_limit
index({postdate: 1}, { unique: false, background: true }) index({postdate: 1}, { unique: false, background: true })
index({is_top: -1, postdate: -1, event_date: -1, _id: -1}, { unique: false, background: true }) index({is_top: -1, postdate: -1, event_date: -1, _id: -1}, { unique: false, background: true })
index({is_top: -1,postdate: -1, event_date: 1, _id: -1}, { unique: false, background: true }) index({is_top: -1, event_date: 1, postdate: -1, _id: -1}, { unique: false, background: true })
def get_org_model def get_org_model
if self.is_preview if self.is_preview
org_model = nil org_model = nil