mirror of
https://github.com/discourse/discourse.git
synced 2025-06-24 02:31:31 +08:00
FIX: N+1 in admin themes page (#32763)
`strict_loading` was added to prevent it happening in the future. Few adjustments had to be made: - include color_scheme and color_scheme_colors, also for parent and child themes; - internal translations were using preload_fields, but it was too deep to correctly use preloaded tables. I had to pass `preloaded_locale_fields` manually; - include theme in color_scheme. Before: <img width="663" alt="Screenshot 2025-05-15 at 3 43 47 pm" src="https://github.com/user-attachments/assets/b55ce11e-80cb-43eb-8e31-940b0e9859f3" /> After: <img width="665" alt="Screenshot 2025-05-16 at 11 29 00 am" src="https://github.com/user-attachments/assets/f00bac19-f64b-4048-b220-4d0a9d90a929" />
This commit is contained in:

committed by
GitHub

parent
b823fb297f
commit
76e1373b04
@ -169,8 +169,10 @@ class Admin::ThemesController < Admin::AdminController
|
||||
end
|
||||
|
||||
def index
|
||||
@themes = Theme.include_relations.order(:name)
|
||||
@color_schemes = ColorScheme.all.includes(:theme, color_scheme_colors: :color_scheme).to_a
|
||||
@themes = Theme.strict_loading.include_relations.order(:name)
|
||||
|
||||
@color_schemes =
|
||||
ColorScheme.strict_loading.all.includes(:theme, color_scheme_colors: :color_scheme).to_a
|
||||
|
||||
payload = {
|
||||
themes: serialize_data(@themes, ThemeSerializer),
|
||||
|
Reference in New Issue
Block a user