mirror of
https://github.com/aljazceru/cdk.git
synced 2025-12-19 21:55:03 +01:00
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:
@@ -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)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user