update all dependencies

This commit is contained in:
Sebastian Hugentobler 2024-09-24 09:57:32 +02:00
parent 44fc2d7a7e
commit 949eecffb6
Signed by: shu
GPG key ID: BB32CF3CA052C2F0
10 changed files with 223 additions and 183 deletions

View file

@ -1,16 +1,25 @@
use entity::alerts;
use migration::{Migrator, MigratorTrait};
use sea_orm::{ActiveModelTrait, Database, DatabaseConnection, DbErr, EntityTrait, Set};
use sea_orm::{ActiveModelTrait, DatabaseConnection, EntityTrait, Set};
use thiserror::Error;
use tracing::debug;
use crate::json::alert::Alert;
#[derive(Error, Debug)]
#[error("rdbms error")]
pub enum RdbmsError {
/// Database Error
#[error("db error")]
DbError(#[from] sea_orm::DbErr),
}
pub struct Db {
connection: DatabaseConnection,
}
impl Db {
pub async fn is_alert_updated(&self, alert: &Alert) -> Result<bool, DbErr> {
pub async fn is_alert_updated(&self, alert: &Alert) -> Result<bool, RdbmsError> {
let db_alert = entity::alerts::Entity::find_by_id(&alert.identifier)
.one(&self.connection)
.await?;
@ -21,7 +30,7 @@ impl Db {
})
}
pub async fn save_alert(&self, alert: &Alert) -> Result<(), DbErr> {
pub async fn save_alert(&self, alert: &Alert) -> Result<(), RdbmsError> {
let db_alert = entity::alerts::Entity::find_by_id(&alert.identifier)
.one(&self.connection)
.await?;
@ -40,11 +49,12 @@ impl Db {
}
}
pub async fn connect(connection_string: &str) -> Result<Db, DbErr> {
pub async fn connect(connection_string: &str) -> Result<Db, RdbmsError> {
debug!("connecting to {connection_string}...");
let connection: DatabaseConnection = Database::connect(connection_string).await?;
let connection = migration::sea_orm::Database::connect(connection_string).await?;
Migrator::up(&connection, None).await?;
let connection = sea_orm::Database::connect(connection_string).await?;
Ok(Db { connection })
}

View file

@ -1,12 +1,12 @@
use sea_orm::DbErr;
use crate::datastore::rdbms::RdbmsError;
use thiserror::Error;
#[derive(Error, Debug)]
#[error("opds error")]
#[error("application error")]
pub enum Error {
/// Database Error
#[error("opds error")]
DbError(#[from] DbErr),
#[error("database error")]
DbError(#[from] RdbmsError),
/// Error fetching data from alertswiss
#[error("data error")]
FetchError(#[from] reqwest::Error),