From 9cc3ffb4a937334591bc873f29486a7856fad01c Mon Sep 17 00:00:00 2001 From: Algorithm5838 <108630393+Algorithm5838@users.noreply.github.com> Date: Mon, 30 Mar 2026 12:14:33 +0300 Subject: [PATCH] perf: update_last_active_by_id via single UPDATE (#23215) --- backend/open_webui/models/users.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/backend/open_webui/models/users.py b/backend/open_webui/models/users.py index 7007e529d5..ef90745efe 100644 --- a/backend/open_webui/models/users.py +++ b/backend/open_webui/models/users.py @@ -588,18 +588,13 @@ class UsersTable: return None @throttle(DATABASE_USER_ACTIVE_STATUS_UPDATE_INTERVAL) - def update_last_active_by_id(self, id: str, db: Optional[Session] = None) -> Optional[UserModel]: + def update_last_active_by_id(self, id: str, db: Optional[Session] = None) -> None: try: with get_db_context(db) as db: - user = db.query(User).filter_by(id=id).first() - if not user: - return None - user.last_active_at = int(time.time()) + db.query(User).filter_by(id=id).update({'last_active_at': int(time.time())}) db.commit() - db.refresh(user) - return UserModel.model_validate(user) except Exception: - return None + pass def update_user_oauth_by_id( self, id: str, provider: str, sub: str, db: Optional[Session] = None