Speed up sql
All checks were successful
/ test (pull_request) Successful in 48s
/ test (push) Successful in 49s
/ deploy (push) Successful in 5m13s

This commit is contained in:
eleon 2024-11-21 21:14:38 +01:00
parent fdf5ab8ad1
commit 81a0959547
4 changed files with 18 additions and 12 deletions

View file

@ -24,7 +24,7 @@ class BasicItemSerializer(serializers.ModelSerializer):
def get_file(self, instance):
if len(instance.files.all()) > 0:
return instance.files.all().order_by('-created_at')[0].hash
return sorted(instance.files.all(), key=lambda x: x.created_at, reverse=True)[0].hash
return None
def get_returned(self, instance):