From 0a28c11ce10aef42a468fa3735002e7aa2c2452a Mon Sep 17 00:00:00 2001 From: "jonathan.kerr" <3410350+jonodrew@users.noreply.github.com> Date: Mon, 9 Mar 2026 16:06:46 +0000 Subject: [PATCH] Override default scope for Workshop The default_scope for Workshop sorts events in descending order. For future events, we want them sorted in ascending order (ie soonest first). Because I don't know why this scope was added, and where else it's used, I'm not going to change it. Instead, I've updated the two 'upcoming' scopes to override the default ordering. I tested this by generating 15 Workshops for various times over the next two weeks. Without this fix, the workshops were the 5 furthest from this point in time. With this fix, they were the 5 soonest. Signed-off-by: jonathan.kerr <3410350+jonodrew@users.noreply.github.com> --- app/models/concerns/listable.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/concerns/listable.rb b/app/models/concerns/listable.rb index 30cd3c8e8..f0f58785b 100644 --- a/app/models/concerns/listable.rb +++ b/app/models/concerns/listable.rb @@ -4,8 +4,8 @@ module Listable extend ActiveSupport::Concern included do - scope :today_and_upcoming, -> { where('date_and_time >= ?', Time.zone.today).order(date_and_time: :asc) } - scope :upcoming, -> { where('date_and_time >= ?', Time.zone.now).order(date_and_time: :asc) } + scope :today_and_upcoming, -> { where('date_and_time >= ?', Time.zone.today).reorder(date_and_time: :asc) } + scope :upcoming, -> { where('date_and_time >= ?', Time.zone.now).reorder(date_and_time: :asc) } scope :past, -> { where('date_and_time < ?', Time.zone.now).order(:date_and_time) } scope :recent, lambda { where('date_and_time < ?', Time.zone.now)