From d2be9d7247393badd3a835b083237cca99254de7 Mon Sep 17 00:00:00 2001 From: durant <826035498@qq.com> Date: Mon, 8 Jan 2024 16:53:34 +0800 Subject: [PATCH] =?UTF-8?q?fix(backend):=20=E4=BF=AE=E5=A4=8D=E8=BD=AE?= =?UTF-8?q?=E5=80=BC=E5=88=9B=E5=BB=BA=E6=97=B6=E5=8C=BA=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=20#2968=20#=20Reviewed,=20transacti?= =?UTF-8?q?on=20id:=201677?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dbm-ui/backend/db_monitor/models/alarm.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/dbm-ui/backend/db_monitor/models/alarm.py b/dbm-ui/backend/db_monitor/models/alarm.py index 397e23d0ce..b1299f172a 100644 --- a/dbm-ui/backend/db_monitor/models/alarm.py +++ b/dbm-ui/backend/db_monitor/models/alarm.py @@ -44,8 +44,6 @@ __all__ = ["NoticeGroup", "AlertRule", "RuleTemplate", "DispatchGroup", "MonitorPolicy", "DutyRule"] -from backend.utils.time import datetime2str - logger = logging.getLogger("root") @@ -107,7 +105,7 @@ def save_monitor_group(self) -> int: save_duty_rule_params = { "name": f"{self.name}_{self.bk_biz_id}", "bk_biz_id": env.DBA_APP_BK_BIZ_ID, - "effective_time": datetime2str(datetime.datetime.now(timezone.utc)), + "effective_time": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), "end_time": "", "labels": [self.db_type], "enabled": True, @@ -136,7 +134,7 @@ def save_monitor_group(self) -> int: .values_list("monitor_duty_rule_id", flat=True) ) save_monitor_group_params["need_duty"] = True - save_monitor_group_params["duty_rules"] = list(monitor_duty_rule_ids) + save_monitor_group_params["duty_rules"] = list(monitor_duty_rule_ids) + [self.monitor_duty_rule_id] else: save_monitor_group_params["duty_arranges"][0]["users"] = self.receivers @@ -226,8 +224,8 @@ def save(self, *args, **kwargs): params = { "name": f"{self.db_type}_{self.name}", "bk_biz_id": env.DBA_APP_BK_BIZ_ID, - "effective_time": datetime2str(self.effective_time), - "end_time": datetime2str(self.end_time) if self.end_time else "", + "effective_time": self.effective_time.strftime("%Y-%m-%d %H:%M:%S"), + "end_time": self.end_time.strftime("%Y-%m-%d %H:%M:%S") if self.end_time else "", "labels": [self.db_type], "enabled": self.is_enabled, "category": self.category,