refac: is_user_active

This commit is contained in:
Timothy Jaeryang Baek
2026-02-13 13:40:59 -06:00
parent 97a3b1528d
commit ca6b18ab5c
2 changed files with 12 additions and 4 deletions
+8
View File
@@ -762,6 +762,14 @@ class UsersTable:
)
return count
@staticmethod
def is_active(user: UserModel) -> bool:
"""Compute active status from an already-loaded UserModel (no DB hit)."""
if user.last_active_at:
three_minutes_ago = int(time.time()) - 180
return user.last_active_at >= three_minutes_ago
return False
def is_user_active(self, user_id: str, db: Optional[Session] = None) -> bool:
with get_db_context(db) as db:
user = db.query(User).filter_by(id=user_id).first()