From 1e5d7e99b362087fc7e8a476fac8dc98377f172c Mon Sep 17 00:00:00 2001 From: j Date: Tue, 18 Sep 2018 11:05:58 +0200 Subject: [PATCH] merge comment --- pandora/annotation/models.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pandora/annotation/models.py b/pandora/annotation/models.py index 1327f3bdb..0e27f8486 100644 --- a/pandora/annotation/models.py +++ b/pandora/annotation/models.py @@ -292,6 +292,13 @@ class Annotation(models.Model): def _get_entity_json(self, user=None, entity_cache=None): """When serializing many annotations pointing to the same entity, it is expensive to 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