Skip to content

Commit 63a77f7

Browse files
committed
loopdb: add query DepositsForSwapHash
1 parent 82fe7f8 commit 63a77f7

File tree

4 files changed

+93
-1
lines changed

4 files changed

+93
-1
lines changed

loopdb/sqlc/migrations/000010_static_address_deposits.up.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ CREATE TABLE IF NOT EXISTS deposit_updates (
4545

4646
-- update_timestamp is the timestamp of the update.
4747
update_timestamp TIMESTAMP NOT NULL
48-
);
48+
);

loopdb/sqlc/querier.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

loopdb/sqlc/queries/static_address_loopin.sql

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,26 @@ FROM
118118
WHERE
119119
swap_hash = $1;
120120

121+
-- name: DepositsForSwapHash :many
122+
SELECT
123+
d.*,
124+
u.update_state,
125+
u.update_timestamp
126+
FROM
127+
deposits d
128+
LEFT JOIN
129+
deposit_updates u ON u.id = (
130+
SELECT id
131+
FROM deposit_updates
132+
WHERE deposit_id = d.deposit_id
133+
ORDER BY update_timestamp DESC
134+
LIMIT 1
135+
)
136+
WHERE
137+
d.swap_hash = $1;
138+
139+
140+
141+
121142

122143

loopdb/sqlc/static_address_loopin.sql.go

Lines changed: 70 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)