|
|
|
@@ -94,7 +94,7 @@ class Issue < ApplicationRecord |
|
|
|
has_many :attach_pull_requests, through: :pull_attached_issues, source: :pull_request |
|
|
|
# PM 关联工作项目 |
|
|
|
has_many :pm_links, as: :linkable, dependent: :destroy |
|
|
|
has_many :be_pm_links,as: :be_linkable, dependent: :destroy |
|
|
|
|
|
|
|
belongs_to :changer, class_name: 'User', foreign_key: :changer_id, optional: true |
|
|
|
|
|
|
|
scope :issue_includes, ->{includes(:user)} |
|
|
|
@@ -106,8 +106,13 @@ class Issue < ApplicationRecord |
|
|
|
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 :incre_or_decre_closed_issues_count, :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 |
|
|
|
after_destroy :update_closed_issues_count_in_project!, :decre_project_common, :decre_user_statistic, :decre_platform_statistic, :destroy_be_pm_links |
|
|
|
|
|
|
|
def destroy_be_pm_links |
|
|
|
PmLink.where(be_linkable_type:"Issue",be_linkable_id:self.id).map(&:destroy) |
|
|
|
end |
|
|
|
|
|
|
|
def check_pm_and_update_due_date |
|
|
|
if pm_project_id.present? && pm_issue_type.present? && status_id_changed? |
|
|
|
|