fix tracked budget

This commit is contained in:
Riccardo Balbo 2025-02-18 13:49:34 +00:00
commit c1dab6a632

View file

@ -147,8 +147,7 @@ async def tracked_spend_nwc(data: TrackedSpendNWC, action):
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 = ( tot_spent_in_range_msats = (
( next(iter((await db.fetchone(
await db.fetchone(
""" """
SELECT SUM(amount_msats) FROM nwcprovider.spent SELECT SUM(amount_msats) FROM nwcprovider.spent
WHERE pubkey = :pubkey AND created_at >= WHERE pubkey = :pubkey AND created_at >=
@ -159,9 +158,7 @@ async def tracked_spend_nwc(data: TrackedSpendNWC, action):
"last_cycle": last_cycle, "last_cycle": last_cycle,
"next_cycle": next_cycle, "next_cycle": next_cycle,
}, },
) )).values())) or 0
)[0]
or 0
) )
if tot_spent_in_range_msats + data.amount_msats > budget.budget_msats: if tot_spent_in_range_msats + data.amount_msats > budget.budget_msats:
in_budget = False in_budget = False