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,
|
&self,
|
||||||
merchant_id: &str,
|
merchant_id: &str,
|
||||||
refund_details: &api_models::refunds::RefundListRequest,
|
refund_details: &api_models::refunds::RefundListRequest,
|
||||||
storage_scheme: enums::MerchantStorageScheme,
|
_storage_scheme: enums::MerchantStorageScheme,
|
||||||
limit: i64,
|
limit: i64,
|
||||||
offset: i64,
|
offset: i64,
|
||||||
) -> CustomResult<Vec<diesel_models::refund::Refund>, errors::StorageError> {
|
) -> CustomResult<Vec<diesel_models::refund::Refund>, errors::StorageError> {
|
||||||
match storage_scheme {
|
|
||||||
enums::MerchantStorageScheme::PostgresOnly => {
|
|
||||||
let conn = connection::pg_connection_read(self).await?;
|
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
|
.await
|
||||||
.map_err(Into::into)
|
.map_err(Into::into)
|
||||||
.into_report()
|
.into_report()
|
||||||
}
|
}
|
||||||
|
|
||||||
enums::MerchantStorageScheme::RedisKv => Err(errors::StorageError::KVError.into()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "olap")]
|
#[cfg(feature = "olap")]
|
||||||
async fn filter_refund_by_meta_constraints(
|
async fn filter_refund_by_meta_constraints(
|
||||||
&self,
|
&self,
|
||||||
merchant_id: &str,
|
merchant_id: &str,
|
||||||
refund_details: &api_models::refunds::TimeRange,
|
refund_details: &api_models::refunds::TimeRange,
|
||||||
storage_scheme: enums::MerchantStorageScheme,
|
_storage_scheme: enums::MerchantStorageScheme,
|
||||||
) -> CustomResult<api_models::refunds::RefundListMetaData, errors::StorageError> {
|
) -> CustomResult<api_models::refunds::RefundListMetaData, errors::StorageError> {
|
||||||
match storage_scheme {
|
|
||||||
enums::MerchantStorageScheme::PostgresOnly => {
|
|
||||||
let conn = connection::pg_connection_read(self).await?;
|
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)
|
<diesel_models::refund::Refund as storage_types::RefundDbExt>::filter_by_meta_constraints(&conn, merchant_id, refund_details)
|
||||||
.await
|
.await
|
||||||
@ -671,29 +669,23 @@ mod storage {
|
|||||||
.into_report()
|
.into_report()
|
||||||
}
|
}
|
||||||
|
|
||||||
enums::MerchantStorageScheme::RedisKv => Err(errors::StorageError::KVError.into()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "olap")]
|
#[cfg(feature = "olap")]
|
||||||
async fn get_total_count_of_refunds(
|
async fn get_total_count_of_refunds(
|
||||||
&self,
|
&self,
|
||||||
merchant_id: &str,
|
merchant_id: &str,
|
||||||
refund_details: &api_models::refunds::RefundListRequest,
|
refund_details: &api_models::refunds::RefundListRequest,
|
||||||
storage_scheme: enums::MerchantStorageScheme,
|
_storage_scheme: enums::MerchantStorageScheme,
|
||||||
) -> CustomResult<i64, errors::StorageError> {
|
) -> CustomResult<i64, errors::StorageError> {
|
||||||
match storage_scheme {
|
|
||||||
enums::MerchantStorageScheme::PostgresOnly => {
|
|
||||||
let conn = connection::pg_connection_read(self).await?;
|
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
|
.await
|
||||||
.map_err(Into::into)
|
.map_err(Into::into)
|
||||||
.into_report()
|
.into_report()
|
||||||
}
|
}
|
||||||
|
|
||||||
enums::MerchantStorageScheme::RedisKv => Err(errors::StorageError::KVError.into()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -224,15 +224,11 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
|
|||||||
filters: &PaymentIntentFetchConstraints,
|
filters: &PaymentIntentFetchConstraints,
|
||||||
storage_scheme: MerchantStorageScheme,
|
storage_scheme: MerchantStorageScheme,
|
||||||
) -> error_stack::Result<Vec<PaymentIntent>, StorageError> {
|
) -> error_stack::Result<Vec<PaymentIntent>, StorageError> {
|
||||||
match storage_scheme {
|
|
||||||
MerchantStorageScheme::PostgresOnly => {
|
|
||||||
self.router_store
|
self.router_store
|
||||||
.filter_payment_intent_by_constraints(merchant_id, filters, storage_scheme)
|
.filter_payment_intent_by_constraints(merchant_id, filters, storage_scheme)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
MerchantStorageScheme::RedisKv => Err(StorageError::KVError.into()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[cfg(feature = "olap")]
|
#[cfg(feature = "olap")]
|
||||||
async fn filter_payment_intents_by_time_range_constraints(
|
async fn filter_payment_intents_by_time_range_constraints(
|
||||||
&self,
|
&self,
|
||||||
@ -240,8 +236,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
|
|||||||
time_range: &api_models::payments::TimeRange,
|
time_range: &api_models::payments::TimeRange,
|
||||||
storage_scheme: MerchantStorageScheme,
|
storage_scheme: MerchantStorageScheme,
|
||||||
) -> error_stack::Result<Vec<PaymentIntent>, StorageError> {
|
) -> error_stack::Result<Vec<PaymentIntent>, StorageError> {
|
||||||
match storage_scheme {
|
|
||||||
MerchantStorageScheme::PostgresOnly => {
|
|
||||||
self.router_store
|
self.router_store
|
||||||
.filter_payment_intents_by_time_range_constraints(
|
.filter_payment_intents_by_time_range_constraints(
|
||||||
merchant_id,
|
merchant_id,
|
||||||
@ -250,9 +244,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
|
|||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
MerchantStorageScheme::RedisKv => Err(StorageError::KVError.into()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "olap")]
|
#[cfg(feature = "olap")]
|
||||||
async fn get_filtered_payment_intents_attempt(
|
async fn get_filtered_payment_intents_attempt(
|
||||||
@ -261,15 +252,10 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
|
|||||||
filters: &PaymentIntentFetchConstraints,
|
filters: &PaymentIntentFetchConstraints,
|
||||||
storage_scheme: MerchantStorageScheme,
|
storage_scheme: MerchantStorageScheme,
|
||||||
) -> error_stack::Result<Vec<(PaymentIntent, PaymentAttempt)>, StorageError> {
|
) -> error_stack::Result<Vec<(PaymentIntent, PaymentAttempt)>, StorageError> {
|
||||||
match storage_scheme {
|
|
||||||
MerchantStorageScheme::PostgresOnly => {
|
|
||||||
self.router_store
|
self.router_store
|
||||||
.get_filtered_payment_intents_attempt(merchant_id, filters, storage_scheme)
|
.get_filtered_payment_intents_attempt(merchant_id, filters, storage_scheme)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
MerchantStorageScheme::RedisKv => Err(StorageError::KVError.into()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "olap")]
|
#[cfg(feature = "olap")]
|
||||||
async fn get_filtered_active_attempt_ids_for_total_count(
|
async fn get_filtered_active_attempt_ids_for_total_count(
|
||||||
@ -278,8 +264,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
|
|||||||
constraints: &PaymentIntentFetchConstraints,
|
constraints: &PaymentIntentFetchConstraints,
|
||||||
storage_scheme: MerchantStorageScheme,
|
storage_scheme: MerchantStorageScheme,
|
||||||
) -> error_stack::Result<Vec<String>, StorageError> {
|
) -> error_stack::Result<Vec<String>, StorageError> {
|
||||||
match storage_scheme {
|
|
||||||
MerchantStorageScheme::PostgresOnly => {
|
|
||||||
self.router_store
|
self.router_store
|
||||||
.get_filtered_active_attempt_ids_for_total_count(
|
.get_filtered_active_attempt_ids_for_total_count(
|
||||||
merchant_id,
|
merchant_id,
|
||||||
@ -288,10 +272,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
|
|||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
MerchantStorageScheme::RedisKv => Err(StorageError::KVError.into()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
|
|||||||
Reference in New Issue
Block a user