ソースを参照

feat: optimize last_active_at update (#1083)

tags/0.3.20
takatost 2年前
コミット
48eb590065
コミッターのメールアドレスに関連付けられたアカウントが存在しません
1個のファイルの変更7行の追加3行の削除
  1. 7
    3
      api/app.py

+ 7
- 3
api/app.py ファイルの表示

# -*- coding:utf-8 -*- # -*- coding:utf-8 -*-
import os import os
from datetime import datetime
from datetime import datetime, timedelta


from werkzeug.exceptions import Forbidden from werkzeug.exceptions import Forbidden


_create_tenant_for_account(account) _create_tenant_for_account(account)
session['workspace_id'] = account.current_tenant_id session['workspace_id'] = account.current_tenant_id


account.last_active_at = datetime.utcnow()
db.session.commit()
current_time = datetime.utcnow()

# update last_active_at when last_active_at is more than 10 minutes ago
if current_time - account.last_active_at > timedelta(minutes=10):
account.last_active_at = current_time
db.session.commit()


# Log in the user with the updated user_id # Log in the user with the updated user_id
flask_login.login_user(account, remember=True) flask_login.login_user(account, remember=True)

読み込み中…
キャンセル
保存