Skip to content

Commit 0a28c11

Browse files
committed
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>
1 parent fde6023 commit 0a28c11

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

app/models/concerns/listable.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ module Listable
44
extend ActiveSupport::Concern
55

66
included do
7-
scope :today_and_upcoming, -> { where('date_and_time >= ?', Time.zone.today).order(date_and_time: :asc) }
8-
scope :upcoming, -> { where('date_and_time >= ?', Time.zone.now).order(date_and_time: :asc) }
7+
scope :today_and_upcoming, -> { where('date_and_time >= ?', Time.zone.today).reorder(date_and_time: :asc) }
8+
scope :upcoming, -> { where('date_and_time >= ?', Time.zone.now).reorder(date_and_time: :asc) }
99
scope :past, -> { where('date_and_time < ?', Time.zone.now).order(:date_and_time) }
1010
scope :recent, lambda {
1111
where('date_and_time < ?', Time.zone.now)

0 commit comments

Comments
 (0)