From 947fe1fff24ebd0288c75719394466e69bbea86a Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Wed, 24 Dec 2025 06:27:52 +0000 Subject: [PATCH] Optimize Issue#recalculate_attributes_for by merging date queries (#43619). Patch by Go MAEDA (user:maeda). git-svn-id: https://svn.redmine.org/redmine/trunk@24229 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/issue.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/models/issue.rb b/app/models/issue.rb index ee317b006..b9f6b8fea 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -1870,8 +1870,7 @@ class Issue < ApplicationRecord if p.dates_derived? # start/due dates = lowest/highest dates of children - p.start_date = p.children.minimum(:start_date) - p.due_date = p.children.maximum(:due_date) + p.start_date, p.due_date = p.children.pick('MIN(start_date)', 'MAX(due_date)') if p.start_date && p.due_date && p.due_date < p.start_date p.start_date, p.due_date = p.due_date, p.start_date end