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