From a74606c87c7e762ae923253f180939bd627612a2 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Fri, 15 Jul 2016 17:16:13 -0400 Subject: [PATCH] PERF: tag groups index query --- app/controllers/tag_groups_controller.rb | 2 +- app/serializers/tag_group_serializer.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/tag_groups_controller.rb b/app/controllers/tag_groups_controller.rb index 050aaa423ca..783839fd4d6 100644 --- a/app/controllers/tag_groups_controller.rb +++ b/app/controllers/tag_groups_controller.rb @@ -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 diff --git a/app/serializers/tag_group_serializer.rb b/app/serializers/tag_group_serializer.rb index 560eef34bcd..62858aff200 100644 --- a/app/serializers/tag_group_serializer.rb +++ b/app/serializers/tag_group_serializer.rb @@ -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