fix issue count error

This commit is contained in:
呱呱呱 2023-11-16 14:15:37 +08:00
parent f9f0485e50
commit 23a1be8ce3
3 changed files with 5 additions and 9 deletions

View File

@ -11,12 +11,12 @@ class Api::Pm::ProjectsController < Api::Pm::BaseController
def issues_count def issues_count
return tip_exception '参数错误' unless params[:pm_project_id].present? return tip_exception '参数错误' unless params[:pm_project_id].present?
@issues = Issue.where(pm_project_id_params) @issues = Issue.where(id: params[:pm_project_id])
data = {} data = {}
@issues_count = @issues.group(:pm_project_id).count @issues_count = @issues.group(:pm_project_id).count
# requirement 1 task 2 bug 3 # requirement 1 task 2 bug 3
@issues_type_count = @issues.group(:pm_project_id, :pm_issue_type).count @issues_type_count = @issues.group(:pm_project_id, :pm_issue_type).count
pm_project_id_params[:pm_project_id].map(&:to_i).map do |project_id| params[:pm_project_id].map(&:to_i).map do |project_id|
data[project_id] = { data[project_id] = {
total: @issues_count[project_id] || 0, total: @issues_count[project_id] || 0,
requirement: @issues_type_count[[project_id, 1]] || 0, requirement: @issues_type_count[[project_id, 1]] || 0,
@ -37,9 +37,5 @@ class Api::Pm::ProjectsController < Api::Pm::BaseController
@project = Project.joins(:owner).find params[:project_id] @project = Project.joins(:owner).find params[:project_id]
end end
def pm_project_id_params
params.permit(
pm_project_id: []
)
end
end end

View File

@ -81,7 +81,7 @@ class Api::V1::Issues::CreateService < ApplicationService
end end
project.del_project_issue_cache_delete_count # 把缓存里存储项目删除issue的个数清除掉 project.del_project_issue_cache_delete_count # 把缓存里存储项目删除issue的个数清除掉
unless project.id.zero? unless @project.id.zero?
# 新增时向grimoirelab推送事件 # 新增时向grimoirelab推送事件
IssueWebhookJob.set(wait: 5.seconds).perform_later(@created_issue.id) IssueWebhookJob.set(wait: 5.seconds).perform_later(@created_issue.id)

View File

@ -88,7 +88,7 @@ class Api::V1::Issues::UpdateService < ApplicationService
build_after_issue_journal_details if @updated_issue.previous_changes.present? # 操作记录 build_after_issue_journal_details if @updated_issue.previous_changes.present? # 操作记录
build_previous_issue_changes build_previous_issue_changes
build_cirle_blockchain_token if blockchain_token_num.present? build_cirle_blockchain_token if blockchain_token_num.present?
unless project.id.zero? unless @project.id.zero?
# @信息发送 # @信息发送
AtmeService.call(current_user, @atme_receivers, @issue) unless receivers_login.blank? AtmeService.call(current_user, @atme_receivers, @issue) unless receivers_login.blank?
# 消息发送 # 消息发送