Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
48eb5900
Unverified
Commit
48eb5900
authored
Sep 01, 2023
by
takatost
Committed by
GitHub
Sep 01, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: optimize last_active_at update (#1083)
parent
33562a9d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
app.py
api/app.py
+7
-3
No files found.
api/app.py
View file @
48eb5900
# -*- 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
...
@@ -145,8 +145,12 @@ def load_user(user_id):
...
@@ -145,8 +145,12 @@ def load_user(user_id):
_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
()
current_time
=
datetime
.
utcnow
()
db
.
session
.
commit
()
# 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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment