openverse-api icon indicating copy to clipboard operation
openverse-api copied to clipboard

Move audio thumbnail retrieval into grouped query

Open AetherUnbound opened this issue 3 years ago • 0 comments

Description

PR #727 introduced a query which runs for every Audio result and attempts to retrieve the thumbnail associated with the audio record. If no thumbnail is found, it is set to None on the API end:

https://github.com/WordPress/openverse-api/blob/5fae4eb89c33f849fd41d2a890057858ec789278/api/catalog/api/serializers/audio_serializers.py#L138-L150

@sarayourfriend had mentioned that it should be possible to move this into the "list" endpoint for Audio records, and have a targeted Audio.objects.filter(identifier__in=<identifiers>) rather than performing one query per audio Hit.

It seems that this particular code path is intended to be removed once we alter the Elasticsearch index to include audio thumbnails, although it doesn't look like we have a ticket for that yet.

Additional context

PR #765 was also related to this work.

Resolution

  • [ ] 🙋 I would be interested in resolving this bug.

AetherUnbound avatar Aug 26 '22 19:08 AetherUnbound