[Update] 修改节点资产数量的bug

pull/3217/head^2
ibuler 5 years ago
parent 3fdec62e25
commit 444f494c0b

@ -39,9 +39,9 @@ class TreeMixin:
tree_updated_time = cache.get(cls.tree_updated_time_cache_key, 0) tree_updated_time = cache.get(cls.tree_updated_time_cache_key, 0)
if not cls.tree_created_time or \ if not cls.tree_created_time or \
tree_updated_time > cls.tree_created_time: tree_updated_time > cls.tree_created_time:
logger.debug("Create node tree")
tree = TreeService.new() tree = TreeService.new()
cls.tree_created_time = time.time() cls.tree_created_time = time.time()
cls.refresh_tree(cls.tree_assets_created_time)
cls.tree_assets_created_time = time.time() cls.tree_assets_created_time = time.time()
cls._tree_service = tree cls._tree_service = tree
return tree return tree
@ -50,7 +50,7 @@ class TreeMixin:
node_assets_updated_time > cls.tree_assets_created_time: node_assets_updated_time > cls.tree_assets_created_time:
cls._tree_service.init_assets_async() cls._tree_service.init_assets_async()
cls.tree_assets_created_time = time.time() cls.tree_assets_created_time = time.time()
cls.refresh_node_assets(cls.tree_assets_created_time) logger.debug("Refresh node tree assets")
return cls._tree_service return cls._tree_service
@classmethod @classmethod

@ -92,6 +92,8 @@ class TreeService(Tree):
def init_assets(self): def init_assets(self):
from orgs.utils import tmp_to_root_org from orgs.utils import tmp_to_root_org
self.all_nodes_assets_map = {} self.all_nodes_assets_map = {}
self.nodes_assets_map = defaultdict(set)
logger.debug('Init tree assets')
with tmp_to_root_org(): with tmp_to_root_org():
queryset = Asset.objects.all().values_list('id', 'nodes__key') queryset = Asset.objects.all().values_list('id', 'nodes__key')
for asset_id, key in queryset: for asset_id, key in queryset:

Loading…
Cancel
Save