PERF: Eradicate N+1 queries from the theme admin page

This commit is contained in:
David Taylor
2018-12-20 17:13:05 +00:00
committed by Sam
parent 2909e7fbdf
commit 7feabd9e49
6 changed files with 34 additions and 7 deletions

View File

@ -96,8 +96,15 @@ class Admin::ThemesController < Admin::AdminController
end
def index
@themes = Theme.order(:name).includes(:theme_fields, :remote_theme)
@color_schemes = ColorScheme.all.to_a
@themes = Theme.order(:name).includes(:child_themes,
:remote_theme,
:theme_settings,
:settings_field,
:user,
:color_scheme,
theme_fields: :upload
)
@color_schemes = ColorScheme.all.includes(:theme, color_scheme_colors: :color_scheme).to_a
light = ColorScheme.new(name: I18n.t("color_schemes.light"))
@color_schemes.unshift(light)