]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
REST: Stop including 'tags' in '/patches'
authorStephen Finucane <stephen@that.guru>
Mon, 15 May 2017 23:13:29 +0000 (00:13 +0100)
committerStephen Finucane <stephen@that.guru>
Thu, 18 May 2017 20:18:37 +0000 (21:18 +0100)
While this is a very helpful field to include, doing so significantly
increases the number of DB queries necessary for listing patches (from
~14 to ~46). Stop including this information until the model itself is
reworked to prevent this issue.

Signed-off-by: Stephen Finucane <stephen@that.guru>
patchwork/api/patch.py
patchwork/tests/test_rest_api.py

index 294c5f625b7aab3c5f623a80e99193e9cfad12f0..7247b110fe91d114d9a284790c24859538e1ecfb 100644 (file)
@@ -84,11 +84,9 @@ class PatchListSerializer(HyperlinkedModelSerializer):
         return request.build_absolute_uri(instance.get_mbox_url())
 
     def get_tags(self, instance):
-        if instance.project.tags:
-            return {x.name: getattr(instance, x.attr_name)
-                    for x in instance.project.tags}
-        else:
-            return None
+        # TODO(stephenfin): Make tags performant, possibly by reworking the
+        # model
+        return {}
 
     def get_check(self, instance):
         return instance.combined_check_state
@@ -149,7 +147,7 @@ class PatchList(ListAPIView):
     def get_queryset(self):
         # TODO(stephenfin): Does the defer here cause issues with Django 1.6
         # (like /cover)?
-        return Patch.objects.all().with_tag_counts()\
+        return Patch.objects.all()\
             .prefetch_related('series', 'check_set')\
             .select_related('project', 'state', 'submitter', 'delegate')\
             .defer('content', 'diff', 'headers')
@@ -162,6 +160,6 @@ class PatchDetail(RetrieveUpdateAPIView):
     serializer_class = PatchDetailSerializer
 
     def get_queryset(self):
-        return Patch.objects.all().with_tag_counts()\
+        return Patch.objects.all()\
             .prefetch_related('series', 'check_set')\
             .select_related('project', 'state', 'submitter', 'delegate')
index 2b064a25028e6401ecc171da6a7858dc8dee4b3c..3c11bcaefdc0ad9f2a91dd350f9053902f6c4778 100644 (file)
@@ -357,8 +357,7 @@ class TestPatchAPI(APITestCase):
         self.assertEqual(patch.headers, resp.data['headers'] or '')
         self.assertEqual(patch.content, resp.data['content'])
         self.assertEqual(patch.diff, resp.data['diff'])
-        self.assertEqual(3, len(resp.data['tags']))
-        self.assertEqual(1, resp.data['tags']['Reviewed-by'])
+        self.assertEqual(0, len(resp.data['tags']))
 
     def test_create(self):
         """Ensure creations are rejected."""