新增:项目缓存加入关闭issue数量

This commit is contained in:
2024-01-15 16:41:54 +08:00
parent e2374676c3
commit 7d813c0ebe
3 changed files with 32 additions and 3 deletions

View File

@@ -99,9 +99,20 @@ 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
after_save :change_versions_count, :send_update_message_to_notice_system, :associate_attachment_container
after_save :incre_or_decre_closed_issues_count, :change_versions_count, :send_update_message_to_notice_system, :associate_attachment_container
after_destroy :update_closed_issues_count_in_project!, :decre_project_common, :decre_user_statistic, :decre_platform_statistic
def incre_or_decre_closed_issues_count
if previous_changes[:status_id].present?
if previous_changes[:status_id][1] == 5
CacheAsyncSetJob.perform_later("project_common_service", {closed_issues: 1}, self.project_id)
end
if previous_changes[:status_id][0] == 5
CacheAsyncSetJob.perform_later("project_common_service", {closed_issues: -1}, self.project_id)
end
end
end
def incre_project_common
CacheAsyncSetJob.perform_later("project_common_service", {issues: 1}, self.project_id)
end