From 47dc5ddcec60c8db58e5591e3072ff01d127ce80 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sun, 4 Oct 2026 19:33:59 +0100 Subject: [PATCH] Fix N+1 queries with moderation zones --- app/controllers/moderation_zones_controller.rb | 4 ++-- test/prosopite_todo.yml | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/controllers/moderation_zones_controller.rb b/app/controllers/moderation_zones_controller.rb index 6233553ab..155a4c6d0 100644 --- a/app/controllers/moderation_zones_controller.rb +++ b/app/controllers/moderation_zones_controller.rb @@ -13,7 +13,7 @@ class ModerationZonesController < ApplicationController before_action :set_moderation_zone, :only => [:edit, :update] def index - @moderation_zones = ModerationZone.all + @moderation_zones = ModerationZone.preload(:creator, :revoker).all end def new @@ -55,7 +55,7 @@ class ModerationZonesController < ApplicationController private def set_moderation_zone - @moderation_zone = ModerationZone.find(params.expect(:id)) + @moderation_zone = ModerationZone.preload(:creator, :revoker).find(params.expect(:id)) end def moderation_zone_params diff --git a/test/prosopite_todo.yml b/test/prosopite_todo.yml index 93f09bdff..5813c84c6 100644 --- a/test/prosopite_todo.yml +++ b/test/prosopite_todo.yml @@ -5,7 +5,6 @@ # `includes` or `preload`. Remove files from the list once they are fixed. - app/controllers/issues_controller.rb -- app/controllers/moderation_zones_controller.rb - app/controllers/user_blocks_controller.rb - app/helpers/user_helper.rb - app/models/node.rb @@ -32,7 +31,6 @@ - app/views/diary_entries/_diary_entry.html.erb - app/views/diary_entries/_profile_diaries.html.erb - app/views/issues/_page.html.erb -- app/views/moderation_zones/_row.html.erb - app/views/notes/index.html.erb - app/views/notifications/_notification.html.erb - app/views/oauth2_authorized_applications/_application.html.erb -- 2.47.3