Skip to content

Commit

Permalink
perf(backend): 优化进程启动速度 TencentBlueKing#7809
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzhw8 authored and iSecloud committed Nov 7, 2024
1 parent 4a5de3d commit 065f716
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions dbm-ui/backend/db_meta/models/db_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,22 @@ def get_choices_with_filter(cls, cluster_type=None):
if cluster_type:
q = Q(cluster_type=cluster_type)

# logger.info("get db module choices with filter: {}".format(q))

db_module_choices = []
appcache_dict = AppCache.get_appcache(key="appcache_dict")

for dm in cls.objects.filter(q).all():

try:
appcache_dict = AppCache.get_appcache(key="appcache_dict")
appcache = appcache_dict.get(str(dm.bk_biz_id))
db_module_choices.append(
(
dm.db_module_id,
f"[{dm.db_module_id}]-"
f"[{dm.cluster_type}]-[app:{appcache['db_app_abbr']}]-"
f"{dm.db_module_name}",
)
appcache = appcache_dict.get(str(dm.bk_biz_id))
db_module_choices.append(
(
dm.db_module_id,
f"[{dm.db_module_id}]-"
f"[{dm.cluster_type}]-[app:{appcache['db_app_abbr']}]-"
f"{dm.db_module_name}",
)
except AppCache.DoesNotExist:
continue
)

except Exception: # pylint: disable=broad-except
except Exception as err: # pylint: disable=broad-except
# 忽略出现的异常,此时可能因为表未初始化
logger.exception("DBModule get_choices_with_filter error, {}".format(err))
db_module_choices = []
return db_module_choices

0 comments on commit 065f716

Please sign in to comment.