fix: update select query in get_withdraw_links (#52)

This commit is contained in:
Judy 2024-11-29 17:46:47 +01:00 committed by GitHub
commit f05169f994
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

19
crud.py
View file

@ -69,12 +69,21 @@ async def get_withdraw_links(
wallet_ids: list[str], limit: int, offset: int
) -> tuple[list[WithdrawLink], int]:
q = ",".join([f"'{w}'" for w in wallet_ids])
links = await db.fetchall(
f"""
query_str = f"""
SELECT * FROM withdraw.withdraw_link WHERE wallet IN ({q})
ORDER BY open_time DESC LIMIT :limit OFFSET :offset
""",
{"limit": limit, "offset": offset},
ORDER BY open_time DESC
"""
if limit > 0:
query_str += """ LIMIT :limit OFFSET :offset"""
query_params = {"limit": limit, "offset": offset}
else:
query_params = {}
links = await db.fetchall(
query_str,
query_params,
WithdrawLink,
)