Skip to content

Commit 4b9b23b

Browse files
committed
perf: update_last_active_by_id via single UPDATE
1 parent 9517efe commit 4b9b23b

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

backend/open_webui/models/users.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -588,18 +588,13 @@ def update_user_profile_image_url_by_id(
588588
return None
589589

590590
@throttle(DATABASE_USER_ACTIVE_STATUS_UPDATE_INTERVAL)
591-
def update_last_active_by_id(self, id: str, db: Optional[Session] = None) -> Optional[UserModel]:
591+
def update_last_active_by_id(self, id: str, db: Optional[Session] = None) -> None:
592592
try:
593593
with get_db_context(db) as db:
594-
user = db.query(User).filter_by(id=id).first()
595-
if not user:
596-
return None
597-
user.last_active_at = int(time.time())
594+
db.query(User).filter_by(id=id).update({'last_active_at': int(time.time())})
598595
db.commit()
599-
db.refresh(user)
600-
return UserModel.model_validate(user)
601596
except Exception:
602-
return None
597+
pass
603598

604599
def update_user_oauth_by_id(
605600
self, id: str, provider: str, sub: str, db: Optional[Session] = None

0 commit comments

Comments
 (0)