PERF: no need to select entire group just to find name

Note, this is a very good candidate for some cache longer term to cut
the query out
This commit is contained in:
Sam Saffron 2019-03-26 17:59:05 +11:00
parent 3cfedc6c71
commit 5a8451bf89
1 changed files with 3 additions and 1 deletions

View File

@ -125,7 +125,9 @@ module ApplicationHelper
result << "category-#{@category.url.sub(/^\/c\//, '').gsub(/\//, '-')}"
end
if current_user.present? && primary_group_name = current_user.primary_group&.name
if current_user.present? &&
current_user.primary_group_id &&
primary_group_name = Group.where(id: current_user.primary_group_id).pluck(:name).first
result << "primary-group-#{primary_group_name.downcase}"
end