count_group_watchers_v2.patch

salman mp, 2022-05-01 15:16

Download (1.01 KB)

View differences:

lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb (revision 41000+:f7b4efce8b3f+)
16 16
            has_many :watcher_users, :through => :watchers, :source => :user, :validate => false
17 17

  
18 18
            scope :watched_by, lambda { |user_id|
19
              user_ids = user_id.is_a?(User) ? user_id.groups.map(&:id) : []
20
              user_ids << user_id.id
19 21
              joins(:watchers).
20
              where("#{Watcher.table_name}.user_id = ?", user_id)
22
              where("#{Watcher.table_name}.user_id IN (?)", user_ids)
21 23
            }
22 24
          end
23 25
          send :include, Redmine::Acts::Watchable::InstanceMethods