PERF: Remove N+1 query in `SiteSerializer#user_color_schemes`.

This commit is contained in:
Alan Guo Xiang Tan 2021-06-02 13:26:09 +08:00
parent 2e4182b4b3
commit eea9fead63
1 changed files with 1 additions and 1 deletions

View File

@ -50,7 +50,7 @@ class SiteSerializer < ApplicationSerializer
def user_color_schemes
cache_fragment("user_color_schemes") do
schemes = ColorScheme.where('user_selectable').order(:name)
schemes = ColorScheme.includes(:color_scheme_colors).where('user_selectable').order(:name)
ActiveModel::ArraySerializer.new(schemes, each_serializer: ColorSchemeSelectableSerializer).as_json
end
end