Skip to content

Commit 8e28570

Browse files
committed
feat: promote lately hosting locations by showing them first
1 parent 35571be commit 8e28570

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

app/controllers/locations_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class LocationsController < ApplicationController
44
expose(:location, find: ->(id, scope) { scope.from_slug(id) })
5-
expose(:locations) { Location.ordered }
5+
expose(:locations) { Location.ordered_by_last_occurrence }
66
expose(:organizers) { User.organizers }
77
expose(:stats) { Event.stats }
88

app/models/location.rb

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class Location < ApplicationRecord
1616
validates :url, length: { maximum: 255 }
1717

1818
scope :ordered, -> { order('name ASC') }
19+
scope :ordered_by_last_occurrence, -> { joins(:events).group(primary_key).order(Event.arel_table[:date].maximum.desc) }
1920
default_scope -> { where(label: Whitelabel[:label_id]) }
2021

2122
def geo_coder_address

0 commit comments

Comments
 (0)