discourse/lib/group_lookup.rb
Vinoth Kannan d4bfd441ba
FEATURE: display PM participant group names in the topics list. (#21677)
After this change, we can view all participant group names on the topic list page.

Co-authored-by: Régis Hanol <regis@hanol.fr>
2023-05-31 19:32:06 +05:30

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