OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add classes for new causes introduced in progress calculation changes
Klaus Zanders50c87a61c814
diff --git a/app/models/journal/caused_by_progress_mode_changed_to_status_based.rb b/app/models/journal/caused_by_progress_mode_changed_to_status_based.rbnew file mode 100644index 00000000000..84a78eb674d--- /dev/null+++ b/app/models/journal/caused_by_progress_mode_changed_to_status_based.rb@@ -0,0 +1,33 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2023 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#+++#+class Journal::CausedByProgressModeChangedToStatusBased < CauseOfChange::Base+ def initialize+ super("progress_mode_changed_to_status_based")+ end+enddiff --git a/app/models/journal/caused_by_status_p_complete_changed.rb b/app/models/journal/caused_by_status_p_complete_changed.rbnew file mode 100644index 00000000000..da648aca57d--- /dev/null+++ b/app/models/journal/caused_by_status_p_complete_changed.rb@@ -0,0 +1,39 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2023 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#+++#+class Journal::CausedByStatusPCompleteChanged < CauseOfChange::Base+ def initialize(status_name:, status_id:, status_p_complete_change:)+ additional = {+ "status_name" => status_name,+ "status_id" => status_id,+ "status_p_complete_change" => status_p_complete_change+ }++ super("status_p_complete_changed", additional)+ end+enddiff --git a/app/workers/work_packages/apply_statuses_p_complete_job.rb b/app/workers/work_packages/apply_statuses_p_complete_job.rbindex 530a3bb3f2f..41867469855 100644--- a/app/workers/work_packages/apply_statuses_p_complete_job.rb+++ b/app/workers/work_packages/apply_statuses_p_complete_job.rb@@ -75,13 +75,17 @@ class WorkPackages::ApplyStatusesPCompleteJob < ApplicationJobcase cause_typewhen "progress_mode_changed_to_status_based"- { type: cause_type }+ Journal::CausedByProgressModeChangedToStatusBased.newwhen "status_p_complete_changed"raise ArgumentError, "status_name must be provided" if status_name.blank?raise ArgumentError, "status_id must be provided" if status_id.nil?raise ArgumentError, "change must be provided" if change.nil?- { type: cause_type, status_name:, status_id:, status_p_complete_change: change }+ Journal::CausedByStatusPCompleteChanged.new(+ status_name:,+ status_id:,+ status_p_complete_change: change+ )elseraise "Unable to handle cause type #{cause_type.inspect}"enddiff --git a/app/workers/work_packages/update_progress_job.rb b/app/workers/work_packages/update_progress_job.rbindex 426de0ea1c2..9aa0e1142ba 100644--- a/app/workers/work_packages/update_progress_job.rb+++ b/app/workers/work_packages/update_progress_job.rb@@ -246,7 +246,7 @@ class WorkPackages::UpdateProgressJob < ApplicationJobWorkPackage.where(id: updated_work_package_ids).find_each do |work_package|Journals::CreateService.new(work_package, system_user)- .call(cause: { type: "system_update", feature: "progress_calculation_changed" })+ .call(cause: Journal::CausedBySystemUpdate.new(feature: "progress_calculation_changed"))endend