mirror of
https://github.com/flibusta-apps/library_updater.git
synced 2025-12-06 15:45:36 +01:00
Update
This commit is contained in:
82
src/types.rs
82
src/types.rs
@@ -20,6 +20,10 @@ pub trait Update {
|
|||||||
client: &Client,
|
client: &Client,
|
||||||
source_id: i16,
|
source_id: i16,
|
||||||
) -> Result<(), Box<tokio_postgres::Error>>;
|
) -> Result<(), Box<tokio_postgres::Error>>;
|
||||||
|
|
||||||
|
async fn after_update(
|
||||||
|
client: &Client,
|
||||||
|
) -> Result<(), Box<tokio_postgres::Error>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -93,6 +97,12 @@ impl Update for Author {
|
|||||||
Err(err) => Err(Box::new(err)),
|
Err(err) => Err(Box::new(err)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn after_update(
|
||||||
|
_client: &Client
|
||||||
|
) -> Result<(), Box<tokio_postgres::Error>> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -187,6 +197,18 @@ impl Update for Book {
|
|||||||
Err(err) => Err(Box::new(err)),
|
Err(err) => Err(Box::new(err)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn after_update(
|
||||||
|
client: &Client
|
||||||
|
) -> Result<(), Box<tokio_postgres::Error>> {
|
||||||
|
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)]
|
#[derive(Debug)]
|
||||||
@@ -260,6 +282,12 @@ impl Update for BookAuthor {
|
|||||||
Err(err) => Err(Box::new(err)),
|
Err(err) => Err(Box::new(err)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn after_update(
|
||||||
|
_client: &Client
|
||||||
|
) -> Result<(), Box<tokio_postgres::Error>> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -338,6 +366,12 @@ impl Update for Translator {
|
|||||||
Err(err) => Err(Box::new(err)),
|
Err(err) => Err(Box::new(err)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn after_update(
|
||||||
|
_client: &Client
|
||||||
|
) -> Result<(), Box<tokio_postgres::Error>> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -400,6 +434,12 @@ impl Update for Sequence {
|
|||||||
Err(err) => Err(Box::new(err)),
|
Err(err) => Err(Box::new(err)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn after_update(
|
||||||
|
_client: &Client
|
||||||
|
) -> Result<(), Box<tokio_postgres::Error>> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -487,6 +527,12 @@ impl Update for SequenceInfo {
|
|||||||
Err(err) => Err(Box::new(err)),
|
Err(err) => Err(Box::new(err)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn after_update(
|
||||||
|
_client: &Client
|
||||||
|
) -> Result<(), Box<tokio_postgres::Error>> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -563,6 +609,12 @@ impl Update for BookAnnotation {
|
|||||||
Err(err) => Err(Box::new(err)),
|
Err(err) => Err(Box::new(err)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn after_update(
|
||||||
|
_client: &Client
|
||||||
|
) -> Result<(), Box<tokio_postgres::Error>> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -615,6 +667,12 @@ WHERE book = books.id;\
|
|||||||
Err(err) => Err(Box::new(err)),
|
Err(err) => Err(Box::new(err)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn after_update(
|
||||||
|
_client: &Client
|
||||||
|
) -> Result<(), Box<tokio_postgres::Error>> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -691,6 +749,12 @@ impl Update for AuthorAnnotation {
|
|||||||
Err(err) => Err(Box::new(err)),
|
Err(err) => Err(Box::new(err)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn after_update(
|
||||||
|
_client: &Client
|
||||||
|
) -> Result<(), Box<tokio_postgres::Error>> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -742,6 +806,12 @@ WHERE author = authors.id;",
|
|||||||
Err(err) => Err(Box::new(err)),
|
Err(err) => Err(Box::new(err)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn after_update(
|
||||||
|
_client: &Client
|
||||||
|
) -> Result<(), Box<tokio_postgres::Error>> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -817,6 +887,12 @@ impl Update for Genre {
|
|||||||
Err(err) => Err(Box::new(err)),
|
Err(err) => Err(Box::new(err)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn after_update(
|
||||||
|
_client: &Client
|
||||||
|
) -> Result<(), Box<tokio_postgres::Error>> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -864,4 +940,10 @@ impl Update for BookGenre {
|
|||||||
Err(err) => Err(Box::new(err)),
|
Err(err) => Err(Box::new(err)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn after_update(
|
||||||
|
_client: &Client
|
||||||
|
) -> Result<(), Box<tokio_postgres::Error>> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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}...");
|
log::info!("Updated {file_name}...");
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user