fixed issues_count统计增加已分配类型,单独汇总

This commit is contained in:
xxq250 2024-01-31 15:37:09 +08:00
parent c88c64b33b
commit 94b7129257
1 changed files with 12 additions and 2 deletions

View File

@ -14,9 +14,19 @@ class Api::Pm::ProjectsController < Api::Pm::BaseController
return tip_exception '参数错误' unless params[:pm_project_id].present?
@issues = Issue.where(pm_project_id: params[:pm_project_id])
@participant_category_count = {}
if params[:participant_category].present?
if params[:participant_category].to_s == "authoredme" or params[:participant_category].to_s == "assignedme"
issues_category = @issues.joins(:issue_participants).where(issue_participants: {participant_type: %w[authored assigned atme], participant_id: current_user&.id})
@participant_category_count = issues_category.group(:pm_project_id, "issue_participants.participant_type").count
end
case params[:participant_category].to_s
when 'aboutme' # 关于我的
@issues = @issues.joins(:issue_participants).where(issue_participants: {participant_type: %w[authored assigned atme], participant_id: current_user&.id})
@participant_category_count = @issues.group(:pm_project_id, "issue_participants.participant_type").count
when 'authoredme' # 我创建的
@issues = @issues.joins(:issue_participants).where(issue_participants: {participant_type: 'authored', participant_id: current_user&.id})
when 'assignedme' # 我负责的
@issues = @issues.joins(:issue_participants).where(issue_participants: {participant_type: 'assigned', participant_id: current_user&.id})
when 'atme' # @我的
@issues = @issues.joins(:issue_participants).where(issue_participants: {participant_type: 'atme', participant_id: current_user&.id})
end
data = {}
@issues_count = @issues.group(:pm_project_id).count