Skip to content

Commit 22fe0aa

Browse files
[PLT-4135] Expose User.last_login_at in the Python SDK (#2070)
1 parent bd46a49 commit 22fe0aa

5 files changed

Lines changed: 11 additions & 1 deletion

File tree

libs/labelbox/src/labelbox/schema/issue.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ class IssueStatus(str, Enum):
3737
# ---------------------------------------------------------------------------
3838

3939
_USER_FIELDS = (
40-
"id email nickname name picture isViewer isExternalUser createdAt updatedAt"
40+
"id email nickname name picture isViewer isExternalUser "
41+
"createdAt updatedAt lastLoginAt"
4142
)
4243

4344
_COMMENT_FIELDS = (

libs/labelbox/src/labelbox/schema/user.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ class User(DbObject):
1414
Attributes:
1515
updated_at (datetime)
1616
created_at (datetime)
17+
last_login_at (datetime or None): When this user last established a
18+
session (login or workspace switch) in this organization. ``None``
19+
until the user logs in after last-login tracking was enabled.
1720
email (str)
1821
name (str)
1922
nickname (str)
@@ -28,6 +31,7 @@ class User(DbObject):
2831

2932
updated_at = Field.DateTime("updated_at")
3033
created_at = Field.DateTime("created_at")
34+
last_login_at = Field.DateTime("last_login_at")
3135
email = Field.String("email")
3236
name = Field.String("nickname")
3337
nickname = Field.String("name")

libs/labelbox/tests/integration/test_user_and_org.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ def test_user(client):
55
user = client.get_user()
66
assert user.uid is not None
77
assert user.organization() == client.get_organization()
8+
assert hasattr(user, "last_login_at")
9+
# Nullable: None until the user has logged in after tracking was enabled.
10+
assert user.last_login_at is None or hasattr(user.last_login_at, "year")
811

912

1013
def test_organization(client):

libs/labelbox/tests/unit/schema/test_issue.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"isExternalUser": False,
2424
"createdAt": _NOW,
2525
"updatedAt": _NOW,
26+
"lastLoginAt": _NOW,
2627
}
2728

2829
_COMMENT_RAW = {

libs/labelbox/tests/unit/schema/test_project_issues.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"isExternalUser": False,
3232
"createdAt": _NOW,
3333
"updatedAt": _NOW,
34+
"lastLoginAt": _NOW,
3435
}
3536

3637
_ISSUE_RAW = {

0 commit comments

Comments
 (0)