Skip to content

feat: added query support to get_users_newest_first and get_users_oldest_first #318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 28, 2023
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## unreleased


## [0.12.9] - 2023-04-28

- Added missing arguments in `get_users_newest_first` and `get_users_oldest_first`

## [0.12.8] - 2023-04-19

- Fixed an issues that threw 500 when changing password for user from dashboard
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@

setup(
name="supertokens_python",
version="0.12.8",
version="0.12.9",
author="SuperTokens",
license="Apache 2.0",
author_email="[email protected]",
Expand Down
8 changes: 5 additions & 3 deletions supertokens_python/asyncio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from typing import List, Union, Optional
from typing import List, Union, Optional, Dict

from supertokens_python import Supertokens
from supertokens_python.interfaces import (
Expand All @@ -31,19 +31,21 @@ async def get_users_oldest_first(
limit: Union[int, None] = None,
pagination_token: Union[str, None] = None,
include_recipe_ids: Union[None, List[str]] = None,
query: Union[None, Dict[str, str]] = None,
) -> UsersResponse:
return await Supertokens.get_instance().get_users(
"ASC", limit, pagination_token, include_recipe_ids
"ASC", limit, pagination_token, include_recipe_ids, query
)


async def get_users_newest_first(
limit: Union[int, None] = None,
pagination_token: Union[str, None] = None,
include_recipe_ids: Union[None, List[str]] = None,
query: Union[None, Dict[str, str]] = None,
) -> UsersResponse:
return await Supertokens.get_instance().get_users(
"DESC", limit, pagination_token, include_recipe_ids
"DESC", limit, pagination_token, include_recipe_ids, query
)


Expand Down
2 changes: 1 addition & 1 deletion supertokens_python/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"2.19",
"2.20",
]
VERSION = "0.12.8"
VERSION = "0.12.9"
TELEMETRY = "/telemetry"
USER_COUNT = "/users/count"
USER_DELETE = "/user/remove"
Expand Down
8 changes: 5 additions & 3 deletions supertokens_python/syncio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from typing import List, Union, Optional
from typing import List, Union, Optional, Dict

from supertokens_python import Supertokens
from supertokens_python.async_to_sync_wrapper import sync
Expand All @@ -32,10 +32,11 @@ def get_users_oldest_first(
limit: Union[int, None] = None,
pagination_token: Union[str, None] = None,
include_recipe_ids: Union[None, List[str]] = None,
query: Union[None, Dict[str, str]] = None,
) -> UsersResponse:
return sync(
Supertokens.get_instance().get_users(
"ASC", limit, pagination_token, include_recipe_ids
"ASC", limit, pagination_token, include_recipe_ids, query
)
)

Expand All @@ -44,10 +45,11 @@ def get_users_newest_first(
limit: Union[int, None] = None,
pagination_token: Union[str, None] = None,
include_recipe_ids: Union[None, List[str]] = None,
query: Union[None, Dict[str, str]] = None,
) -> UsersResponse:
return sync(
Supertokens.get_instance().get_users(
"DESC", limit, pagination_token, include_recipe_ids
"DESC", limit, pagination_token, include_recipe_ids, query
)
)

Expand Down
25 changes: 25 additions & 0 deletions tests/supertokens_python/test_supertokens_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,28 @@ async def test_supertokens_functions():
users_asc = (await st_asyncio.get_users_oldest_first(limit=10)).users
emails_asc = [user.email for user in users_asc]
assert emails[1] not in emails_asc # The 2nd user must be deleted now.

if not is_version_gte(version, "2.20"):
# If the version is less than 2.20, query users doesn't exist, so we mark the test successful
return
users_asc = (
await st_asyncio.get_users_oldest_first(limit=10, query={"email": "baz"})
).users
users_desc = (
await st_asyncio.get_users_newest_first(limit=10, query={"email": "baz"})
).users
emails_asc = [user.email for user in users_asc]
emails_desc = [user.email for user in users_desc]
assert len(emails_asc) == 1
assert len(emails_desc) == 1

users_asc = (
await st_asyncio.get_users_oldest_first(limit=10, query={"email": "john"})
).users
users_desc = (
await st_asyncio.get_users_newest_first(limit=10, query={"email": "john"})
).users
emails_asc = [user.email for user in users_asc]
emails_desc = [user.email for user in users_desc]
assert len(emails_asc) == 0
assert len(emails_desc) == 0