Skip to content

Commit 08c5856

Browse files
committed
api: do not fetch every patch in a patch detail view 404
mpe and jk and sfr found that the OzLabs server was melting due to some queries downloading every patch. Turns out if you 404 the patch detail view in the API, d-r-f attempts to render a listbox with every single patch to fill in the 'related' field. The bundle API also has a similar field. Replace the multiple selection box with a text field. You can still (AIUI) populate the relevant patch IDs manually. This is the recommended approach per https://www.django-rest-framework.org/topics/browsable-api/#handling-choicefield-with-large-numbers-of-items Reported-by: Jeremy Kerr <jk@ozlabs.org> Reported-by: Michael Ellerman <mpe@ellerman.id.au> Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Tested-by: Jeremy Kerr <jk@ozlabs.org> Server-no-longer-on-fire-by: Jeremy Kerr <jk@ozlabs.org> Reviewed-by: Stephen Finucane <stephen@that.guru> Signed-off-by: Daniel Axtens <dja@axtens.net>
1 parent 4eaf300 commit 08c5856

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

patchwork/api/bundle.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ class BundleSerializer(BaseHyperlinkedModelSerializer):
6262
project = ProjectSerializer(read_only=True)
6363
mbox = SerializerMethodField()
6464
owner = UserSerializer(read_only=True)
65-
patches = PatchSerializer(many=True, required=True)
65+
patches = PatchSerializer(many=True, required=True,
66+
style={'base_template': 'input.html'})
6667

6768
def get_web_url(self, instance):
6869
request = self.context.get('request')

patchwork/api/embedded.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ class Meta:
141141

142142
class PatchRelationSerializer(BaseHyperlinkedModelSerializer):
143143
"""Hide the PatchRelation model, just show the list"""
144-
patches = PatchSerializer(many=True)
144+
patches = PatchSerializer(many=True,
145+
style={'base_template': 'input.html'})
145146

146147
def to_internal_value(self, data):
147148
if not isinstance(data, type([])):

0 commit comments

Comments
 (0)