Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/kili/core/graphql/operations/project_user/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ def __init__(
organization_id: Optional[str] = None,
status: Optional[Literal["ACTIVATED", "ORG_ADMIN", "ORG_SUSPENDED"]] = None,
active_in_project: Optional[bool] = None,
deleted: Optional[bool] = None,
) -> None:
self.project_id = project_id
self.email = email
self._id = _id
self.organization_id = organization_id
self.status = status
self.active_in_project = active_in_project # user not deleted and nbr of labeled assets > 0
self.deleted = deleted
super().__init__()

def graphql_where_builder(self):
Expand All @@ -32,6 +34,7 @@ def graphql_where_builder(self):
"id": self._id,
"status": self.status,
"activeInProject": self.active_in_project,
"deleted": self.deleted,
"project": {
"id": self.project_id,
},
Expand Down
5 changes: 5 additions & 0 deletions src/kili/entrypoints/queries/project_user/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def project_users(
status_in: Optional[Sequence[Literal["ACTIVATED", "ORG_ADMIN", "ORG_SUSPENDED"]]] = (
"ACTIVATED",
"ORG_ADMIN",
"ORG_SUSPENDED",
),
fields: ListOrTuple[str] = (
"activated",
Expand Down Expand Up @@ -143,6 +144,7 @@ def project_users(
fields = [*fields, "status"]

where = ProjectUserWhere(
deleted=False,
project_id=project_id,
email=email,
_id=id,
Expand Down Expand Up @@ -176,6 +178,7 @@ def count_project_users(
status_in: Optional[Sequence[Literal["ACTIVATED", "ORG_ADMIN", "ORG_SUSPENDED"]]] = (
"ACTIVATED",
"ORG_ADMIN",
"ORG_SUSPENDED",
),
) -> int:
"""Count the number of projects and their users that match a set of criteria.
Expand All @@ -196,6 +199,7 @@ def count_project_users(
"""
if status_in is None:
where = ProjectUserWhere(
deleted=False,
project_id=project_id,
email=email,
_id=id,
Expand All @@ -206,6 +210,7 @@ def count_project_users(
count = 0
for status in set(status_in):
where = ProjectUserWhere(
deleted=False,
project_id=project_id,
email=email,
_id=id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def test_project_users_query(mocker: pytest_mock.MockFixture):
assert "query projectUsers" in query
assert variables == {
"where": {
"deleted": False,
"id": None,
"status": None,
"activeInProject": None,
Expand Down