merge comment

This commit is contained in:
j 2018-09-18 11:05:58 +02:00
parent 00746ed7d9
commit 1e5d7e99b3

View file

@ -292,6 +292,13 @@ class Annotation(models.Model):
def _get_entity_json(self, user=None, entity_cache=None): def _get_entity_json(self, user=None, entity_cache=None):
"""When serializing many annotations pointing to the same entity, it is expensive to """When serializing many annotations pointing to the same entity, it is expensive to
repeatedly look up and serialize the same entity. repeatedly look up and serialize the same entity.
TODO: if Entity were a (nullable) foreign key of Annotation, we could just:
prefetch_related('entity', 'entity__user', 'entity__documents')
before serializing the annotations, which would make self.entity.json(user=user) cheap and
all this unnecessary.
""" """
from entity.models import Entity from entity.models import Entity