This commit is contained in:
yystopf 2024-08-21 17:23:13 +08:00
parent 91399808c4
commit 1a374468ea
3 changed files with 60 additions and 60 deletions

View File

@ -12,7 +12,7 @@ class Api::Pm::IssueLinksController < Api::Pm::BaseController
@issue.pm_links.find_or_create_by!(be_linkable_type: 'Issue', be_linkable_id: e)
tag_issue = Issue.find_by_id(e)
next unless tag_issue.present?
journal = tag_issue.journals.create!({user_id: current_id.id})
journal = tag_issue.journals.create!({user_id: current_user.id})
journal.journal_details.create!({property: "tag_link_issue", prop_key: "1", value: @issue.id.to_s})
end
journal = @issue.journals.create!({user_id: current_user.id})

View File

@ -84,10 +84,10 @@ class Journal < ApplicationRecord
def pm_operate_category
detail = self.journal_details.take
if (detail.property == "requirement" || detail.property == "task" || detail.property == "bug") && detail.prop_key.to_s == "1"
if %w(requirement task bug).include?(detail.property) && detail.prop_key.to_s == "1"
return "issue"
else
return detail.property == "attr" ? detail.prop_key : detail.property
return %w(requirement task bug attr).include?(detail.property) ? detail.prop_key : detail.property
end
end
@ -101,10 +101,10 @@ class Journal < ApplicationRecord
old_value = IssueStatus.find_by_id(detail.old_value)&.name
new_value = IssueStatus.find_by_id(detail.value)&.name
content += "将状态"
if old_value.nil? || old_value.blank?
if detail.old_value.nil? || detail.old_value.blank?
content += "设置为<b>#{new_value}</b>"
else
new_value = "未设置" if new_value.blank?
new_value = "未设置" if detail.value.blank?
content += "由<b>#{old_value}</b>更改为<b>#{new_value}</b>"
end
content.gsub!('新增', '待评审')
@ -116,10 +116,10 @@ class Journal < ApplicationRecord
when 'root_id'
old_value = "<b>#{Issue.find_by_id(detail.old_value)&.subject}</b>"
new_value = "<b>#{Issue.find_by_id(detail.value)&.subject}</b>"
if old_value.nil? || old_value.blank?
if detail.old_value.nil? || detail.old_value.blank?
content += "关联了父需求<b><#{new_value}></b>"
else
if new_value.nil? || new_value.blank?
if detail.value.nil? || detail.value.blank?
content += "取消了关联的父需求<b><#{old_value}></b>"
else
content += "将关联的父需求由<b><#{old_value}></b>更改为<b><#{new_value}></b>"
@ -129,10 +129,10 @@ class Journal < ApplicationRecord
when 'leaf_issue'
old_value = Issue.where(id: detail.old_value.to_s.split(",")).map{|i| "<b><#{i.subject}></b>"}.join("")
new_value = Issue.where(id: detail.value.to_s.split(",")).map{|i| "<b><#{i.subject}></b>"}.join("")
if old_value.nil? || old_value.blank?
if detail.old_value.nil? || detail.old_value.blank?
content += "新建了子需求#{new_value}"
else
if new_value.nil? || new_value.blank?
if detail.value.nil? || detail.value.blank?
content += "删除了关联的子需求#{old_value}"
else
content += "新建了子需求#{new_value}"
@ -142,10 +142,10 @@ class Journal < ApplicationRecord
when 'tag_leaf_issue'
old_value = Issue.where(id: detail.old_value.to_s.split(",")).map{|i| "<b><#{i.subject}></b>"}.join("")
new_value = Issue.where(id: detail.value.to_s.split(",")).map{|i| "<b><#{i.subject}></b>"}.join("")
if old_value.nil? || old_value.blank?
if detail.old_value.nil? || detail.old_value.blank?
content += "关联了子需求#{new_value}"
else
if new_value.nil? || new_value.blank?
if detail.value.nil? || detail.value.blank?
content += "取消了关联的子需求#{old_value}"
else
content += "关联了子需求#{new_value}"
@ -161,10 +161,10 @@ class Journal < ApplicationRecord
old_value = IssueStatus.find_by_id(detail.old_value)&.name
new_value = IssueStatus.find_by_id(detail.value)&.name
content += "将状态"
if old_value.nil? || old_value.blank?
if detail.old_value.nil? || detail.old_value.blank?
content += "设置为<b>#{new_value}</b>"
else
new_value = "未设置" if new_value.blank?
new_value = "未设置" if detail.value.blank?
content += "由<b>#{old_value}</b>更改为<b>#{new_value}</b>"
end
content.gsub!('新增', '待处理')
@ -176,10 +176,10 @@ class Journal < ApplicationRecord
when 'root_id'
old_value = "<b>#{Issue.find_by_id(detail.old_value)&.subject}</b>"
new_value = "<b>#{Issue.find_by_id(detail.value)&.subject}</b>"
if old_value.nil? || old_value.blank?
if detail.old_value.nil? || detail.old_value.blank?
content += "关联了父任务<b><#{new_value}></b>"
else
if new_value.nil? || new_value.blank?
if detail.value.nil? || detail.value.blank?
content += "取消了关联的父任务<b><#{old_value}></b>"
else
content += "将关联的父任务由<b><#{old_value}></b>更改为<b><#{new_value}></b>"
@ -189,10 +189,10 @@ class Journal < ApplicationRecord
when 'leaf_issue'
old_value = Issue.where(id: detail.old_value.to_s.split(",")).map{|i| "<b><#{i.subject}></b>"}.join("")
new_value = Issue.where(id: detail.value.to_s.split(",")).map{|i| "<b><#{i.subject}></b>"}.join("")
if old_value.nil? || old_value.blank?
if detail.old_value.nil? || detail.old_value.blank?
content += "新建了子任务#{new_value}"
else
if new_value.nil? || new_value.blank?
if detail.value.nil? || detail.value.blank?
content += "删除了关联的子任务#{old_value}"
else
content += "新建了子任务#{new_value}"
@ -202,10 +202,10 @@ class Journal < ApplicationRecord
when 'tag_leaf_issue'
old_value = Issue.where(id: detail.old_value.to_s.split(",")).map{|i| "<b><#{i.subject}></b>"}.join("")
new_value = Issue.where(id: detail.value.to_s.split(",")).map{|i| "<b><#{i.subject}></b>"}.join("")
if old_value.nil? || old_value.blank?
if detail.old_value.nil? || detail.old_value.blank?
content += "关联了子任务#{new_value}"
else
if new_value.nil? || new_value.blank?
if detail.value.nil? || detail.value.blank?
content += "取消了关联的子任务#{old_value}"
else
content += "关联了子任务#{new_value}"
@ -221,10 +221,10 @@ class Journal < ApplicationRecord
old_value = IssueStatus.find_by_id(detail.old_value)&.name
new_value = IssueStatus.find_by_id(detail.value)&.name
content += "将状态"
if old_value.nil? || old_value.blank?
if detail.old_value.nil? || detail.old_value.blank?
content += "设置为<b>#{new_value}</b>"
else
new_value = "未设置" if new_value.blank?
new_value = "未设置" if detail.value.blank?
content += "由<b>#{old_value}</b>更改为<b>#{new_value}</b>"
end
content.gsub!('新增', '待修复')
@ -236,10 +236,10 @@ class Journal < ApplicationRecord
when 'root_id'
old_value = "<b>#{Issue.find_by_id(detail.old_value)&.subject}</b>"
new_value = "<b>#{Issue.find_by_id(detail.value)&.subject}</b>"
if old_value.nil? || old_value.blank?
if detail.old_value.nil? || detail.old_value.blank?
content += "关联了父缺陷<b><#{new_value}></b>"
else
if new_value.nil? || new_value.blank?
if detail.value.nil? || detail.value.blank?
content += "取消了关联的父缺陷<b><#{old_value}></b>"
else
content += "将关联的父缺陷由<b><#{old_value}></b>更改为<b><#{new_value}></b>"
@ -249,10 +249,10 @@ class Journal < ApplicationRecord
when 'leaf_issue'
old_value = Issue.where(id: detail.old_value.to_s.split(",")).map{|i| "<b><#{i.subject}></b>"}.join("")
new_value = Issue.where(id: detail.value.to_s.split(",")).map{|i| "<b><#{i.subject}></b>"}.join("")
if old_value.nil? || old_value.blank?
if detail.old_value.nil? || detail.old_value.blank?
content += "新建了子缺陷#{new_value}"
else
if new_value.nil? || new_value.blank?
if detail.value.nil? || detail.value.blank?
content += "删除了关联的子缺陷#{old_value}"
else
content += "新建了子缺陷#{new_value}"
@ -262,10 +262,10 @@ class Journal < ApplicationRecord
when 'tag_leaf_issue'
old_value = Issue.where(id: detail.old_value.to_s.split(",")).map{|i| "<b><#{i.subject}></b>"}.join("")
new_value = Issue.where(id: detail.value.to_s.split(",")).map{|i| "<b><#{i.subject}></b>"}.join("")
if old_value.nil? || old_value.blank?
if detail.old_value.nil? || detail.old_value.blank?
content += "关联了子缺陷#{new_value}"
else
if new_value.nil? || new_value.blank?
if detail.value.nil? || detail.value.blank?
content += "取消了关联的子缺陷#{old_value}"
else
content += "关联了子缺陷#{new_value}"
@ -284,20 +284,20 @@ class Journal < ApplicationRecord
when 'priority_id'
old_value = IssuePriority.find_by_id(detail.old_value)&.name
new_value = IssuePriority.find_by_id(detail.value)&.name
if old_value.nil? || old_value.blank?
if detail.old_value.nil? || detail.old_value.blank?
content += "将优先级设置为<b>#{new_value}</b>"
else
new_value = "未设置" if new_value.blank?
new_value = "未设置" if detail.value.blank?
content += "将优先级由<b>#{old_value}</b>更改为<b>#{new_value}</b>"
end
return content
when 'status_id'
old_value = IssueStatus.find_by_id(detail.old_value)&.name
new_value = IssueStatus.find_by_id(detail.value)&.name
if old_value.nil? || old_value.blank?
if detail.old_value.nil? || detail.old_value.blank?
content += "将状态设置为<b>#{new_value}</b>"
else
new_value = "未设置" if new_value.blank?
new_value = "未设置" if detail.value.blank?
content += "将状态由<b>#{old_value}</b>更改为<b>#{new_value}</b>"
end
case self.issue.pm_issue_type.to_i
@ -324,10 +324,10 @@ class Journal < ApplicationRecord
when 'pm_issue_type'
old_value = detail.old_value
new_value = detail.value
if old_value.nil? || old_value.blank?
if detail.old_value.nil? || detail.old_value.blank?
content += "将工作项类型设置为<b>#{new_value}</b>"
else
new_value = "未设置" if new_value.blank?
new_value = "未设置" if detail.value.blank?
content += "将工作项类型由<b>#{old_value}</b>更改为<b>#{new_value}</b>"
end
content.gsub!('1', '需求')
@ -337,10 +337,10 @@ class Journal < ApplicationRecord
when 'pm_sprint_id'
old_value = detail.old_value
new_value = detail.value
if old_value.nil? || old_value.blank?
if detail.old_value.nil? || detail.old_value.blank?
content += "添加了关联迭代"
else
if new_value.nil? || new_value.blank?
if detail.value.nil? || detail.value.blank?
content += "将关联迭代更改为<b>未设置</b>"
else
content += "变更了关联迭代"
@ -350,10 +350,10 @@ class Journal < ApplicationRecord
when 'project_id'
old_value = Project.find_by_id(detail.old_value)&.name
new_value = Project.find_by_id(detail.value)&.name
if old_value.nil? || old_value.blank?
if detail.old_value.nil? || detail.old_value.blank?
content += "添加关联代码库<b>#{new_value}</b>"
else
if new_value.nil? || new_value.blank?
if detail.value.nil? || detail.value.blank?
content += "将关联代码库更改为<b>未设置</b>"
else
content += "将关联代码库由<b>#{old_value}</b>改为<b>#{new_value}</b>"
@ -363,10 +363,10 @@ class Journal < ApplicationRecord
when 'branch_name'
old_value = detail.old_value
new_value = detail.value
if old_value.nil? || old_value.blank?
if detail.old_value.nil? || detail.old_value.blank?
content += "添加关联分支<b>#{new_value}</b>"
else
if new_value.nil? || new_value.blank?
if detail.value.nil? || detail.value.blank?
content += "将关联分支更改为<b>未设置</b>"
else
content += "将关联分支由<b>#{old_value}</b>改为<b>#{new_value}</b>"
@ -377,10 +377,10 @@ class Journal < ApplicationRecord
when 'start_date'
old_value = detail.old_value
new_value = detail.value
if old_value.nil? || old_value.blank?
if detail.old_value.nil? || detail.old_value.blank?
content += "添加开始时间<b>#{new_value}</b>"
else
if new_value.nil? || new_value.blank?
if detail.value.nil? || detail.value.blank?
content += "将开始时间更改为<b>未设置</b>"
else
content += "将开始时间由<b>#{old_value}</b>改为<b>#{new_value}</b>"
@ -391,10 +391,10 @@ class Journal < ApplicationRecord
when 'due_date'
old_value = detail.old_value
new_value = detail.value
if old_value.nil? || old_value.blank?
if detail.old_value.nil? || detail.old_value.blank?
content += "添加结束时间<b>#{new_value}</b>"
else
if new_value.nil? || new_value.blank?
if detail.value.nil? || detail.value.blank?
content += "将结束时间更改为<b>未设置</b>"
else
content += "将结束时间由<b>#{old_value}</b>改为<b>#{new_value}</b>"
@ -404,10 +404,10 @@ class Journal < ApplicationRecord
when 'time_scale'
old_value = detail.old_value
new_value = detail.value
if old_value.nil? || old_value.blank?
if detail.old_value.nil? || detail.old_value.blank?
content += "添加预估工时<b>#{new_value}</b>"
else
if new_value.nil? || new_value.blank?
if detail.value.nil? || detail.value.blank?
content += "将预估工时更改为<b>未设置</b>"
else
content += "将预估工时由<b>#{old_value}</b>改为<b>#{new_value}</b>"
@ -418,10 +418,10 @@ class Journal < ApplicationRecord
when 'attachment'
old_value = detail.old_value.to_s
new_value = detail.value.to_s
if old_value.nil? || old_value.blank?
if detail.old_value.nil? || detail.old_value.blank?
content += "上传了附件"
else
if new_value.nil? || new_value.blank?
if detail.value.nil? || detail.value.blank?
content += "删除了附件"
else
content += "上传了附件"
@ -431,10 +431,10 @@ class Journal < ApplicationRecord
when 'assigner'
old_value = User.where(id: detail.old_value.split(",")).map{|u| "<b>#{u.real_name}</b>"}.join("")
new_value = User.where(id: detail.value.split(",")).map{|u| "<b>#{u.real_name}</b>"}.join("")
if old_value.nil? || old_value.blank?
if detail.old_value.nil? || detail.old_value.blank?
content += "添加负责人#{new_value}"
else
if new_value.nil? || new_value.blank?
if detail.value.nil? || detail.value.blank?
content += "将负责人更改为<b>未设置</b>"
else
content += "将负责人由#{old_value}更改为#{new_value}"
@ -444,10 +444,10 @@ class Journal < ApplicationRecord
when 'issue_tag'
old_value = IssueTag.where(id: detail.old_value.split(",")).map{|t| "<b>#{t.name}</b>"}.join("")
new_value = IssueTag.where(id: detail.value.split(",")).map{|t| "<b>#{t.name}</b>"}.join("")
if old_value.nil? || old_value.blank?
if detail.old_value.nil? || detail.old_value.blank?
content += "添加标记#{new_value}"
else
if new_value.nil? || new_value.blank?
if detail.value.nil? || detail.value.blank?
content += "将标记更改为<b>未设置</b>"
else
content += "将标记由#{old_value}更改为#{new_value}"
@ -457,10 +457,10 @@ class Journal < ApplicationRecord
when 'link_issue'
old_value = Issue.where(id: detail.old_value.to_s.split(",")).map{|i| "<b>[#{i.pm_issue_type}]-<#{i.subject}></b>"}.join("")
new_value = Issue.where(id: detail.value.to_s.split(",")).map{|i| "<b>[#{i.pm_issue_type}]-<#{i.subject}></b>"}.join("")
if old_value.nil? || old_value.blank?
if detail.old_value.nil? || detail.old_value.blank?
content += "新建了关联的工作项#{new_value}"
else
if new_value.nil? || new_value.blank?
if detail.value.nil? || detail.value.blank?
content += "删除了关联的工作项#{old_value}"
else
content += "新建了关联的工作项#{new_value}"
@ -473,10 +473,10 @@ class Journal < ApplicationRecord
when 'tag_link_issue'
old_value = Issue.where(id: detail.old_value.to_s.split(",")).map{|i| "<b>[#{i.pm_issue_type}]-<#{i.subject}></b>"}.join("")
new_value = Issue.where(id: detail.value.to_s.split(",")).map{|i| "<b>[#{i.pm_issue_type}]-<#{i.subject}></b>"}.join("")
if old_value.nil? || old_value.blank?
if detail.old_value.nil? || detail.old_value.blank?
content += "关联了工作项#{new_value}"
else
if new_value.nil? || new_value.blank?
if detail.value.nil? || detail.value.blank?
content += "取消了关联的工作项#{old_value}"
else
content += "关联了工作项#{new_value}"

