mirror of
https://github.com/discourse/discourse.git
synced 2024-12-29 03:58:34 +08:00
32 lines
624 B
Ruby
32 lines
624 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
# This is used on a topic page
|
||
|
class TopicParticipantGroupsSummary
|
||
|
attr_reader :topic, :options
|
||
|
|
||
|
def initialize(topic, options = {})
|
||
|
@topic = topic
|
||
|
@options = options
|
||
|
@group = options[:group]
|
||
|
end
|
||
|
|
||
|
def summary
|
||
|
group_participants.compact
|
||
|
end
|
||
|
|
||
|
def group_participants
|
||
|
return [] if group_ids.blank?
|
||
|
group_ids.map { |id| group_lookup[id] }
|
||
|
end
|
||
|
|
||
|
def group_ids
|
||
|
ids = topic.allowed_group_ids
|
||
|
ids = ids - [@group.id] if @group.present?
|
||
|
ids
|
||
|
end
|
||
|
|
||
|
def group_lookup
|
||
|
@group_lookup ||= options[:group_lookup] || GroupLookup.new(group_ids)
|
||
|
end
|
||
|
end
|