fix: optimize the number of queries in the serializers and queryset
- Changes in connection.py:
- Optimizes database queries by prefetching related
created_by
objects in the queryset ofConnectionViewset
- Efficiently retrieves the related
credential
object for the current user by prefetching the associateduser
object inget_credential
(same forget_last_edited_time
) - Caches and retrieves serialized representations in
to_representation
based on the instance's primary key to optimize performance and reduce redundant serialization computations.
- Optimizes database queries by prefetching related
- re-adapt the queryset in
DatalinksViewset
Edited by Imane Messak