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
7552a6be
Unverified
Commit
7552a6be
authored
Jun 15, 2023
by
John Wang
Committed by
GitHub
Jun 15, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add last active at for accounts (#375)
parent
33200090
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
0 deletions
+38
-0
app.py
api/app.py
+5
-0
614f77cecc48_add_last_active_at.py
api/migrations/versions/614f77cecc48_add_last_active_at.py
+32
-0
account.py
api/models/account.py
+1
-0
No files found.
api/app.py
View file @
7552a6be
# -*- coding:utf-8 -*-
import
os
from
datetime
import
datetime
if
not
os
.
environ
.
get
(
"DEBUG"
)
or
os
.
environ
.
get
(
"DEBUG"
)
.
lower
()
!=
'true'
:
from
gevent
import
monkey
monkey
.
patch_all
()
...
...
@@ -122,6 +124,9 @@ def load_user(user_id):
account
.
current_tenant_id
=
tenant_account_join
.
tenant_id
session
[
'workspace_id'
]
=
account
.
current_tenant_id
account
.
last_active_at
=
datetime
.
utcnow
()
db
.
session
.
commit
()
# Log in the user with the updated user_id
flask_login
.
login_user
(
account
,
remember
=
True
)
...
...
api/migrations/versions/614f77cecc48_add_last_active_at.py
0 → 100644
View file @
7552a6be
"""add last active at
Revision ID: 614f77cecc48
Revises: a45f4dfde53b
Create Date: 2023-06-15 13:33:00.357467
"""
from
alembic
import
op
import
sqlalchemy
as
sa
# revision identifiers, used by Alembic.
revision
=
'614f77cecc48'
down_revision
=
'a45f4dfde53b'
branch_labels
=
None
depends_on
=
None
def
upgrade
():
# ### commands auto generated by Alembic - please adjust! ###
with
op
.
batch_alter_table
(
'accounts'
,
schema
=
None
)
as
batch_op
:
batch_op
.
add_column
(
sa
.
Column
(
'last_active_at'
,
sa
.
DateTime
(),
server_default
=
sa
.
text
(
'CURRENT_TIMESTAMP(0)'
),
nullable
=
False
))
# ### end Alembic commands ###
def
downgrade
():
# ### commands auto generated by Alembic - please adjust! ###
with
op
.
batch_alter_table
(
'accounts'
,
schema
=
None
)
as
batch_op
:
batch_op
.
drop_column
(
'last_active_at'
)
# ### end Alembic commands ###
api/models/account.py
View file @
7552a6be
...
...
@@ -32,6 +32,7 @@ class Account(UserMixin, db.Model):
timezone
=
db
.
Column
(
db
.
String
(
255
))
last_login_at
=
db
.
Column
(
db
.
DateTime
)
last_login_ip
=
db
.
Column
(
db
.
String
(
255
))
last_active_at
=
db
.
Column
(
db
.
DateTime
,
nullable
=
False
,
server_default
=
db
.
text
(
'CURRENT_TIMESTAMP(0)'
))
status
=
db
.
Column
(
db
.
String
(
16
),
nullable
=
False
,
server_default
=
db
.
text
(
"'active'::character varying"
))
initialized_at
=
db
.
Column
(
db
.
DateTime
)
created_at
=
db
.
Column
(
db
.
DateTime
,
nullable
=
False
,
server_default
=
db
.
text
(
'CURRENT_TIMESTAMP(0)'
))
...
...
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