Skip to content

Commit 1600db7

Browse files
author
Josselin BUILS
committed
fix(LAB-3967): fix count_project_users criteria
It now excludes deleted users, but include deactivated users by default.
1 parent 1e3477e commit 1600db7

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

src/kili/core/graphql/operations/project_user/queries.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ def __init__(
1717
organization_id: Optional[str] = None,
1818
status: Optional[Literal["ACTIVATED", "ORG_ADMIN", "ORG_SUSPENDED"]] = None,
1919
active_in_project: Optional[bool] = None,
20+
deleted: Optional[bool] = None,
2021
) -> None:
2122
self.project_id = project_id
2223
self.email = email
2324
self._id = _id
2425
self.organization_id = organization_id
2526
self.status = status
2627
self.active_in_project = active_in_project # user not deleted and nbr of labeled assets > 0
28+
self.deleted = deleted
2729
super().__init__()
2830

2931
def graphql_where_builder(self):
@@ -32,6 +34,7 @@ def graphql_where_builder(self):
3234
"id": self._id,
3335
"status": self.status,
3436
"activeInProject": self.active_in_project,
37+
"deleted": self.deleted,
3538
"project": {
3639
"id": self.project_id,
3740
},

src/kili/entrypoints/queries/project_user/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ def count_project_users(
176176
status_in: Optional[Sequence[Literal["ACTIVATED", "ORG_ADMIN", "ORG_SUSPENDED"]]] = (
177177
"ACTIVATED",
178178
"ORG_ADMIN",
179+
"ORG_SUSPENDED",
179180
),
180181
) -> int:
181182
"""Count the number of projects and their users that match a set of criteria.
@@ -196,6 +197,7 @@ def count_project_users(
196197
"""
197198
if status_in is None:
198199
where = ProjectUserWhere(
200+
deleted=False,
199201
project_id=project_id,
200202
email=email,
201203
_id=id,
@@ -206,6 +208,7 @@ def count_project_users(
206208
count = 0
207209
for status in set(status_in):
208210
where = ProjectUserWhere(
211+
deleted=False,
209212
project_id=project_id,
210213
email=email,
211214
_id=id,

tests/integration/entrypoints/client/queries/test_project_users_queries.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def test_project_users_query(mocker: pytest_mock.MockFixture):
1515
assert "query projectUsers" in query
1616
assert variables == {
1717
"where": {
18+
"deleted": None,
1819
"id": None,
1920
"status": None,
2021
"activeInProject": None,

0 commit comments

Comments
 (0)