fix(payment): fix max limit on payment intents list (#2014)

Co-authored-by: Apoorv Dixit <apoorv.dixit@juspay.in>
This commit is contained in:
Sampras Lopes
2023-08-25 14:44:17 +05:30
committed by GitHub
parent ac63794162
commit a888953004
6 changed files with 29 additions and 26 deletions

View File

@ -39,9 +39,6 @@ use crate::{
DataModelExt, DatabaseStore, KVRouterStore,
};
#[cfg(feature = "olap")]
const QUERY_LIMIT: u32 = 20;
#[async_trait::async_trait]
impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
async fn insert_payment_intent(
@ -339,7 +336,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
query = query.filter(pi_dsl::payment_id.eq(payment_intent_id.to_owned()));
}
PaymentIntentFetchConstraints::List {
offset: _,
offset,
starting_at,
ending_at,
connector: _,
@ -351,7 +348,9 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
ending_before_id,
limit,
} => {
query = query.limit(limit.unwrap_or(QUERY_LIMIT).into());
if let Some(limit) = limit {
query = query.limit((*limit).into());
};
if let Some(customer_id) = customer_id {
query = query.filter(pi_dsl::customer_id.eq(customer_id.clone()));
@ -390,6 +389,8 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
}
(None, None) => query,
};
query = query.offset((*offset).into());
query = match currency {
Some(currency) => query.filter(pi_dsl::currency.eq_any(currency.clone())),
None => query,
@ -470,7 +471,9 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
ending_before_id,
limit,
} => {
query = query.limit(limit.unwrap_or(QUERY_LIMIT).into());
if let Some(limit) = limit {
query = query.limit((*limit).into());
}
if let Some(customer_id) = customer_id {
query = query.filter(pi_dsl::customer_id.eq(customer_id.clone()));
@ -510,10 +513,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
(None, None) => query,
};
query = match offset {
Some(offset) => query.offset((*offset).into()),
None => query,
};
query = query.offset((*offset).into());
query = match currency {
Some(currency) => query.filter(pi_dsl::currency.eq_any(currency.clone())),