[WEB-4442] fix: removed the deleted labels from webhook payload (#7337)

* chore: removed the deleted label from payload

* chore: optimised the query

* chore: optimised the logic

* chore: defined function for prefetch
This commit is contained in:
Bavisetti Narayan 2025-07-18 20:08:01 +05:30 committed by GitHub
parent d5eb374217
commit a75ae71ff0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 52 additions and 3 deletions

View file

@ -448,10 +448,30 @@ class LabelLiteSerializer(BaseSerializer):
class IssueExpandSerializer(BaseSerializer):
cycle = CycleLiteSerializer(source="issue_cycle.cycle", read_only=True)
module = ModuleLiteSerializer(source="issue_module.module", read_only=True)
labels = LabelLiteSerializer(read_only=True, many=True)
assignees = UserLiteSerializer(read_only=True, many=True)
labels = serializers.SerializerMethodField()
assignees = serializers.SerializerMethodField()
state = StateLiteSerializer(read_only=True)
def get_labels(self, obj):
expand = self.context.get("expand", [])
if "labels" in expand:
# Use prefetched data
return LabelLiteSerializer(
[il.label for il in obj.label_issue.all()], many=True
).data
return [il.label_id for il in obj.label_issue.all()]
def get_assignees(self, obj):
expand = self.context.get("expand", [])
if "assignees" in expand:
return UserLiteSerializer(
[ia.assignee for ia in obj.issue_assignee.all()], many=True
).data
return [ia.assignee_id for ia in obj.issue_assignee.all()]
class Meta:
model = Issue
fields = "__all__"