From 131d213a730c494ee3258db5456b0c02c5d3c6fb Mon Sep 17 00:00:00 2001 From: thexqn Date: Sat, 14 Sep 2024 11:30:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96CITypeCache=E7=9A=84=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmdb-api/api/lib/cmdb/history.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cmdb-api/api/lib/cmdb/history.py b/cmdb-api/api/lib/cmdb/history.py index 1aa0cff..08bc5df 100644 --- a/cmdb-api/api/lib/cmdb/history.py +++ b/cmdb-api/api/lib/cmdb/history.py @@ -68,14 +68,16 @@ class AttributeHistoryManger(object): type_id = record.OperationRecord.type_id ci_id = record.AttributeHistory.ci_id show_attr_set[ci_id] = None - - ci_type = CITypeCache.get(type_id) - if ci_type: - show_attr = show_attr_cache.setdefault(type_id, AttributeCache.get(ci_type.show_id or ci_type.unique_id)) + show_attr = show_attr_cache.setdefault( + type_id, + AttributeCache.get( + CITypeCache.get(type_id).show_id or CITypeCache.get(type_id).unique_id) if CITypeCache.get(type_id) else None + ) + if show_attr: attr_table = TableMap(attr=show_attr).table attr_record = attr_table.get_by(attr_id=show_attr.id, ci_id=ci_id, first=True, to_dict=False) show_attr_set[ci_id] = attr_record.value if attr_record else None - + attr_hist = record.AttributeHistory.to_dict() attr_hist['attr'] = AttributeCache.get(attr_hist['attr_id']) if attr_hist['attr']: