fix: 修改组织资源统计时 org 为None的问题

pull/8265/head
Jiangjie.Bai 2022-05-17 22:09:08 +08:00 committed by 老广
parent c3c0f87c01
commit b76920a4bf
1 changed files with 5 additions and 4 deletions

View File

@ -91,10 +91,11 @@ class OrgResourceStatisticsRefreshUtil:
@classmethod
def refresh_if_need(cls, instance):
cache_field_name = cls.model_cache_field_mapper.get(type(instance))
if cache_field_name:
org_cache = OrgResourceStatisticsCache(instance.org)
org_cache.expire(*cache_field_name)
OrgResourceStatisticsCache(Organization.root()).expire(*cache_field_name)
if not cache_field_name:
return
OrgResourceStatisticsCache(Organization.root()).expire(*cache_field_name)
if instance.org:
OrgResourceStatisticsCache(instance.org).expire(*cache_field_name)
@receiver(post_save)