[PATCH 1/2] api: do not fetch every patch in a patch detail view 404

Stephen Finucane stephen at that.guru
Tue Apr 14 20:22:29 AEST 2020


On Tue, 2020-04-14 at 16:21 +1000, Daniel Axtens wrote:
> 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.
> 
> Reported-by: Jeremy Kerr <jk at ozlabs.org>
> Reported-by: Michael Ellerman <mpe at ellerman.id.au>
> Reported-by: Stephen Rothwell <sfr at canb.auug.org.au>
> Signed-off-by: Daniel Axtens <dja at axtens.net>

It's a crying shame that DRF doesn't provide any AJAX'y widgets out of
the box, though I guess that would involve choosing a framework since
JQuery is dying. Given they don't, this is the correct solution. Even
the docs [1] say so!

Reviewed-by: Stephen Finucane <stephen at that.guru>

Stephen

PS: It would be nice to include [1] in the commit message when merging.

[1] https://www.django-rest-framework.org/topics/browsable-api/#handling-choicefield-with-large-numbers-of-items



More information about the Patchwork mailing list