From 9b9374c99bb1ba1cc0ac8dce83a975e7ccb4fbb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=B1=E5=91=B1=E5=91=B1?= Date: Wed, 31 Jan 2024 08:43:10 +0800 Subject: [PATCH 1/2] add due_date to pm issue batch params --- app/controllers/api/pm/issues_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/pm/issues_controller.rb b/app/controllers/api/pm/issues_controller.rb index 6cd37ce18..06ada1e9a 100644 --- a/app/controllers/api/pm/issues_controller.rb +++ b/app/controllers/api/pm/issues_controller.rb @@ -182,7 +182,7 @@ class Api::Pm::IssuesController < Api::Pm::BaseController def batch_issue_params params.permit( - :status_id, :priority_id, :milestone_id, :pm_sprint_id, :pm_issue_type, :root_id, :target_pm_project_id, :project_id, + :status_id, :priority_id, :milestone_id, :pm_sprint_id, :due_date, :pm_issue_type, :root_id, :target_pm_project_id, :project_id, :issue_tag_ids => [], :assigner_ids => [] ) end From 65d23879313dc9311c9826d34258d1b204cd33e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=B1=E5=91=B1=E5=91=B1?= Date: Wed, 31 Jan 2024 09:08:38 +0800 Subject: [PATCH 2/2] update --- app/models/issue.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/models/issue.rb b/app/models/issue.rb index b40efefa1..2c1a22d92 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -104,9 +104,16 @@ class Issue < ApplicationRecord scope :closed, ->{where(status_id: 5)} scope :opened, ->{where.not(status_id: 5)} after_create :incre_project_common, :incre_user_statistic, :incre_platform_statistic + before_save :check_pm_and_update_due_date after_save :change_versions_count, :send_update_message_to_notice_system, :associate_attachment_container, :generate_uuid after_destroy :update_closed_issues_count_in_project!, :decre_project_common, :decre_user_statistic, :decre_platform_statistic + def check_pm_and_update_due_date + if pm_project_id.present? && status_id.changed? && status_id == 5 + self.due_date = self.due_date || Time.current + end + end + def incre_project_common CacheAsyncSetJob.perform_later('project_common_service', {issues: 1}, self.project_id) end