Speed up sql
Some checks failed
/ test (push) Failing after 53s
/ test (pull_request) Failing after 51s

This commit is contained in:
eleon 2024-11-21 21:14:38 +01:00
parent fdf5ab8ad1
commit 0de9e47b27
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):