mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 12:06:56 +08:00
feat(router): add attempt_count in list payments response (#1990)
This commit is contained in:
committed by
GitHub
parent
f690c5f3ea
commit
f0cc0fba16
@ -1269,6 +1269,11 @@ pub async fn list_payments(
|
||||
.await
|
||||
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
|
||||
|
||||
let attempt_count = payment_intents
|
||||
.iter()
|
||||
.map(|intent| intent.attempt_count)
|
||||
.sum();
|
||||
|
||||
let collected_futures = payment_intents.into_iter().map(|pi| {
|
||||
async {
|
||||
match db
|
||||
@ -1316,6 +1321,7 @@ pub async fn list_payments(
|
||||
Ok(services::ApplicationResponse::Json(
|
||||
api::PaymentListResponse {
|
||||
size: data.len(),
|
||||
attempt_count,
|
||||
data,
|
||||
},
|
||||
))
|
||||
@ -1342,12 +1348,15 @@ pub async fn apply_filters_on_payments(
|
||||
.map(|(pi, pa)| (pi, pa.to_storage_model()))
|
||||
.collect();
|
||||
|
||||
let attempt_count = list.iter().map(|item| item.0.attempt_count).sum();
|
||||
|
||||
let data: Vec<api::PaymentsResponse> =
|
||||
list.into_iter().map(ForeignFrom::foreign_from).collect();
|
||||
|
||||
Ok(services::ApplicationResponse::Json(
|
||||
api::PaymentListResponse {
|
||||
size: data.len(),
|
||||
attempt_count,
|
||||
data,
|
||||
},
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user