|
@ -1,13 +1,14 @@ |
|
|
use crate::db::{insert_new_cfd_state_by_order_id, load_all_cfds}; |
|
|
use crate::db::{insert_new_cfd_state_by_order_id, load_all_cfds}; |
|
|
use crate::model::cfd::{Cfd, CfdState, CfdStateCommon}; |
|
|
use crate::model::cfd::{Cfd, CfdState, CfdStateCommon}; |
|
|
use anyhow::Result; |
|
|
use anyhow::Result; |
|
|
use sqlx::SqlitePool; |
|
|
use sqlx::pool::PoolConnection; |
|
|
|
|
|
use sqlx::Sqlite; |
|
|
use std::time::SystemTime; |
|
|
use std::time::SystemTime; |
|
|
|
|
|
|
|
|
pub async fn transition_non_continue_cfds_to_setup_failed(db: SqlitePool) -> Result<()> { |
|
|
pub async fn transition_non_continue_cfds_to_setup_failed( |
|
|
let mut conn = db.acquire().await?; |
|
|
conn: &mut PoolConnection<Sqlite>, |
|
|
|
|
|
) -> Result<()> { |
|
|
let cfds = load_all_cfds(&mut conn).await?; |
|
|
let cfds = load_all_cfds(conn).await?; |
|
|
|
|
|
|
|
|
for cfd in cfds.iter().filter(|cfd| Cfd::is_cleanup(cfd)) { |
|
|
for cfd in cfds.iter().filter(|cfd| Cfd::is_cleanup(cfd)) { |
|
|
insert_new_cfd_state_by_order_id( |
|
|
insert_new_cfd_state_by_order_id( |
|
@ -18,7 +19,7 @@ pub async fn transition_non_continue_cfds_to_setup_failed(db: SqlitePool) -> Res |
|
|
}, |
|
|
}, |
|
|
info: format!("Was in state {} which cannot be continued.", cfd.state), |
|
|
info: format!("Was in state {} which cannot be continued.", cfd.state), |
|
|
}, |
|
|
}, |
|
|
&mut conn, |
|
|
conn, |
|
|
) |
|
|
) |
|
|
.await?; |
|
|
.await?; |
|
|
} |
|
|
} |
|
|