From 79f5dac661b069a813f510f62aa5d6788f8a592b Mon Sep 17 00:00:00 2001 From: pycook Date: Mon, 18 Sep 2023 13:04:50 +0800 Subject: [PATCH] fix dashboard compute --- cmdb-api/api/lib/cmdb/cache.py | 2 +- cmdb-api/api/lib/cmdb/ci_type.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cmdb-api/api/lib/cmdb/cache.py b/cmdb-api/api/lib/cmdb/cache.py index bbc1c22..b3c3aa3 100644 --- a/cmdb-api/api/lib/cmdb/cache.py +++ b/cmdb-api/api/lib/cmdb/cache.py @@ -342,7 +342,7 @@ class CMDBCounterCache(object): type_ids = custom['options'].get('type_ids') or (type_id and [type_id]) attr_ids = list(map(str, custom['options'].get('attr_ids') or (attr_id and [attr_id]))) other_filter = custom['options'].get('filter') - other_filter = "({})".format(other_filter) if other_filter else '' + other_filter = "{}".format(other_filter) if other_filter else '' if custom['options'].get('ret') == 'cis': query = "_type:({}),{}".format(";".join(map(str, type_ids)), other_filter) diff --git a/cmdb-api/api/lib/cmdb/ci_type.py b/cmdb-api/api/lib/cmdb/ci_type.py index 83b6f3e..fb404a1 100644 --- a/cmdb-api/api/lib/cmdb/ci_type.py +++ b/cmdb-api/api/lib/cmdb/ci_type.py @@ -582,7 +582,8 @@ class CITypeRelationManager(object): def get_children(_id, level): children = CITypeRelation.get_by(parent_id=_id, to_dict=False) - result[level + 1] = [i.child.to_dict() for i in children] + if children: + result.setdefault(level + 1, []).extend([i.child.to_dict() for i in children]) for i in children: if i.child_id != _id: