mirror of
https://github.com/discourse/discourse.git
synced 2024-12-01 03:13:38 +08:00
d4bfd441ba
After this change, we can view all participant group names on the topic list page. Co-authored-by: Régis Hanol <regis@hanol.fr>
19 lines
325 B
Ruby
19 lines
325 B
Ruby
# frozen_string_literal: true
|
|
|
|
class GroupLookup
|
|
def initialize(group_ids = [])
|
|
@group_ids = group_ids.flatten.compact.uniq
|
|
end
|
|
|
|
# Lookup a group by id
|
|
def [](group_id)
|
|
group_names[group_id]
|
|
end
|
|
|
|
private
|
|
|
|
def group_names
|
|
@group_names ||= Group.where(id: @group_ids).pluck(:id, :name).to_h
|
|
end
|
|
end
|