2021-04-27 06:21:48 +00:00
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
|
2023-02-09 12:48:25 +00:00
|
|
|
from assets.signal_handlers.node_assets_mapping import expire_node_assets_mapping
|
2021-08-19 07:40:41 +00:00
|
|
|
from orgs.caches import OrgResourceStatisticsCache
|
2021-04-27 06:21:48 +00:00
|
|
|
from orgs.models import Organization
|
|
|
|
|
|
|
|
|
|
|
|
def expire_node_assets_mapping():
|
|
|
|
org_ids = Organization.objects.all().values_list('id', flat=True)
|
|
|
|
org_ids = [*org_ids, '00000000-0000-0000-0000-000000000000']
|
|
|
|
|
|
|
|
for org_id in org_ids:
|
2023-02-09 12:48:25 +00:00
|
|
|
expire_node_assets_mapping(org_id)
|
2021-04-27 06:21:48 +00:00
|
|
|
|
|
|
|
|
2021-08-19 07:40:41 +00:00
|
|
|
def expire_org_resource_statistics_cache():
|
|
|
|
orgs = Organization.objects.all()
|
|
|
|
for org in orgs:
|
|
|
|
cache = OrgResourceStatisticsCache(org)
|
|
|
|
cache.expire()
|
|
|
|
|
|
|
|
|
2021-04-27 06:21:48 +00:00
|
|
|
class Command(BaseCommand):
|
|
|
|
help = 'Expire caches'
|
|
|
|
|
|
|
|
def handle(self, *args, **options):
|
|
|
|
expire_node_assets_mapping()
|
2021-08-19 07:40:41 +00:00
|
|
|
expire_org_resource_statistics_cache()
|