diff --git a/src/types.rs b/src/types.rs index ca2dd47..ab39e7e 100644 --- a/src/types.rs +++ b/src/types.rs @@ -20,6 +20,10 @@ pub trait Update { client: &Client, source_id: i16, ) -> Result<(), Box>; + + async fn after_update( + client: &Client, + ) -> Result<(), Box>; } #[derive(Debug)] @@ -93,6 +97,12 @@ impl Update for Author { Err(err) => Err(Box::new(err)), } } + + async fn after_update( + _client: &Client + ) -> Result<(), Box> { + Ok(()) + } } #[derive(Debug)] @@ -187,6 +197,18 @@ impl Update for Book { Err(err) => Err(Box::new(err)), } } + + async fn after_update( + client: &Client + ) -> Result<(), Box> { + match client.execute( + "UPDATE books SET is_deleted = 't' WHERE lang NOT IN ('ru', 'be', 'uk');", + &[] + ).await { + Ok(_) => Ok(()), + Err(err) => Err(Box::new(err)), + } + } } #[derive(Debug)] @@ -260,6 +282,12 @@ impl Update for BookAuthor { Err(err) => Err(Box::new(err)), } } + + async fn after_update( + _client: &Client + ) -> Result<(), Box> { + Ok(()) + } } #[derive(Debug)] @@ -338,6 +366,12 @@ impl Update for Translator { Err(err) => Err(Box::new(err)), } } + + async fn after_update( + _client: &Client + ) -> Result<(), Box> { + Ok(()) + } } #[derive(Debug)] @@ -400,6 +434,12 @@ impl Update for Sequence { Err(err) => Err(Box::new(err)), } } + + async fn after_update( + _client: &Client + ) -> Result<(), Box> { + Ok(()) + } } #[derive(Debug)] @@ -487,6 +527,12 @@ impl Update for SequenceInfo { Err(err) => Err(Box::new(err)), } } + + async fn after_update( + _client: &Client + ) -> Result<(), Box> { + Ok(()) + } } #[derive(Debug)] @@ -563,6 +609,12 @@ impl Update for BookAnnotation { Err(err) => Err(Box::new(err)), } } + + async fn after_update( + _client: &Client + ) -> Result<(), Box> { + Ok(()) + } } #[derive(Debug)] @@ -615,6 +667,12 @@ WHERE book = books.id;\ Err(err) => Err(Box::new(err)), } } + + async fn after_update( + _client: &Client + ) -> Result<(), Box> { + Ok(()) + } } #[derive(Debug)] @@ -691,6 +749,12 @@ impl Update for AuthorAnnotation { Err(err) => Err(Box::new(err)), } } + + async fn after_update( + _client: &Client + ) -> Result<(), Box> { + Ok(()) + } } #[derive(Debug)] @@ -742,6 +806,12 @@ WHERE author = authors.id;", Err(err) => Err(Box::new(err)), } } + + async fn after_update( + _client: &Client + ) -> Result<(), Box> { + Ok(()) + } } #[derive(Debug)] @@ -817,6 +887,12 @@ impl Update for Genre { Err(err) => Err(Box::new(err)), } } + + async fn after_update( + _client: &Client + ) -> Result<(), Box> { + Ok(()) + } } #[derive(Debug)] @@ -864,4 +940,10 @@ impl Update for BookGenre { Err(err) => Err(Box::new(err)), } } + + async fn after_update( + _client: &Client + ) -> Result<(), Box> { + Ok(()) + } } diff --git a/src/updater.rs b/src/updater.rs index 654b346..25b5b2a 100644 --- a/src/updater.rs +++ b/src/updater.rs @@ -167,6 +167,11 @@ where } } + match T::after_update(&pool.get().await.unwrap()).await { + Ok(_) => (), + Err(err) => return Err(err), + }; + log::info!("Updated {file_name}..."); Ok(())