Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(db): error when counting online users in mysql #1453

Merged
merged 1 commit into from
Nov 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/db/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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()