perf: Modifying the label matching logic of an AppletHost (random)

This commit is contained in:
Bai
2024-07-25 18:59:06 +08:00
committed by Bryan
parent 4887b21d35
commit 457021040a
2 changed files with 8 additions and 7 deletions

View File

@@ -173,7 +173,7 @@ class Asset(NodesRelationMixin, LabeledMixin, AbsConnectivity, JSONFilterMixin,
def get_labels(self):
from labels.models import Label, LabeledResource
res_type = ContentType.objects.get_for_model(self.__class__)
res_type = ContentType.objects.get_for_model(self.__class__.label_model())
label_ids = LabeledResource.objects.filter(res_type=res_type, res_id=self.id) \
.values_list('label_id', flat=True)
return Label.objects.filter(id__in=label_ids)