diff options
-rw-r--r-- | patchwork/api/patch.py | 9 | ||||
-rw-r--r-- | patchwork/tests/api/test_patch.py | 4 |
2 files changed, 8 insertions, 5 deletions
diff --git a/patchwork/api/patch.py b/patchwork/api/patch.py index efa38e1..15fce8e 100644 --- a/patchwork/api/patch.py +++ b/patchwork/api/patch.py @@ -288,10 +288,13 @@ class PatchList(ListAPIView): ordering = 'id' def get_queryset(self): + # TODO(dja): we need to revisit this after the patch migration, paying + # particular attention to cases with filtering return Patch.objects.all()\ - .prefetch_related('check_set', 'related__patches__project')\ - .select_related('project', 'state', 'submitter', 'delegate', - 'series__project')\ + .prefetch_related( + 'check_set', 'delegate', 'project', 'series__project', + 'related__patches__project')\ + .select_related('state', 'submitter', 'series')\ .defer('content', 'diff', 'headers') diff --git a/patchwork/tests/api/test_patch.py b/patchwork/tests/api/test_patch.py index aba92b9..b24c5ab 100644 --- a/patchwork/tests/api/test_patch.py +++ b/patchwork/tests/api/test_patch.py @@ -211,11 +211,11 @@ class TestPatchAPI(utils.APITestCase): self.assertNotIn('web_url', resp.data[0]) def test_list_bug_335(self): - """Ensure we retrieve the embedded series project once.""" + """Ensure we retrieve the embedded series project in O(1).""" series = create_series() create_patches(5, series=series) - with self.assertNumQueries(4): + with self.assertNumQueries(7): self.client.get(self.api_url()) @utils.store_samples('patch-detail') |