Skip to content

Commit

Permalink
优化CITypeCache的调用方式
Browse files Browse the repository at this point in the history
  • Loading branch information
thexqn committed Sep 14, 2024
1 parent ff98777 commit 131d213
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions cmdb-api/api/lib/cmdb/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,16 @@ def get_records_for_attributes(start, end, username, page, page_size, operate_ty
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']:
Expand Down

0 comments on commit 131d213

Please sign in to comment.