优化CITypeCache的调用方式

This commit is contained in:
thexqn 2024-09-14 11:30:45 +08:00
parent ff98777689
commit 131d213a73
1 changed files with 7 additions and 5 deletions

View File

@ -68,10 +68,12 @@ class AttributeHistoryManger(object):
type_id = record.OperationRecord.type_id type_id = record.OperationRecord.type_id
ci_id = record.AttributeHistory.ci_id ci_id = record.AttributeHistory.ci_id
show_attr_set[ci_id] = None show_attr_set[ci_id] = None
show_attr = show_attr_cache.setdefault(
ci_type = CITypeCache.get(type_id) type_id,
if ci_type: AttributeCache.get(
show_attr = show_attr_cache.setdefault(type_id, AttributeCache.get(ci_type.show_id or ci_type.unique_id)) 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_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) 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 show_attr_set[ci_id] = attr_record.value if attr_record else None