Skip to content
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

✨ Add wallet_list pagination support #47

Merged
merged 2 commits into from
Jun 20, 2024
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
11 changes: 10 additions & 1 deletion acapy_wallet_groups_plugin/v1_0/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
wallet_update,
)
from aries_cloudagent.multitenant.base import BaseError, BaseMultitenantManager
from aries_cloudagent.storage.base import DEFAULT_PAGE_SIZE
from aries_cloudagent.storage.error import StorageError, StorageNotFoundError
from aries_cloudagent.utils.endorsement_setup import (
attempt_auto_author_with_endorser_setup,
Expand Down Expand Up @@ -99,9 +100,17 @@ async def wallets_list(request: web.BaseRequest):
if group_id:
query["group_id"] = group_id

limit = int(request.query.get("limit", DEFAULT_PAGE_SIZE))
offset = int(request.query.get("offset", 0))

try:
async with profile.session() as session:
records = await WalletRecord.query(session, tag_filter=query)
records = await WalletRecord.query(
session,
tag_filter=query,
limit=limit,
offset=offset,
)
results = [format_wallet_record(record) for record in records]
results.sort(key=lambda w: w["created_at"])
except (StorageError, BaseModelError) as err:
Expand Down
Loading