From 94b7129257b9204ee7c582f93edf5a962d94d927 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 31 Jan 2024 15:37:09 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20issues=5Fcount=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=B7=B2=E5=88=86=E9=85=8D=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?,=E5=8D=95=E7=8B=AC=E6=B1=87=E6=80=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/pm/projects_controller.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/pm/projects_controller.rb b/app/controllers/api/pm/projects_controller.rb index 7fce94d94..536995a72 100644 --- a/app/controllers/api/pm/projects_controller.rb +++ b/app/controllers/api/pm/projects_controller.rb @@ -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