From 61d14a769440df37a0cf4e75093cfa231a5c48e1 Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Thu, 11 Nov 2021 18:11:23 +0100 Subject: [PATCH] DEV: Fix 3N+1 query in `/admin/customize/themes` (#14876) --- app/models/theme.rb | 1 + app/models/theme_field.rb | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/models/theme.rb b/app/models/theme.rb index 41e4ba8bddc..3f59348d9e2 100644 --- a/app/models/theme.rb +++ b/app/models/theme.rb @@ -50,6 +50,7 @@ class Theme < ActiveRecord::Base :locale_fields, :user, :color_scheme, + :theme_translation_overrides, theme_fields: :upload ) } diff --git a/app/models/theme_field.rb b/app/models/theme_field.rb index 603e1f0eaf0..fac8bf1b781 100644 --- a/app/models/theme_field.rb +++ b/app/models/theme_field.rb @@ -216,8 +216,12 @@ class ThemeField < ActiveRecord::Base # this would reduce the size of the payload, without affecting functionality data = {} fallback_data.each { |hash| data.merge!(hash) } - overrides = theme.translation_override_hash.deep_symbolize_keys - data.deep_merge!(overrides) if with_overrides + + if with_overrides + overrides = theme.translation_override_hash.deep_symbolize_keys + data.deep_merge!(overrides) + end + data end