chore: add assignee avatar in cycle endpoint (#996)
* chore: add assignee avatar in cycle endpoint * dev: update the structure to return avatar and firstname * dev: return distinct users * dev: update the structure to return id * dev: update the prefetch queryset to distinct by id * dev: remove id from distinct * dev: add unique condition
This commit is contained in:
parent
1bf1b63fff
commit
993cf3faba
2 changed files with 45 additions and 1 deletions
|
|
@ -30,6 +30,7 @@ from plane.db.models import (
|
|||
CycleFavorite,
|
||||
IssueLink,
|
||||
IssueAttachment,
|
||||
User,
|
||||
)
|
||||
from plane.bgtasks.issue_activites_task import issue_activity
|
||||
from plane.utils.grouper import group_results
|
||||
|
|
@ -501,6 +502,12 @@ class CurrentUpcomingCyclesEndpoint(BaseAPIView):
|
|||
filter=Q(issue_cycle__issue__state__group="backlog"),
|
||||
)
|
||||
)
|
||||
.prefetch_related(
|
||||
Prefetch(
|
||||
"issue_cycle__issue__assignees",
|
||||
queryset=User.objects.only("avatar", "first_name", "id").distinct(),
|
||||
)
|
||||
)
|
||||
.order_by("name", "-is_favorite")
|
||||
)
|
||||
|
||||
|
|
@ -545,6 +552,12 @@ class CurrentUpcomingCyclesEndpoint(BaseAPIView):
|
|||
filter=Q(issue_cycle__issue__state__group="backlog"),
|
||||
)
|
||||
)
|
||||
.prefetch_related(
|
||||
Prefetch(
|
||||
"issue_cycle__issue__assignees",
|
||||
queryset=User.objects.only("avatar", "first_name", "id").distinct(),
|
||||
)
|
||||
)
|
||||
.order_by("name", "-is_favorite")
|
||||
)
|
||||
|
||||
|
|
@ -557,7 +570,7 @@ class CurrentUpcomingCyclesEndpoint(BaseAPIView):
|
|||
)
|
||||
|
||||
except Exception as e:
|
||||
capture_exception(e)
|
||||
print(e)
|
||||
return Response(
|
||||
{"error": "Something went wrong please try again later"},
|
||||
status=status.HTTP_400_BAD_REQUEST,
|
||||
|
|
@ -618,6 +631,12 @@ class CompletedCyclesEndpoint(BaseAPIView):
|
|||
filter=Q(issue_cycle__issue__state__group="backlog"),
|
||||
)
|
||||
)
|
||||
.prefetch_related(
|
||||
Prefetch(
|
||||
"issue_cycle__issue__assignees",
|
||||
queryset=User.objects.only("avatar", "first_name", "id").distinct(),
|
||||
)
|
||||
)
|
||||
.order_by("name", "-is_favorite")
|
||||
)
|
||||
|
||||
|
|
@ -693,6 +712,12 @@ class DraftCyclesEndpoint(BaseAPIView):
|
|||
filter=Q(issue_cycle__issue__state__group="backlog"),
|
||||
)
|
||||
)
|
||||
.prefetch_related(
|
||||
Prefetch(
|
||||
"issue_cycle__issue__assignees",
|
||||
queryset=User.objects.only("avatar", "first_name", "id").distinct(),
|
||||
)
|
||||
)
|
||||
.order_by("name", "-is_favorite")
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue