From 0e51bae003bd077d5d20368df5c642e684d99473 Mon Sep 17 00:00:00 2001 From: nero Date: Mon, 13 Nov 2023 17:43:04 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20cr=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bk-user/bkuser/apis/web/tenant_setting/serializers.py | 2 +- src/bk-user/bkuser/apps/tenant/notifier.py | 3 +-- src/bk-user/bkuser/apps/tenant/tasks.py | 5 ----- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/bk-user/bkuser/apis/web/tenant_setting/serializers.py b/src/bk-user/bkuser/apis/web/tenant_setting/serializers.py index 974b40775..71d921bd5 100644 --- a/src/bk-user/bkuser/apis/web/tenant_setting/serializers.py +++ b/src/bk-user/bkuser/apis/web/tenant_setting/serializers.py @@ -177,7 +177,7 @@ class NotificationTemplatesInputSLZ(serializers.Serializer): class TenantUserValidityPeriodConfigInputSLZ(serializers.Serializer): enabled = serializers.BooleanField(help_text="是否启用账户有效期") validity_period = serializers.IntegerField(help_text="账户有效期,单位:天") - remind_before_expire = serializers.ListField(help_text="临过期提醒时间") + remind_before_expire = serializers.ListField(help_text="临过期提醒时间", child=serializers.IntegerField()) enabled_notification_methods = serializers.ListField( help_text="通知方式", child=serializers.ChoiceField(choices=NotificationMethod.get_choices()), diff --git a/src/bk-user/bkuser/apps/tenant/notifier.py b/src/bk-user/bkuser/apps/tenant/notifier.py index 631193ad7..714be22c0 100644 --- a/src/bk-user/bkuser/apps/tenant/notifier.py +++ b/src/bk-user/bkuser/apps/tenant/notifier.py @@ -99,10 +99,9 @@ def send(self, users: List[TenantUser]) -> None: # TODO 细化异常处理 except Exception: logger.exception( - "send notification failed, tenant: %s, scene:%s, tenant_user_id: %s", + "send notification failed, tenant: %s, scene: %s", self.tenant_id, self.scene, - u.id, ) def _get_templates_with_scene(self, scene: NotificationScene) -> List[NotificationTemplate]: diff --git a/src/bk-user/bkuser/apps/tenant/tasks.py b/src/bk-user/bkuser/apps/tenant/tasks.py index c23d36e56..2dd34d2a2 100644 --- a/src/bk-user/bkuser/apps/tenant/tasks.py +++ b/src/bk-user/bkuser/apps/tenant/tasks.py @@ -50,11 +50,6 @@ def notify_expiring_tenant_user(): for item in tenant_remind_before_expire_list: tenant_id, remind_before_expire = item["tenant_id"], item["remind_before_expire"] - # DateTimeField 使用__date__xx的orm查询,orm会将相应字段的进行转换时区. - # mysql 数据库需要加载系统的时区表, 可以通过下面的sql,来确认是否加载了 - # SELECT CONVERT_TZ("2023-11-18 06:38:32.000000", 'UTC', 'Asia/Shanghai') - # https://docs.djangoproject.com/en/3.2/ref/models/querysets/#database-time-zone-definitions - # https://dev.mysql.com/doc/refman/8.2/en/mysql-tzinfo-to-sql.html tenant_users = TenantUser.objects.filter(account_expired_at__date__gt=now.date(), tenant_id=tenant_id) # 临1/7/15天过期 条件设置, 每个租户的设置都不一样