From aee48f6fa410492fecce09bd0bb21650bd441ed5 Mon Sep 17 00:00:00 2001 From: Bavisetti Narayan <72156168+NarayanBavisetti@users.noreply.github.com> Date: Tue, 23 Apr 2024 13:04:14 +0530 Subject: [PATCH] [WEB-1042] fix: dashboard collaborators active issue count (#4256) * chore: recent collaborators based on workspace * chore: removed the duplicate issue --- apiserver/plane/app/views/dashboard/base.py | 15 ++++++++++----- .../plane/db/management/commands/test_email.py | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/apiserver/plane/app/views/dashboard/base.py b/apiserver/plane/app/views/dashboard/base.py index 33b3cf9d5..9558348d9 100644 --- a/apiserver/plane/app/views/dashboard/base.py +++ b/apiserver/plane/app/views/dashboard/base.py @@ -571,14 +571,16 @@ def dashboard_recent_collaborators(self, request, slug): return self.paginate( request=request, queryset=project_members_with_activities, - controller=self.get_results_controller, + controller=lambda qs: self.get_results_controller(qs, slug), ) class DashboardEndpoint(BaseAPIView): - def get_results_controller(self, project_members_with_activities): + def get_results_controller(self, project_members_with_activities, slug): user_active_issue_counts = ( - User.objects.filter(id__in=project_members_with_activities) + User.objects.filter( + id__in=project_members_with_activities, + ) .annotate( active_issue_count=Count( Case( @@ -587,10 +589,13 @@ class DashboardEndpoint(BaseAPIView): "unstarted", "started", ], - then=1, + issue_assignee__issue__workspace__slug=slug, + issue_assignee__issue__project__project_projectmember__is_active=True, + then=F("issue_assignee__issue__id"), ), output_field=IntegerField(), - ) + ), + distinct=True, ) ) .values("active_issue_count", user_id=F("id")) diff --git a/apiserver/plane/db/management/commands/test_email.py b/apiserver/plane/db/management/commands/test_email.py index 99c5d9684..63b602518 100644 --- a/apiserver/plane/db/management/commands/test_email.py +++ b/apiserver/plane/db/management/commands/test_email.py @@ -15,7 +15,7 @@ class Command(BaseCommand): receiver_email = options.get("to_email") if not receiver_email: - raise CommandError("Reciever email is required") + raise CommandError("Receiver email is required") ( EMAIL_HOST, @@ -54,7 +54,7 @@ class Command(BaseCommand): connection=connection, ) msg.send() - self.stdout.write(self.style.SUCCESS("Email succesfully sent")) + self.stdout.write(self.style.SUCCESS("Email successfully sent")) except Exception as e: self.stdout.write( self.style.ERROR(