mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 04:04:55 +08:00
fix: fetch data directly from DB in OLAP functions (#2475)
This commit is contained in:
@ -638,32 +638,30 @@ mod storage {
|
||||
&self,
|
||||
merchant_id: &str,
|
||||
refund_details: &api_models::refunds::RefundListRequest,
|
||||
storage_scheme: enums::MerchantStorageScheme,
|
||||
_storage_scheme: enums::MerchantStorageScheme,
|
||||
limit: i64,
|
||||
offset: i64,
|
||||
) -> CustomResult<Vec<diesel_models::refund::Refund>, errors::StorageError> {
|
||||
match storage_scheme {
|
||||
enums::MerchantStorageScheme::PostgresOnly => {
|
||||
let conn = connection::pg_connection_read(self).await?;
|
||||
<diesel_models::refund::Refund as storage_types::RefundDbExt>::filter_by_constraints(&conn, merchant_id, refund_details, limit, offset)
|
||||
<diesel_models::refund::Refund as storage_types::RefundDbExt>::filter_by_constraints(
|
||||
&conn,
|
||||
merchant_id,
|
||||
refund_details,
|
||||
limit,
|
||||
offset,
|
||||
)
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
.into_report()
|
||||
}
|
||||
|
||||
enums::MerchantStorageScheme::RedisKv => Err(errors::StorageError::KVError.into()),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "olap")]
|
||||
async fn filter_refund_by_meta_constraints(
|
||||
&self,
|
||||
merchant_id: &str,
|
||||
refund_details: &api_models::refunds::TimeRange,
|
||||
storage_scheme: enums::MerchantStorageScheme,
|
||||
_storage_scheme: enums::MerchantStorageScheme,
|
||||
) -> CustomResult<api_models::refunds::RefundListMetaData, errors::StorageError> {
|
||||
match storage_scheme {
|
||||
enums::MerchantStorageScheme::PostgresOnly => {
|
||||
let conn = connection::pg_connection_read(self).await?;
|
||||
<diesel_models::refund::Refund as storage_types::RefundDbExt>::filter_by_meta_constraints(&conn, merchant_id, refund_details)
|
||||
.await
|
||||
@ -671,29 +669,23 @@ mod storage {
|
||||
.into_report()
|
||||
}
|
||||
|
||||
enums::MerchantStorageScheme::RedisKv => Err(errors::StorageError::KVError.into()),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "olap")]
|
||||
async fn get_total_count_of_refunds(
|
||||
&self,
|
||||
merchant_id: &str,
|
||||
refund_details: &api_models::refunds::RefundListRequest,
|
||||
storage_scheme: enums::MerchantStorageScheme,
|
||||
_storage_scheme: enums::MerchantStorageScheme,
|
||||
) -> CustomResult<i64, errors::StorageError> {
|
||||
match storage_scheme {
|
||||
enums::MerchantStorageScheme::PostgresOnly => {
|
||||
let conn = connection::pg_connection_read(self).await?;
|
||||
<diesel_models::refund::Refund as storage_types::RefundDbExt>::get_refunds_count(&conn, merchant_id, refund_details)
|
||||
<diesel_models::refund::Refund as storage_types::RefundDbExt>::get_refunds_count(
|
||||
&conn,
|
||||
merchant_id,
|
||||
refund_details,
|
||||
)
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
.into_report()
|
||||
}
|
||||
|
||||
enums::MerchantStorageScheme::RedisKv => Err(errors::StorageError::KVError.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -224,15 +224,11 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
|
||||
filters: &PaymentIntentFetchConstraints,
|
||||
storage_scheme: MerchantStorageScheme,
|
||||
) -> error_stack::Result<Vec<PaymentIntent>, StorageError> {
|
||||
match storage_scheme {
|
||||
MerchantStorageScheme::PostgresOnly => {
|
||||
self.router_store
|
||||
.filter_payment_intent_by_constraints(merchant_id, filters, storage_scheme)
|
||||
.await
|
||||
}
|
||||
MerchantStorageScheme::RedisKv => Err(StorageError::KVError.into()),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "olap")]
|
||||
async fn filter_payment_intents_by_time_range_constraints(
|
||||
&self,
|
||||
@ -240,8 +236,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
|
||||
time_range: &api_models::payments::TimeRange,
|
||||
storage_scheme: MerchantStorageScheme,
|
||||
) -> error_stack::Result<Vec<PaymentIntent>, StorageError> {
|
||||
match storage_scheme {
|
||||
MerchantStorageScheme::PostgresOnly => {
|
||||
self.router_store
|
||||
.filter_payment_intents_by_time_range_constraints(
|
||||
merchant_id,
|
||||
@ -250,9 +244,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
|
||||
)
|
||||
.await
|
||||
}
|
||||
MerchantStorageScheme::RedisKv => Err(StorageError::KVError.into()),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "olap")]
|
||||
async fn get_filtered_payment_intents_attempt(
|
||||
@ -261,15 +252,10 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
|
||||
filters: &PaymentIntentFetchConstraints,
|
||||
storage_scheme: MerchantStorageScheme,
|
||||
) -> error_stack::Result<Vec<(PaymentIntent, PaymentAttempt)>, StorageError> {
|
||||
match storage_scheme {
|
||||
MerchantStorageScheme::PostgresOnly => {
|
||||
self.router_store
|
||||
.get_filtered_payment_intents_attempt(merchant_id, filters, storage_scheme)
|
||||
.await
|
||||
}
|
||||
MerchantStorageScheme::RedisKv => Err(StorageError::KVError.into()),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "olap")]
|
||||
async fn get_filtered_active_attempt_ids_for_total_count(
|
||||
@ -278,8 +264,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
|
||||
constraints: &PaymentIntentFetchConstraints,
|
||||
storage_scheme: MerchantStorageScheme,
|
||||
) -> error_stack::Result<Vec<String>, StorageError> {
|
||||
match storage_scheme {
|
||||
MerchantStorageScheme::PostgresOnly => {
|
||||
self.router_store
|
||||
.get_filtered_active_attempt_ids_for_total_count(
|
||||
merchant_id,
|
||||
@ -288,10 +272,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
MerchantStorageScheme::RedisKv => Err(StorageError::KVError.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
|
||||
Reference in New Issue
Block a user