Skip to content

Commit

Permalink
chore: run formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperswitch-bot[bot] committed Apr 5, 2024
1 parent 0a76b82 commit 26682d7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
4 changes: 2 additions & 2 deletions crates/diesel_models/src/mandate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ impl MandateUpdateInternal {
}
}

impl From<&MandateNew> for Mandate{
fn from(mandate_new : &MandateNew) -> Mandate {
impl From<&MandateNew> for Mandate {
fn from(mandate_new: &MandateNew) -> Mandate {
Mandate {
id: 0i32,
mandate_id: mandate_new.mandate_id.clone(),
Expand Down
35 changes: 22 additions & 13 deletions crates/router/src/db/mandate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,17 @@ impl MandateInterface for Store {
) -> CustomResult<storage::Mandate, errors::StorageError> {
let conn = connection::pg_connection_write(self).await?;

match storage_scheme{
match storage_scheme {
MerchantStorageScheme::PostgresOnly => {
storage::Mandate::update_by_merchant_id_mandate_id(&conn, merchant_id, mandate_id, storage::MandateUpdateInternal::from(mandate_update))
storage::Mandate::update_by_merchant_id_mandate_id(
&conn,
merchant_id,
mandate_id,
storage::MandateUpdateInternal::from(mandate_update),
)
.await
.map_err(|error| report!(errors::StorageError::from(error)))
},
}
MerchantStorageScheme::RedisKv => {
let key = format!("mid_{}_mandate_{}", merchant_id, mandate_id);
let field = format!("mandate_{}", mandate_id);
Expand Down Expand Up @@ -251,20 +256,18 @@ impl MandateInterface for Store {
) -> CustomResult<storage::Mandate, errors::StorageError> {
let conn = connection::pg_connection_write(self).await?;

match storage_scheme{
MerchantStorageScheme::PostgresOnly => {
mandate
match storage_scheme {
MerchantStorageScheme::PostgresOnly => mandate
.insert(&conn)
.await
.map_err(|error| report!(errors::StorageError::from(error)))
},
.map_err(|error| report!(errors::StorageError::from(error))),
MerchantStorageScheme::RedisKv => {
let mandate_id = mandate.mandate_id.clone();
let merchant_id = mandate.merchant_id.clone();
let connector_mandate_id = mandate.connector_mandate_id.clone();
let key = format!("mid_{}_mandate_{}", mandate.merchant_id, mandate_id);
let field = format!("mandate_{}", mandate_id);

let storage_mandate = storage::Mandate::from(&mandate);

let redis_entry = kv::TypedSql {
Expand All @@ -284,7 +287,8 @@ impl MandateInterface for Store {
updated_by: storage_scheme.to_string(),
};

self.insert_reverse_lookup(reverse_lookup_entry, storage_scheme).await?;
self.insert_reverse_lookup(reverse_lookup_entry, storage_scheme)
.await?;
}

match kv_wrapper::<diesel_models::Mandate, _, _>(
Expand Down Expand Up @@ -364,9 +368,14 @@ impl MandateInterface for Store {
mandate: storage::MandateUpdate,
) -> CustomResult<storage::Mandate, errors::StorageError> {
let conn = connection::pg_connection_write(self).await?;
storage::Mandate::update_by_merchant_id_mandate_id(&conn, merchant_id, mandate_id, storage::MandateUpdateInternal::from(mandate))
.await
.map_err(|error| report!(errors::StorageError::from(error)))
storage::Mandate::update_by_merchant_id_mandate_id(
&conn,
merchant_id,
mandate_id,
storage::MandateUpdateInternal::from(mandate),
)
.await
.map_err(|error| report!(errors::StorageError::from(error)))
}

#[instrument(skip_all)]
Expand Down

0 comments on commit 26682d7

Please sign in to comment.