From 6df845d6621e748ad310aa713184a2642a1b7513 Mon Sep 17 00:00:00 2001 From: pycook Date: Wed, 30 Aug 2023 13:34:10 +0800 Subject: [PATCH] fix update attribute --- cmdb-api/api/lib/cmdb/attribute.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmdb-api/api/lib/cmdb/attribute.py b/cmdb-api/api/lib/cmdb/attribute.py index 4a8e265..d812201 100644 --- a/cmdb-api/api/lib/cmdb/attribute.py +++ b/cmdb-api/api/lib/cmdb/attribute.py @@ -8,6 +8,7 @@ from flask_login import current_user from api.extensions import db from api.lib.cmdb.cache import AttributeCache +from api.lib.cmdb.cache import CITypeAttributesCache from api.lib.cmdb.cache import CITypeCache from api.lib.cmdb.const import CITypeOperateType from api.lib.cmdb.const import PermEnum, ResourceTypeEnum, RoleEnum @@ -213,7 +214,11 @@ class AttributeManager(object): return attr.id @staticmethod - def _change_index(attr, old, new): + def _clean_ci_type_attributes_cache(attr_id): + for i in CITypeAttribute.get_by(attr_id=attr_id, to_dict=False): + CITypeAttributesCache.clean(i.type_id) + + def _change_index(self, attr, old, new): from api.lib.cmdb.utils import TableMap from api.tasks.cmdb import batch_ci_cache from api.lib.cmdb.const import CMDB_QUEUE @@ -310,6 +315,8 @@ class AttributeManager(object): AttributeCache.clean(attr) + self._clean_ci_type_attributes_cache(_id) + return attr.id @staticmethod