loopdb+sweepbatcher: add GetParentBatch and TotalSwept calls

This commit is contained in:
Andras Banki-Horvath 2024-02-02 22:07:40 +01:00
parent c094ad4a85
commit b4ebb19a77
No known key found for this signature in database
GPG key ID: 80E5375C094198D8
6 changed files with 159 additions and 0 deletions

View file

@ -62,6 +62,29 @@ INSERT INTO sweeps (
amt = $5,
completed = $6;
-- name: GetParentBatch :one
SELECT
sweep_batches.*
FROM
sweep_batches
JOIN
sweeps ON sweep_batches.id = sweeps.batch_id
WHERE
sweeps.swap_hash = $1
AND
sweeps.completed = TRUE
AND
sweep_batches.confirmed = TRUE;
-- name: GetBatchSweptAmount :one
SELECT
SUM(amt) AS total
FROM
sweeps
WHERE
batch_id = $1
AND
completed = TRUE;
-- name: GetBatchSweeps :many
SELECT