From 2d2d5fb276c8c8d120ec2f17550561bcdd224ebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E5=8D=9A=E4=BA=9E?= Date: Sat, 28 Sep 2024 20:45:57 +0800 Subject: [PATCH] fix sorting error for show_today_data_first --- app/models/event_news.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/event_news.rb b/app/models/event_news.rb index 02dd66c..0e66401 100644 --- a/app/models/event_news.rb +++ b/app/models/event_news.rb @@ -107,7 +107,10 @@ class EventNews 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).valid_time_range} - scope :can_display_and_sorted_according_today, ->{where(:is_hidden.ne=>true,:is_preview.ne => true).valid_time_range.where(:event_date.gte => Date.today.to_time)} + scope :can_display_and_sorted_according_today, ->{ + where(:is_hidden.ne=>true,:is_preview.ne => true) + .order(event_date: :asc).valid_time_range.where(:event_date.gte => Date.today.to_time) + } scope :valid_time_range, ->{ and_any_of([ {"postdate"=>{"$lte"=> Time.now}, "deadline"=>{"$gte"=> Time.now}},