diff options
author | Stephen Finucane <stephen@that.guru> | 2017-05-16 00:13:29 +0100 |
---|---|---|
committer | Stephen Finucane <stephen@that.guru> | 2017-05-18 21:18:37 +0100 |
commit | 42def013fe468ef2b112dd345987515edcc62d07 (patch) | |
tree | 67dfcf3e56955a8c3202417c0df61710fcc0bfc9 | |
parent | 2d486c28c5b8a67c7242f19749354afd21533961 (diff) | |
download | patchwork-42def013fe468ef2b112dd345987515edcc62d07.tar patchwork-42def013fe468ef2b112dd345987515edcc62d07.tar.gz |
REST: Stop including 'tags' in '/patches'
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>
-rw-r--r-- | patchwork/api/patch.py | 12 | ||||
-rw-r--r-- | patchwork/tests/test_rest_api.py | 3 |
2 files changed, 6 insertions, 9 deletions
diff --git a/patchwork/api/patch.py b/patchwork/api/patch.py index 294c5f6..7247b11 100644 --- a/patchwork/api/patch.py +++ b/patchwork/api/patch.py @@ -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') diff --git a/patchwork/tests/test_rest_api.py b/patchwork/tests/test_rest_api.py index 2b064a2..3c11bca 100644 --- a/patchwork/tests/test_rest_api.py +++ b/patchwork/tests/test_rest_api.py @@ -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.""" |