Optimize num queries in API serializers and views
We recently optimized SoundSerializer and SoundListSerializer to optimize the number of queries they carry out to render sound data. In fact, if loaded with a Sound object retrieved using Sound.objects.bulk_query_id(), the sound serializers will perform no extra query.
The other serializers used in the API should also be optimized similarly. This requires changes in the serializer and changes in the views that load the objects that are passed to the serializer (e.g. adding some select_related or annotating querysets).
Unit tests must be added for each serializer (like those already existing for SoundListSerializer and SoundSerializer). It would be optimal also to add unit tests for the corresponding API views that call the serializers and assert number of queries in these.
Note: even though SoundSerializer has been updated, the sound instance view has not and it is not bulk_sound_id (or select_related) to retrieve the sound, which generates unwanted queries later at the serializer. This also needs to be fixed.