From ab273711156a5a9ebee9b27aa85f3ba72d613d18 Mon Sep 17 00:00:00 2001 From: Kevin McConnell Date: Thu, 27 Feb 2025 10:51:59 +0000 Subject: [PATCH] Include self in watcher list --- app/controllers/bubbles/watches_controller.rb | 2 +- app/models/user.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/bubbles/watches_controller.rb b/app/controllers/bubbles/watches_controller.rb index 8357655d0..e5a1873b5 100644 --- a/app/controllers/bubbles/watches_controller.rb +++ b/app/controllers/bubbles/watches_controller.rb @@ -2,7 +2,7 @@ class Bubbles::WatchesController < ApplicationController include BubbleScoped, BucketScoped def show - @watchers = @bubble.watchers_and_subscribers.without(Current.user) + @watchers = @bubble.watchers_and_subscribers.sorted_with_user_first(Current.user) end def create diff --git a/app/models/user.rb b/app/models/user.rb index 08cb2333b..c63814556 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -27,7 +27,8 @@ class User < ApplicationRecord after_create_commit :grant_access_to_buckets - scope :alphabetically, -> { order("LOWER(name)") } + scope :alphabetically, -> { order("lower(name)") } + scope :sorted_with_user_first, ->(user) { order(Arel.sql("id != ?, lower(name)", user.id)) } def initials name.to_s.scan(/\b\p{L}/).join.upcase