perf: user login filter filter_long_time

This commit is contained in:
feng
2026-06-22 16:22:08 +08:00
parent 36b3f8e8e2
commit 42b522b2b0
10 changed files with 36 additions and 22 deletions

View File

@@ -1775,5 +1775,7 @@
"SdkScriptLoadFailed": "SDK script load failed, please check network or driver service",
"SdkStatus": "SDK Status",
"OperationUnavailableWhenMismatch": "No available actions because Ukey does not match the user",
"InfoHiddenWhenMismatch": "Certificate information is hidden because Ukey does not match the user"
"InfoHiddenWhenMismatch": "Certificate information is hidden because Ukey does not match the user",
"Days": "day",
"NotLoggedInForMoreThan": "Not logged in for more than"
}

View File

@@ -1697,5 +1697,7 @@
"ReportRecipientsTip": "Actualmente solo admite envío por correo electrónico",
"ReportSchedulePriorityTip": "Si se establecen tanto el intervalo como el crontab, el crontab tiene prioridad",
"FooterContentTooLong200": "El contenido del pie de página no debe exceder los 200 caracteres",
"ImageFileCorruptedOrUnreadable": "El archivo de imagen está dañado o no se puede leer. Verifica el archivo y vuelve a intentarlo."
"ImageFileCorruptedOrUnreadable": "El archivo de imagen está dañado o no se puede leer. Verifica el archivo y vuelve a intentarlo.",
"Days": "días",
"NotLoggedInForMoreThan": "No ha iniciado sesión durante más de"
}

View File

@@ -1702,5 +1702,7 @@
"ReportRecipientsTip": "現在はメール送信のみ対応しています",
"ReportSchedulePriorityTip": "interval と crontab の両方が設定されている場合、crontab が優先されます",
"FooterContentTooLong200": "フッターの内容は200文字を超えることはできません。",
"ImageFileCorruptedOrUnreadable": "画像ファイルが破損しているか、読み取れません。ファイルを確認して、もう一度お試しください。"
"ImageFileCorruptedOrUnreadable": "画像ファイルが破損しているか、読み取れません。ファイルを確認して、もう一度お試しください。",
"Days": "空",
"NotLoggedInForMoreThan": "ログインしていない日数が"
}

View File

@@ -1697,5 +1697,7 @@
"ReportRecipientsTip": "현재 이메일 전송만 지원합니다",
"ReportSchedulePriorityTip": "interval 과 crontab 이 모두 설정된 경우 crontab 이 우선합니다",
"FooterContentTooLong200": "바닥글 내용은 200자를 초과할 수 없습니다.",
"ImageFileCorruptedOrUnreadable": "이미지 파일이 손상되었거나 읽을 수 없습니다. 파일을 확인한 후 다시 시도해 주세요."
"ImageFileCorruptedOrUnreadable": "이미지 파일이 손상되었거나 읽을 수 없습니다. 파일을 확인한 후 다시 시도해 주세요.",
"Days": "일 이상",
"NotLoggedInForMoreThan": "로그인하지 않은 지"
}

View File

@@ -1698,5 +1698,7 @@
"ReportRecipientsTip": "Atualmente suporta apenas envio por e-mail",
"ReportSchedulePriorityTip": "Se ambos, intervalo e crontab, estiverem definidos, o crontab terá prioridade",
"FooterContentTooLong200": "O conteúdo do rodapé não pode exceder 200 caracteres.",
"ImageFileCorruptedOrUnreadable": "O arquivo de imagem está corrompido ou não pode ser lido. Verifique o arquivo e tente novamente."
"ImageFileCorruptedOrUnreadable": "O arquivo de imagem está corrompido ou não pode ser lido. Verifique o arquivo e tente novamente.",
"Days": "dias",
"NotLoggedInForMoreThan": "Não fez login por mais de"
}

View File

@@ -1697,5 +1697,7 @@
"ReportRecipientsTip": "В настоящее время поддерживается только отправка по электронной почте",
"ReportSchedulePriorityTip": "Если установлены и интервал, и crontab, приоритет отдается crontab",
"FooterContentTooLong200": "Содержание нижнего колонтитула не может превышать 200 символов",
"ImageFileCorruptedOrUnreadable": "Файл изображения повреждён или не может быть прочитан. Пожалуйста, проверьте файл и попробуйте снова."
"ImageFileCorruptedOrUnreadable": "Файл изображения повреждён или не может быть прочитан. Пожалуйста, проверьте файл и попробуйте снова.",
"Days": "дней",
"NotLoggedInForMoreThan": "Не входил более"
}

View File

@@ -1697,5 +1697,7 @@
"ReportRecipientsTip": "Hiện tại chỉ hỗ trợ gửi qua email",
"ReportSchedulePriorityTip": "Nếu cả interval và crontab đều được đặt, crontab sẽ được ưu tiên",
"FooterContentTooLong200": "Nội dung chân trang quá dài, vui lòng nhập nội dung dưới 200 ký tự",
"ImageFileCorruptedOrUnreadable": "Tệp hình ảnh đã bị hỏng hoặc không thể đọc được. Vui lòng kiểm tra tệp và thử lại."
"ImageFileCorruptedOrUnreadable": "Tệp hình ảnh đã bị hỏng hoặc không thể đọc được. Vui lòng kiểm tra tệp và thử lại.",
"Days": "ngày",
"NotLoggedInForMoreThan": "Không đăng nhập quá"
}

View File

@@ -1786,5 +1786,7 @@
"SdkScriptLoadFailed": "驱动脚本加载失败,请检查网络或驱动服务",
"SdkStatus": "SDK 状态",
"OperationUnavailableWhenMismatch": "Ukey 与用户不匹配没有操作可用",
"InfoHiddenWhenMismatch": "Ukey 与用户不匹配不显示证书信息"
"InfoHiddenWhenMismatch": "Ukey 与用户不匹配不显示证书信息",
"Days": "天",
"NotLoggedInForMoreThan": "未登录超过"
}

View File

@@ -1747,5 +1747,7 @@
"SdkScriptLoadFailed": "驅動腳本載入失敗,請檢查網路或驅動服務",
"SdkStatus": "SDK 狀態",
"OperationUnavailableWhenMismatch": "因為 Ukey 與用戶不匹配,無可用操作",
"InfoHiddenWhenMismatch": "因為 Ukey 與用戶不匹配,證書資訊被隱藏"
"InfoHiddenWhenMismatch": "因為 Ukey 與用戶不匹配,證書資訊被隱藏",
"Days": "天",
"NotLoggedInForMoreThan": "未登入超過"
}

View File

@@ -71,20 +71,16 @@ class UserFilter(BaseFilterSet):
return queryset.filter(q)
def filter_long_time(self, queryset, name, value):
now = timezone.now()
interval = 30
date_expired = now - timezone.timedelta(days=int(interval))
if name == 'is_long_time_no_login':
key = 'last_login'
else:
raise ValueError('Invalid filter name')
if not value:
return queryset
if value:
kwargs = {f'{key}__lt': date_expired}
else:
kwargs = {f'{key}__gt': date_expired}
q = Q(**kwargs) | Q(**{f'{key}__isnull': True})
return queryset.filter(q)
no_login_days = self.request.GET.get('no_login_days', 30)
cutoff_time = timezone.now() - timezone.timedelta(days=int(no_login_days))
return queryset.filter(
Q(last_login__lt=cutoff_time) |
Q(last_login__isnull=True)
)
def filter_is_valid(self, queryset, name, value):
if value: