mirror of
https://github.com/lemeow125/Borrowing-TrackerBackend.git
synced 2024-11-16 22:09:27 +08:00
Improve caching
This commit is contained in:
parent
f418bc017d
commit
c61f978c75
1 changed files with 4 additions and 0 deletions
|
@ -191,6 +191,8 @@ class TransactionSerializer(serializers.HyperlinkedModelSerializer):
|
|||
# This updates the status field of all equipment instances in a single query
|
||||
EquipmentInstance.objects.filter(
|
||||
id__in=[equipment.id for equipment in equipments]).update(status='Available')
|
||||
cache.delete('available_equipment_instances')
|
||||
cache.delete('equipment_instances')
|
||||
return super().update(instance, validated_data)
|
||||
|
||||
# For Approved transactions,
|
||||
|
@ -208,6 +210,8 @@ class TransactionSerializer(serializers.HyperlinkedModelSerializer):
|
|||
# This updates the status field of all equipment instances in a single query
|
||||
EquipmentInstance.objects.filter(
|
||||
id__in=[equipment.id for equipment in equipments]).update(status='Available')
|
||||
cache.delete('available_equipment_instances')
|
||||
cache.delete('equipment_instances')
|
||||
return super().update(instance, validated_data)
|
||||
|
||||
# If there are no issues and a transaction changes from Approved to Borrowed, label the selected equipment's statuses as Borrowed
|
||||
|
|
Loading…
Reference in a new issue