-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(refunds): update refunds filters #4409
Conversation
crates/router/src/routes/refunds.rs
Outdated
get, | ||
path = "/refunds/filter_v2", | ||
responses( | ||
(status = 200, description = "List of static filters", body = RefundListMetaData), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the response body type correct?
#[derive(Clone, Debug, serde::Serialize, ToSchema)] | ||
pub struct RefundListFilters { | ||
/// The list of available connector filters | ||
pub connector: HashMap<String, Vec<MerchantConnectorInfo>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will be the key in this hashmap?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please mention it in the doc comment.
crates/router/src/core/refunds.rs
Outdated
.for_each(|(connector_name, info)| { | ||
connector_map | ||
.entry(connector_name.clone()) | ||
.or_default() | ||
.push(info); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fold() and collect() can be used here.
https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.fold
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor stuff
crates/router/src/routes/app.rs
Outdated
@@ -702,7 +702,8 @@ impl Refunds { | |||
{ | |||
route = route | |||
.service(web::resource("/list").route(web::post().to(refunds_list))) | |||
.service(web::resource("/filter").route(web::post().to(refunds_filter_list))); | |||
.service(web::resource("/filter").route(web::post().to(refunds_filter_list))) | |||
.service(web::resource("/filter_v2").route(web::get().to(get_refunds_filters))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be named with/v2
prefix or suffix.
crates/router/src/core/refunds.rs
Outdated
}; | ||
|
||
let connector_map = merchant_connector_accounts | ||
.iter() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use into_iter()
and remove as_ref()
and clone()
.
if let Some(connector) = refund_list_details.clone().connector { | ||
filter = filter.filter(dsl::connector.eq_any(connector)); | ||
} | ||
|
||
if let Some(merchant_connector_id) = refund_list_details.clone().merchant_connector_id { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this work without cloning the whole struct ?
41adc02
Type of Change
Description
The PR:
Adds support for new
filter_v2
api to get list of available filters for refunds quickly: connector with their corresponding label with merchant_connector_ids, currency and refund status. This api is quicker than previous one and gives static and dynamic filter. In this list of available value doesn't depend on refunds that are made (present in table). But these are static and configuration dependent.Modifies existing refunds list as per filters applied (also manages pagination result etc), we can filter list by amount and merchant connector ids as well and the application of previous filters on list remains same.
Also changed payments filter v2 (it is not being used as of now) .
Additional Changes
Motivation and Context
Closes #4408
How did you test it?
To get list of filters:
Response:
To filter refunds list by new parameters i.e., amount and merchant_connector_id
Response:
Checklist
cargo +nightly fmt --all
cargo clippy