mirror of
https://github.com/lemeow125/Borrowing-TrackerBackend.git
synced 2024-11-17 06:19:26 +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
|
# This updates the status field of all equipment instances in a single query
|
||||||
EquipmentInstance.objects.filter(
|
EquipmentInstance.objects.filter(
|
||||||
id__in=[equipment.id for equipment in equipments]).update(status='Available')
|
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)
|
return super().update(instance, validated_data)
|
||||||
|
|
||||||
# For Approved transactions,
|
# For Approved transactions,
|
||||||
|
@ -208,6 +210,8 @@ class TransactionSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
# This updates the status field of all equipment instances in a single query
|
# This updates the status field of all equipment instances in a single query
|
||||||
EquipmentInstance.objects.filter(
|
EquipmentInstance.objects.filter(
|
||||||
id__in=[equipment.id for equipment in equipments]).update(status='Available')
|
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)
|
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
|
# 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