View File

@ -262,13 +262,13 @@ class Api::Pm::Issues::UpdateService < ApplicationService
before_parent_issue = Issue.find_by_id(@updated_issue.previous_changes["root_id"][0])
if before_parent_issue.present?
journal = before_parent_issue.journals.create!({user_id: current_user.id})
journal.journal_details.create!({property: @updated_issue.pm_issue_type_string, prop_key: "tag_leaf_issue", old_value: @updated_issue.previous_changes["root_id"][0]})
journal.journal_details.create!({property: @updated_issue.pm_issue_type_string, prop_key: "tag_leaf_issue", old_value: @updated_issue.id.to_s})
end
after_parent_issue = Issue.find_by_id(@updated_issue.previous_changes["root_id"][1])
if after_parent_issue.present?
journal = after_parent_issue.journals.create!({user_id: current_user.id})
journal.journal_details.create!({property: @updated_issue.pm_issue_type_string, prop_key: "tag_leaf_issue", value: @updated_issue.previous_changes["root_id"][1]})
journal.journal_details.create!({property: @updated_issue.pm_issue_type_string, prop_key: "tag_leaf_issue", value: @updated_issue.id.to_s})
end
end
rescue
@ -282,7 +282,7 @@ class Api::Pm::Issues::UpdateService < ApplicationService
new_assigner_ids = @assigner_ids
new_assigner_ids = [] if @assigner_ids.nil?
now_assigner_ids = @updated_issue.assigners.pluck(:id)
if !(now_assigner_ids & assigner_ids).empty? || !(now_assigner_ids.empty? && new_assigner_ids.empty?)
if !(now_assigner_ids.sort == new_assigner_ids.sort)
journal = @updated_issue.journals.create!({user_id: current_user.id})
journal.journal_details.create!({property: "assigner", prop_key: "#{new_assigner_ids.size}", old_value: now_assigner_ids.join(","), value: new_assigner_ids.join(",")})
end
@ -298,7 +298,7 @@ class Api::Pm::Issues::UpdateService < ApplicationService
new_issue_tag_ids = @issue_tag_ids
new_issue_tag_ids = [] if @issue_tag_ids.nil?
now_issue_tag_ids = @updated_issue.issue_tags.pluck(:id)
if !(now_issue_tag_ids & new_issue_tag_ids).empty? || !(now_issue_tag_ids.empty? && new_issue_tag_ids.empty?)
if !(now_issue_tag_ids.sort == new_issue_tag_ids.sort)
journal = @updated_issue.journals.create!({user_id: current_user.id})
journal.journal_details.create!({property: "issue_tag", prop_key: "#{new_issue_tag_ids.size}", old_value: now_issue_tag_ids.join(","), value: new_issue_tag_ids.join(",")})
end
@ -314,7 +314,7 @@ class Api::Pm::Issues::UpdateService < ApplicationService
new_attachment_ids = @attachment_ids
new_attachment_ids = [] if @attachment_ids.nil?
now_attachment_ids = @updated_issue.attachments.pluck(:id)
if !(now_attachment_ids & new_attachment_ids).empty? || !(now_attachment_ids.empty? && new_attachment_ids.empty?)
if !(now_attachment_ids.sort == new_attachment_ids.sort)
journal = @updated_issue.journals.create!({user_id: current_user.id})
journal.journal_details.create!({property: "attachment", prop_key: "#{new_attachment_ids.size}", old_value: now_attachment_ids.join(","), value: new_attachment_ids.join(",")})
end