From 94d9a2337b85b9e41c8b01bf678f617430455b07 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Sun, 15 Sep 2024 06:31:30 +0000 Subject: Add "Author / Previous assignee" group to assignee dropdown in issue form (#16045). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch by Luka Lüdicke (user:dkd-luedicke), Mizuki ISHIKAWA (user:ishikawa999), and Go MAEDA (user:maeda). git-svn-id: https://svn.redmine.org/redmine/trunk@23059 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/issue.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'app/models') diff --git a/app/models/issue.rb b/app/models/issue.rb index 3debf90ec..48a935558 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -925,6 +925,18 @@ class Issue < ApplicationRecord result end + # Returns the assignee immediately prior to the current one from the issue history + def prior_assigned_to + prior_assigned_to_id = + journals.joins(:details) + .where(details: {prop_key: 'assigned_to_id'}) + .where.not(details: {old_value: nil}) + .order(id: :desc) + .pick(:old_value) + + prior_assigned_to_id && Principal.find_by(id: prior_assigned_to_id) + end + # Returns the initial status of the issue # Returns nil for a new issue def status_was -- cgit v1.2.3