Added paginated fetching to withdraw link table (#41)
Some checks failed
/ release (push) Has been cancelled
/ pullrequest (push) Has been cancelled

This commit is contained in:
Julian 2024-07-19 07:22:46 +02:00 committed by GitHub
commit 00064f65d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 50 additions and 23 deletions

View file

@ -25,6 +25,8 @@ async def api_links(
req: Request,
wallet: WalletTypeInfo = Depends(get_key_type),
all_wallets: bool = Query(False),
offset: int = Query(0),
limit: int = Query(0),
):
wallet_ids = [wallet.wallet.id]
@ -33,10 +35,11 @@ async def api_links(
wallet_ids = user.wallet_ids if user else []
try:
return [
{**link.dict(), **{"lnurl": link.lnurl(req)}}
for link in await get_withdraw_links(wallet_ids)
]
links, total = await get_withdraw_links(wallet_ids, limit, offset)
return {
"data": [{**link.dict(), **{"lnurl": link.lnurl(req)}} for link in links],
"total": total,
}
except LnurlInvalidUrl as exc:
raise HTTPException(