From 924f509c1c83c582f4f1b1030054065f5863ed5e Mon Sep 17 00:00:00 2001 From: Mohammad Date: Sun, 24 Nov 2024 10:09:31 +0330 Subject: [PATCH] fix(db): error when counting online users in mysql --- app/db/crud.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/db/crud.py b/app/db/crud.py index 939f19e48..7490cec1a 100644 --- a/app/db/crud.py +++ b/app/db/crud.py @@ -26,7 +26,7 @@ System, User, UserTemplate, - UserUsageResetLogs + UserUsageResetLogs, ) from app.models.admin import AdminCreate, AdminModify, AdminPartialModify from app.models.node import NodeCreate, NodeModify, NodeStatus, NodeUsageResponse @@ -38,7 +38,7 @@ UserModify, UserResponse, UserStatus, - UserUsageResponse + UserUsageResponse, ) from app.models.user_template import UserTemplateCreate, UserTemplateModify from app.utils.helpers import calculate_expiration_days, calculate_usage_percent @@ -1485,5 +1485,5 @@ def delete_notification_reminder(db: Session, dbreminder: NotificationReminder) def count_online_users(db: Session, hours: int = 24): twenty_four_hours_ago = datetime.utcnow() - timedelta(hours=hours) query = db.query(func.count(User.id)).filter(User.online_at.isnot( - None), func.datetime(User.online_at) >= twenty_four_hours_ago) + None), User.online_at >= twenty_four_hours_ago) return query.scalar()