bugfix: List most recent pool utxos

This commit is contained in:
Dagur Valberg Johannsson 2024-04-15 23:05:06 +02:00
parent bce825c91b
commit 98ab9a81b3
No known key found for this signature in database
GPG key ID: FD701804AEE88107
2 changed files with 16 additions and 15 deletions

View file

@ -76,8 +76,7 @@ pub fn list_tokens_by_volume(
ORDER BY total_trade_volume DESC, tvl_sats DESC
LIMIT ?;
",
)
.unwrap();
)?;
let tokens: Vec<(String, u64, u64, u64, u64, u64, u64)> = statement
.query_and_then([seconds, limit], |row| {

View file

@ -166,19 +166,21 @@ fn db_list_active_pools(
conn: &Connection,
) -> Result<Vec<ActivePool>> {
let mut query: String = "
SELECT
p.owner_pkh,
uf.sats,
uf.token_amount,
uf.new_utxo_txid,
uf.new_utxo_n,
p.token_id
FROM
pool p
JOIN utxo_funding uf ON p.creation_utxo = uf.new_utxo_hash
WHERE
p.withdrawn_in_utxo IS NULL
SELECT
p.owner_pkh,
uf.sats,
uf.token_amount,
uf.new_utxo_txid,
uf.new_utxo_n,
p.token_id
FROM
pool p
JOIN pool_history_entry phe ON p.creation_utxo = phe.pool
JOIN utxo_funding uf ON phe.utxo = uf.new_utxo_hash
LEFT JOIN utxo_spending us ON uf.new_utxo_hash = us.spent_utxo_hash
WHERE
p.withdrawn_in_utxo IS NULL
AND us.spent_utxo_hash IS NULL
"
.to_string();