Skip to content

Commit

Permalink
fix(backend): 修复轮值创建时区报错的问题 #2968
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 1677
  • Loading branch information
zhangzhw8 committed Jan 9, 2024
1 parent cf5dfdb commit d2be9d7
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions dbm-ui/backend/db_monitor/models/alarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@

__all__ = ["NoticeGroup", "AlertRule", "RuleTemplate", "DispatchGroup", "MonitorPolicy", "DutyRule"]

from backend.utils.time import datetime2str

logger = logging.getLogger("root")


Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit d2be9d7

Please sign in to comment.