PERF: tag groups index query
This commit is contained in:
parent
4d27d7e1d3
commit
a74606c87c
|
@ -4,7 +4,7 @@ class TagGroupsController < ApplicationController
|
|||
before_filter :fetch_tag_group, only: [:show, :update, :destroy]
|
||||
|
||||
def index
|
||||
tag_groups = TagGroup.order('name ASC').includes(:parent_tag).all
|
||||
tag_groups = TagGroup.order('name ASC').includes(:parent_tag).preload(:tags).all
|
||||
serializer = ActiveModel::ArraySerializer.new(tag_groups, each_serializer: TagGroupSerializer, root: 'tag_groups')
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
|
|
|
@ -2,7 +2,7 @@ class TagGroupSerializer < ApplicationSerializer
|
|||
attributes :id, :name, :tag_names, :parent_tag_name, :one_per_topic
|
||||
|
||||
def tag_names
|
||||
object.tags.pluck(:name).sort
|
||||
object.tags.map(&:name).sort
|
||||
end
|
||||
|
||||
def parent_tag_name
|
||||
|
|
Loading…
Reference in New Issue