Add filtering for mint quote states in database (#586)

* filter for mint quote states in db

---------

Co-authored-by: thesimplekid <tsk@thesimplekid.com>
Co-authored-by: ok300 <106775972+ok300@users.noreply.github.com>
This commit is contained in:
callebtc
2025-02-08 10:28:54 +01:00
committed by GitHub
parent 8a8b697d9a
commit b818054f9a
5 changed files with 89 additions and 10 deletions

View File

@@ -431,6 +431,43 @@ FROM mint_quote
}
}
async fn get_mint_quotes_with_state(
&self,
state: MintQuoteState,
) -> Result<Vec<MintQuote>, Self::Err> {
let mut transaction = self.pool.begin().await.map_err(Error::from)?;
let rec = sqlx::query(
r#"
SELECT *
FROM mint_quote
WHERE state = ?
"#,
)
.bind(state.to_string())
.fetch_all(&mut transaction)
.await;
match rec {
Ok(rows) => {
transaction.commit().await.map_err(Error::from)?;
let mint_quotes = rows
.into_iter()
.map(sqlite_row_to_mint_quote)
.collect::<Result<Vec<MintQuote>, _>>()?;
Ok(mint_quotes)
}
Err(err) => {
tracing::error!("SQLite get mint quotes with state");
if let Err(err) = transaction.rollback().await {
tracing::error!("Could not rollback sql transaction: {}", err);
}
return Err(Error::from(err).into());
}
}
}
async fn remove_mint_quote(&self, quote_id: &Uuid) -> Result<(), Self::Err> {
let mut transaction = self.pool.begin().await.map_err(Error::from)?;