mirror of
https://github.com/makeplane/plane.git
synced 2026-07-13 22:09:12 +02:00
chore: cycle and module assignee and issue count (#933)
* chore: cycle assignees count * chore: module assignees count * chore: module assignees count * chore: added owned by detail and led detail in cycle and module types * chore: updated leadDetail in module * chore: updated lead in module and owened_by in cycle query * chore: removed unused types in cycle
This commit is contained in:
@@ -14,6 +14,7 @@ from asgiref.sync import sync_to_async
|
||||
|
||||
# Module Imports
|
||||
from plane.db.models import Cycle, Issue
|
||||
from plane.graphql.types.users import UserType
|
||||
|
||||
|
||||
@strawberry_django.type(Cycle)
|
||||
@@ -23,7 +24,6 @@ class CycleType:
|
||||
description: Optional[str]
|
||||
start_date: Optional[date]
|
||||
end_date: Optional[date]
|
||||
owned_by: strawberry.ID
|
||||
view_props: Optional[JSON]
|
||||
sort_order: Optional[float]
|
||||
external_source: Optional[str]
|
||||
@@ -39,10 +39,7 @@ class CycleType:
|
||||
updated_at: datetime
|
||||
total_issues: int
|
||||
completed_issues: int
|
||||
|
||||
@strawberry.field
|
||||
def owned_by(self) -> int:
|
||||
return self.owned_by_id
|
||||
owned_by: Optional[UserType]
|
||||
|
||||
@strawberry.field
|
||||
def project(self) -> int:
|
||||
@@ -67,9 +64,22 @@ class CycleType:
|
||||
|
||||
@strawberry.field
|
||||
async def completed_issues(self, info: Info) -> int:
|
||||
total_issues = await sync_to_async(
|
||||
completed_issues = await sync_to_async(
|
||||
lambda: Issue.issue_objects.filter(
|
||||
issue_cycle__cycle_id=self.id, state__group="completed"
|
||||
).count()
|
||||
)()
|
||||
return total_issues
|
||||
return completed_issues
|
||||
|
||||
@strawberry.field
|
||||
async def assignees_count(self) -> int:
|
||||
issue_assignees_count = await sync_to_async(
|
||||
lambda: Issue.issue_objects.filter(
|
||||
issue_cycle__cycle_id=self.id,
|
||||
issue_cycle__issue__assignees__id__isnull=False,
|
||||
)
|
||||
.values("issue_cycle__issue__assignees__id")
|
||||
.distinct()
|
||||
.count()
|
||||
)()
|
||||
return issue_assignees_count
|
||||
|
||||
@@ -10,6 +10,7 @@ from strawberry.scalars import JSON
|
||||
|
||||
# Module Imports
|
||||
from plane.db.models import Module, Issue
|
||||
from plane.graphql.types.users import UserType
|
||||
|
||||
# Third-party library imports
|
||||
from asgiref.sync import sync_to_async
|
||||
@@ -31,7 +32,6 @@ class ModuleType:
|
||||
description_html: Optional[str]
|
||||
start_date: Optional[date]
|
||||
target_date: Optional[date]
|
||||
lead: Optional[strawberry.ID]
|
||||
members: Optional[list[strawberry.ID]]
|
||||
view_props: Optional[JSON]
|
||||
sort_order: float
|
||||
@@ -41,6 +41,7 @@ class ModuleType:
|
||||
logo_props: Optional[JSON]
|
||||
total_issues: int
|
||||
completed_issues: int
|
||||
lead: Optional[UserType]
|
||||
|
||||
@strawberry.field
|
||||
def project(self) -> int:
|
||||
@@ -71,3 +72,16 @@ class ModuleType:
|
||||
).count()
|
||||
)()
|
||||
return total_issues
|
||||
|
||||
@strawberry.field
|
||||
async def assignees_count(self) -> int:
|
||||
issue_assignees_count = await sync_to_async(
|
||||
lambda: Issue.issue_objects.filter(
|
||||
issue_module__module_id=self.id,
|
||||
issue_module__issue__assignees__id__isnull=False,
|
||||
)
|
||||
.values("issue_module__issue__assignees__id")
|
||||
.distinct()
|
||||
.count()
|
||||
)()
|
||||
return issue_assignees_count
|
||||
|
||||
@@ -33,10 +33,6 @@ class WorkspaceMemberType:
|
||||
role: int
|
||||
is_active: bool
|
||||
|
||||
async def member(self) -> UserType:
|
||||
member = await sync_to_async(self.member)()
|
||||
return member
|
||||
|
||||
|
||||
# workspace your work
|
||||
@strawberry.type
|
||||
|
||||
Reference in New Issue
Block a user