mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-10-09 00:00:12 +09:00
Query sidebar directs and shared rooms separately
Load visible direct memberships ordered by room recency and other rooms ordered by name, instead of hydrating every membership and splitting them in Ruby. Fixes #307. Co-authored-by: Thomas Klemm <github@tklemm.eu>
This commit is contained in:
@@ -9,6 +9,7 @@ class Membership < ApplicationRecord
|
||||
enum :involvement, %w[ invisible nothing mentions everything ].index_by(&:itself), prefix: :involved_in
|
||||
|
||||
scope :with_ordered_room, -> { includes(:room).joins(:room).order("LOWER(rooms.name)") }
|
||||
scope :with_direct_rooms, -> { includes(:room).joins(:room).where(rooms: { type: "Rooms::Direct" }).order(rooms: { updated_at: :desc }) }
|
||||
scope :without_direct_rooms, -> { joins(:room).where.not(room: { type: "Rooms::Direct" }) }
|
||||
|
||||
scope :visible, -> { where.not(involvement: :invisible) }
|
||||
|
||||
Reference in New Issue
Block a user