Skip to content

Commit

Permalink
fix: Fixed errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarthak1799 committed Jan 19, 2025
1 parent d332edf commit 978d315
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
48 changes: 26 additions & 22 deletions crates/router/src/core/payments/routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ pub async fn perform_dynamic_routing(
field: "dynamic_routing_algorithm".to_string(),
})?;

let mut connector_list = dynamic_routing_algo_ref
let connector_list = match dynamic_routing_algo_ref
.success_based_algorithm
.as_ref()
.async_map(|algorithm| {
Expand All @@ -1327,27 +1327,31 @@ pub async fn perform_dynamic_routing(
.attach_printable("unable to perform success_based_routing")
.ok()
.flatten()
.unwrap_or(routable_connectors.clone());

connector_list = dynamic_routing_algo_ref
.contract_based_routing
.as_ref()
.async_map(|algorithm| {
perform_contract_based_routing(
state,
routable_connectors.clone(),
profile,
dynamic_routing_config_params_interpolator,
algorithm.clone(),
)
})
.await
.transpose()
.inspect_err(|e| logger::error!("Dynamic_routing error {:?}", e))
.attach_printable("unable to perform contract_based_routing")
.ok()
.flatten()
.unwrap_or(routable_connectors);
{
Some(success_based_list) => success_based_list,
None => {
// Only run contract based if success based returns None
dynamic_routing_algo_ref
.contract_based_routing
.as_ref()
.async_map(|algorithm| {
perform_contract_based_routing(
state,
routable_connectors.clone(),
profile,
dynamic_routing_config_params_interpolator,
algorithm.clone(),
)
})
.await
.transpose()
.inspect_err(|e| logger::error!("Dynamic_routing error {:?}", e))
.attach_printable("unable to perform contract_based_routing")
.ok()
.flatten()
.unwrap_or(routable_connectors)
}
};

Ok(connector_list)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/core/routing/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@ pub async fn push_metrics_with_update_window_for_contract_based_routing(
let contract_based_routing_config =
fetch_dynamic_routing_configs::<routing_types::ContractBasedRoutingConfig>(
state,
business_profile,
profile_id,
contract_routing_algo_ref
.algorithm_id_with_timestamp
.algorithm_id
Expand Down

0 comments on commit 978d315

Please sign in to comment.