fix sorting error for show_today_data_first

This commit is contained in:
邱博亞 2024-09-28 20:45:57 +08:00
parent 772bfb4979
commit 2d2d5fb276
1 changed files with 4 additions and 1 deletions

View File

@ -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 :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, ->{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, ->{ scope :valid_time_range, ->{
and_any_of([ and_any_of([
{"postdate"=>{"$lte"=> Time.now}, "deadline"=>{"$gte"=> Time.now}}, {"postdate"=>{"$lte"=> Time.now}, "deadline"=>{"$gte"=> Time.now}},