From aa6da2a3bc53daba61bce0b934e43882f3fdf0a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Redrejo?= Date: Wed, 2 Dec 2020 20:16:30 +0100 Subject: [PATCH] Making clearer the values in the queryset for the annotate after paginate approach --- .../search/viewsets/contentnode.py | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/contentcuration/search/viewsets/contentnode.py b/contentcuration/search/viewsets/contentnode.py index 91244c9235..345933cd15 100644 --- a/contentcuration/search/viewsets/contentnode.py +++ b/contentcuration/search/viewsets/contentnode.py @@ -186,6 +186,24 @@ class SearchContentNodeViewSet(ContentNodeViewSet): "content_id", "node_id", ) + base_values = ( + "title", + "description", + "author", + "provider", + "kind__kind", + "channel_id", + "resource_count", + "thumbnail_checksum", + "thumbnail_extension", + "thumbnail_encoding", + "published", + "modified", + "parent_id", + "changed", + "location_ids", + "content_tags", + ) def paginate_queryset(self, queryset): page_results = self.paginator.paginate_queryset( @@ -194,7 +212,8 @@ def paginate_queryset(self, queryset): ids = [result["id"] for result in page_results] queryset = self._annotate_channel_id(ContentNode.objects.filter(id__in=ids)) queryset = self.complete_annotations(queryset) - return list(queryset.values()) + self.values = self.values + self.base_values + return list(queryset.values(*self.values)) def get_accessible_nodes_queryset(self): # jayoshih: May the force be with you, optimizations team...