fix coroutine await

This commit is contained in:
Riccardo Balbo 2024-07-25 20:11:32 +00:00
commit 5c0fa0df83

View file

@ -145,12 +145,12 @@ async def tracked_spend_nwc(
in_budget = True in_budget = True
for budget in budgets: for budget in budgets:
last_cycle, next_cycle = budget.get_timestamp_range() last_cycle, next_cycle = budget.get_timestamp_range()
tot_spent_in_range_msats = await db.fetchone( tot_spent_in_range_msats =(await db.fetchone(
""" """
SELECT SUM(amount_msats) FROM nwcprovider.spent WHERE pubkey = ? AND created_at >= ? AND created_at < ? SELECT SUM(amount_msats) FROM nwcprovider.spent WHERE pubkey = ? AND created_at >= ? AND created_at < ?
""", """,
(pubkey, last_cycle, next_cycle) (pubkey, last_cycle, next_cycle)
)[0] or 0 ))[0] or 0
if tot_spent_in_range_msats + amount_msats > budget.budget_msats: if tot_spent_in_range_msats + amount_msats > budget.budget_msats:
in_budget = False in_budget = False
break break