Skip to content

Commit

Permalink
refactor: cr调整
Browse files Browse the repository at this point in the history
  • Loading branch information
neronkl committed Nov 13, 2023
1 parent f5c097c commit 0e51bae
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/bk-user/bkuser/apis/web/tenant_setting/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
3 changes: 1 addition & 2 deletions src/bk-user/bkuser/apps/tenant/notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
5 changes: 0 additions & 5 deletions src/bk-user/bkuser/apps/tenant/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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天过期 条件设置, 每个租户的设置都不一样
Expand Down

0 comments on commit 0e51bae

Please sign in to comment.