From 3ae976c1839399d9e05a2b889726304c57c395c4 Mon Sep 17 00:00:00 2001 From: "fghbng@qq.com" Date: Thu, 3 Jun 2021 11:01:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BC=93=E5=AD=98=EF=BC=8C?= =?UTF-8?q?=E5=B0=86=E4=BC=9A=E8=AF=9D=E7=9A=84=E7=BC=93=E5=AD=98=E6=8B=BF?= =?UTF-8?q?=E5=87=BA=E6=9D=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/orgs/signals_handler/cache.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/orgs/signals_handler/cache.py b/apps/orgs/signals_handler/cache.py index 626975991..20087dfac 100644 --- a/apps/orgs/signals_handler/cache.py +++ b/apps/orgs/signals_handler/cache.py @@ -72,11 +72,17 @@ class OrgResourceStatisticsRefreshUtil: OrgResourceStatisticsCache(Organization.root()).expire(*cache_field_name) -@receiver(pre_save) -def on_post_save_refresh_org_resource_statistics_cache(sender, instance, **kwargs): - OrgResourceStatisticsRefreshUtil.refresh_if_need(instance) +@receiver(post_save) +def on_post_save_refresh_org_resource_statistics_cache(sender, instance, created, **kwargs): + if created: + OrgResourceStatisticsRefreshUtil.refresh_if_need(instance) @receiver(pre_delete) def on_pre_delete_refresh_org_resource_statistics_cache(sender, instance, **kwargs): OrgResourceStatisticsRefreshUtil.refresh_if_need(instance) + + +@receiver(pre_save, sender=Session) +def on_session_changed_refresh_org_resource_statistics_cache(sender, instance, **kwargs): + OrgResourceStatisticsRefreshUtil.refresh_if_need(instance)