mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +08:00
feat(payments): support sort criteria in payments list (#5389)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
#[cfg(feature = "olap")]
|
||||
use api_models::payments::AmountFilter;
|
||||
use api_models::payments::{AmountFilter, Order, SortBy, SortOn};
|
||||
#[cfg(feature = "olap")]
|
||||
use async_bb8_diesel::{AsyncConnection, AsyncRunQueryDsl};
|
||||
#[cfg(feature = "olap")]
|
||||
@ -674,7 +674,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
|
||||
payment_attempt_schema::table.on(pa_dsl::attempt_id.eq(pi_dsl::active_attempt_id)),
|
||||
)
|
||||
.filter(pi_dsl::merchant_id.eq(merchant_id.to_owned()))
|
||||
.order(pi_dsl::created_at.desc())
|
||||
.into_boxed();
|
||||
|
||||
query = match constraints {
|
||||
@ -682,6 +681,25 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
|
||||
query.filter(pi_dsl::payment_id.eq(payment_intent_id.to_owned()))
|
||||
}
|
||||
PaymentIntentFetchConstraints::List(params) => {
|
||||
query = match params.order {
|
||||
Order {
|
||||
on: SortOn::Amount,
|
||||
by: SortBy::Asc,
|
||||
} => query.order(pi_dsl::amount.asc()),
|
||||
Order {
|
||||
on: SortOn::Amount,
|
||||
by: SortBy::Desc,
|
||||
} => query.order(pi_dsl::amount.desc()),
|
||||
Order {
|
||||
on: SortOn::Created,
|
||||
by: SortBy::Asc,
|
||||
} => query.order(pi_dsl::created_at.asc()),
|
||||
Order {
|
||||
on: SortOn::Created,
|
||||
by: SortBy::Desc,
|
||||
} => query.order(pi_dsl::created_at.desc()),
|
||||
};
|
||||
|
||||
if let Some(limit) = params.limit {
|
||||
query = query.limit(limit.into());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user