From 584ce0afe3bb6f09dceb7c6a3defaa0234b03eb3 Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 21 Sep 2022 13:42:12 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BF=AE=E6=94=B9=E8=BF=81=E7=A7=BB?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/migrations/0097_auto_20220426_1558.py | 9 ++++----- apps/audits/utils.py | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/apps/assets/migrations/0097_auto_20220426_1558.py b/apps/assets/migrations/0097_auto_20220426_1558.py index 02cbda4ce..ed645cc57 100644 --- a/apps/assets/migrations/0097_auto_20220426_1558.py +++ b/apps/assets/migrations/0097_auto_20220426_1558.py @@ -55,7 +55,7 @@ def migrate_database_to_asset(apps, *args): attrs.update(_attrs) db = db_model( - id=app.id, hostname=app.name, ip=attrs['host'], + id=app.id, hostname=app.name, address=attrs['host'], protocols='{}/{}'.format(app.type, attrs['port']), db_name=attrs['database'] or '', platform=platforms_map[app.type], @@ -82,11 +82,10 @@ def migrate_cloud_to_asset(apps, *args): attrs = app.attrs print("Create cloud: {}".format(app.name)) cloud = cloud_model( - id=app.id, hostname=app.name, ip='', - protocols='', - platform=platform, + id=app.id, hostname=app.name, + address=attrs.get('cluster', ''), + protocols='', platform=platform, org_id=app.org_id, - url=attrs.get('cluster', '') ) try: diff --git a/apps/audits/utils.py b/apps/audits/utils.py index f635652f2..1fadbccee 100644 --- a/apps/audits/utils.py +++ b/apps/audits/utils.py @@ -36,13 +36,13 @@ def write_content_to_excel(response, header=None, login_logs=None, fields=None): def write_login_log(*args, **kwargs): from audits.models import UserLoginLog - ip = kwargs.get('address') or '' + ip = kwargs.get('ip') or '' if not (ip and validate_ip(ip)): ip = ip[:15] city = DEFAULT_CITY else: city = get_ip_city(ip) or DEFAULT_CITY - kwargs.update({'address': ip, 'city': city}) + kwargs.update({'ip': ip, 'city': city}) UserLoginLog.objects.create(**kwargs)