mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-08 00:28:16 -06:00
Note about cached_as extra keys
This commit is contained in:
parent
e4a8570d6b
commit
45c09c7e6e
@ -399,8 +399,10 @@ class PowerPort(CableTermination, ComponentModel):
|
||||
else:
|
||||
outlets = PowerOutlet.objects.filter(power_port=self)
|
||||
|
||||
# The outlets are used as extra to invalidate the cache when an outlet's leg is changed
|
||||
@cached_as(self, extra=outlets)
|
||||
def _stats():
|
||||
# Power ports drawing power from the local outlets
|
||||
return PowerPort.objects.filter(
|
||||
pk__in=outlets.values_list('downstream_powerports', flat=True),
|
||||
).aggregate(
|
||||
@ -408,7 +410,6 @@ class PowerPort(CableTermination, ComponentModel):
|
||||
Sum('maximum_draw'),
|
||||
)
|
||||
|
||||
# Power ports drawing power from the local outlets
|
||||
stats = _stats()
|
||||
|
||||
return outlets.count(), stats.get('allocated_draw__sum') or 0, stats.get('maximum_draw__sum') or 0
|
||||
|
Loading…
Reference in New Issue
Block a user