Skip to content

Commit

Permalink
fix: issue serializer to remove deleted labels and assignees (#6241)
Browse files Browse the repository at this point in the history
  • Loading branch information
pablohashescobar authored Dec 20, 2024
1 parent e6bf57a commit 00624ea
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions apiserver/plane/api/serializers/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,17 +237,37 @@ def to_representation(self, instance):
from .user import UserLiteSerializer

data["assignees"] = UserLiteSerializer(
instance.assignees.all(), many=True
User.objects.filter(
pk__in=IssueAssignee.objects.filter(issue=instance).values_list(
"assignee_id", flat=True
)
),
many=True,
).data
else:
data["assignees"] = [
str(assignee.id) for assignee in instance.assignees.all()
str(assignee)
for assignee in IssueAssignee.objects.filter(
issue=instance
).values_list("assignee_id", flat=True)
]
if "labels" in self.fields:
if "labels" in self.expand:
data["labels"] = LabelSerializer(instance.labels.all(), many=True).data
data["labels"] = LabelSerializer(
Label.objects.filter(
pk__in=IssueLabel.objects.filter(issue=instance).values_list(
"label_id", flat=True
)
),
many=True,
).data
else:
data["labels"] = [str(label.id) for label in instance.labels.all()]
data["labels"] = [
str(label)
for label in IssueLabel.objects.filter(issue=instance).values_list(
"label_id", flat=True
)
]

return data

Expand Down

0 comments on commit 00624ea

Please sign in to comment.