This commit is contained in:
呱呱呱 2023-11-08 10:54:09 +08:00
parent 452890f825
commit 43be8d1724
5 changed files with 19 additions and 5 deletions

View File

@ -21,7 +21,7 @@ class Api::Pm::IssuesController < Api::Pm::BaseController
def link_index
pm_issues_type= params[:pm_issues_type] || 1
object_issues = Issue.includes(:pm_links).where( pm_project_id: params[:pm_project_id], root_id: nil, pm_issues_type: pm_issues_type).where.not(pm_links: { linkable_id: params[:id] } )
object_issues = Issue.includes(:pm_links).where(pm_project_id: params[:pm_project_id], root_id: nil, pm_issues_type: pm_issues_type).where.not(pm_links: { linkable_id: params[:id] } )
@issues = kaminari_paginate(object_issues)
render 'api/v1/issues/index'
end

View File

@ -38,6 +38,7 @@
# pm_sprint_id :integer
# pm_issue_type :integer
# time_scale :decimal(10, 2) default("0.00")
# child_count :integer default("0")
#
# Indexes
#
@ -97,7 +98,7 @@ class Issue < ApplicationRecord
scope :issue_index_includes, ->{includes(:tracker, :priority, :version, :issue_status, :journals,:issue_tags,user: :user_extension)}
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_create :incre_project_common, :incre_user_statistic, :incre_platform_statistic, :fresh_root_issue_count
after_save :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
@ -117,6 +118,12 @@ class Issue < ApplicationRecord
CacheAsyncSetJob.perform_later('user_statistic_service', {issue_count: -1}, self.author_id)
end
def fresh_root_issue_count
return if root_id.nil? || root_id.zero?
root_issue = Issue.find_by(id: root_id)
root_count = Issue.where(root_id: root_id).count
root_issue.update(child_count: root_count)
end
def incre_platform_statistic
CacheAsyncSetJob.perform_later('platform_statistic_service', {issue_count: 1})
end

View File

@ -45,8 +45,9 @@ json.attachments issue.attachments.each do |attachment|
json.partial! "api/v1/attachments/simple_detail", locals: {attachment: attachment}
end
json.pull_fixed issue.pull_attached_issues.where(fixed: true).present?
json.parent_id issue.parent_id
json.root_id issue.root_id
json.pm_issue_type issue.pm_issue_type
json.pm_sprint_id issue.pm_sprint_id
json.pm_project_id issue.pm_project_id
json.time_scale issue.time_scale
json.time_scale issue.time_scale
json.child_count issue.child_count

View File

@ -9,11 +9,12 @@ json.status_name issue.issue_status&.name
json.priority_name issue.priority&.name
json.milestone_name issue.version&.name
json.milestone_id issue.fixed_version_id
json.parent_id issue.parent_id
json.root_id issue.root_id
json.pm_issue_type issue.pm_issue_type
json.pm_sprint_id issue.pm_sprint_id
json.pm_project_id issue.pm_project_id
json.time_scale issue.time_scale
json.child_count issue.child_count
json.author do
if issue.user.present?

View File

@ -0,0 +1,5 @@
class AddChildCountToIssues < ActiveRecord::Migration[5.2]
def change
add_column :issues, :child_count, :integer, default:0
end
end