Skip to content

Commit b9c94b5

Browse files
Merge pull request #318 from supertokens/functionSignatureUpdate
feat: added query support to get_users_newest_first and get_users_oldest_first
2 parents e89ae1d + 5eea4b9 commit b9c94b5

File tree

6 files changed

+42
-8
lines changed

6 files changed

+42
-8
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## unreleased
99

10+
11+
## [0.12.9] - 2023-04-28
12+
13+
- Added missing arguments in `get_users_newest_first` and `get_users_oldest_first`
14+
1015
## [0.12.8] - 2023-04-19
1116

1217
- Fixed an issues that threw 500 when changing password for user from dashboard

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070

7171
setup(
7272
name="supertokens_python",
73-
version="0.12.8",
73+
version="0.12.9",
7474
author="SuperTokens",
7575
license="Apache 2.0",
7676
author_email="[email protected]",

supertokens_python/asyncio/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
14-
from typing import List, Union, Optional
14+
from typing import List, Union, Optional, Dict
1515

1616
from supertokens_python import Supertokens
1717
from supertokens_python.interfaces import (
@@ -31,19 +31,21 @@ async def get_users_oldest_first(
3131
limit: Union[int, None] = None,
3232
pagination_token: Union[str, None] = None,
3333
include_recipe_ids: Union[None, List[str]] = None,
34+
query: Union[None, Dict[str, str]] = None,
3435
) -> UsersResponse:
3536
return await Supertokens.get_instance().get_users(
36-
"ASC", limit, pagination_token, include_recipe_ids
37+
"ASC", limit, pagination_token, include_recipe_ids, query
3738
)
3839

3940

4041
async def get_users_newest_first(
4142
limit: Union[int, None] = None,
4243
pagination_token: Union[str, None] = None,
4344
include_recipe_ids: Union[None, List[str]] = None,
45+
query: Union[None, Dict[str, str]] = None,
4446
) -> UsersResponse:
4547
return await Supertokens.get_instance().get_users(
46-
"DESC", limit, pagination_token, include_recipe_ids
48+
"DESC", limit, pagination_token, include_recipe_ids, query
4749
)
4850

4951

supertokens_python/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"2.19",
2626
"2.20",
2727
]
28-
VERSION = "0.12.8"
28+
VERSION = "0.12.9"
2929
TELEMETRY = "/telemetry"
3030
USER_COUNT = "/users/count"
3131
USER_DELETE = "/user/remove"

supertokens_python/syncio/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
14-
from typing import List, Union, Optional
14+
from typing import List, Union, Optional, Dict
1515

1616
from supertokens_python import Supertokens
1717
from supertokens_python.async_to_sync_wrapper import sync
@@ -32,10 +32,11 @@ def get_users_oldest_first(
3232
limit: Union[int, None] = None,
3333
pagination_token: Union[str, None] = None,
3434
include_recipe_ids: Union[None, List[str]] = None,
35+
query: Union[None, Dict[str, str]] = None,
3536
) -> UsersResponse:
3637
return sync(
3738
Supertokens.get_instance().get_users(
38-
"ASC", limit, pagination_token, include_recipe_ids
39+
"ASC", limit, pagination_token, include_recipe_ids, query
3940
)
4041
)
4142

@@ -44,10 +45,11 @@ def get_users_newest_first(
4445
limit: Union[int, None] = None,
4546
pagination_token: Union[str, None] = None,
4647
include_recipe_ids: Union[None, List[str]] = None,
48+
query: Union[None, Dict[str, str]] = None,
4749
) -> UsersResponse:
4850
return sync(
4951
Supertokens.get_instance().get_users(
50-
"DESC", limit, pagination_token, include_recipe_ids
52+
"DESC", limit, pagination_token, include_recipe_ids, query
5153
)
5254
)
5355

tests/supertokens_python/test_supertokens_functions.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,28 @@ async def test_supertokens_functions():
8989
users_asc = (await st_asyncio.get_users_oldest_first(limit=10)).users
9090
emails_asc = [user.email for user in users_asc]
9191
assert emails[1] not in emails_asc # The 2nd user must be deleted now.
92+
93+
if not is_version_gte(version, "2.20"):
94+
# If the version is less than 2.20, query users doesn't exist, so we mark the test successful
95+
return
96+
users_asc = (
97+
await st_asyncio.get_users_oldest_first(limit=10, query={"email": "baz"})
98+
).users
99+
users_desc = (
100+
await st_asyncio.get_users_newest_first(limit=10, query={"email": "baz"})
101+
).users
102+
emails_asc = [user.email for user in users_asc]
103+
emails_desc = [user.email for user in users_desc]
104+
assert len(emails_asc) == 1
105+
assert len(emails_desc) == 1
106+
107+
users_asc = (
108+
await st_asyncio.get_users_oldest_first(limit=10, query={"email": "john"})
109+
).users
110+
users_desc = (
111+
await st_asyncio.get_users_newest_first(limit=10, query={"email": "john"})
112+
).users
113+
emails_asc = [user.email for user in users_asc]
114+
emails_desc = [user.email for user in users_desc]
115+
assert len(emails_asc) == 0
116+
assert len(emails_desc) == 0

0 commit comments

Comments
 (0)