-
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
refactor: #3059 group db update calls #2788
Conversation
let payment_attempt = match payment_attempt_update { | ||
Some(payment_attempt_update) => PaymentAttempt::from_storage_model( | ||
payment_attempt_update | ||
.to_storage_model() | ||
.apply_changeset(payment_attempt.clone().to_storage_model()), | ||
), | ||
None => payment_attempt, | ||
}; |
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.
let payment_attempt = match payment_attempt_update { | |
Some(payment_attempt_update) => PaymentAttempt::from_storage_model( | |
payment_attempt_update | |
.to_storage_model() | |
.apply_changeset(payment_attempt.clone().to_storage_model()), | |
), | |
None => payment_attempt, | |
}; | |
let payment_attempt = payment_attempt_update.map(|payment_attempt_update|{ | |
PaymentAttempt::from_storage_model( | |
payment_attempt_update | |
.to_storage_model() | |
.apply_changeset(payment_attempt.clone().to_storage_model()), | |
) | |
}); |
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.
map would apply function inside Option and return Option back right, want a default value here as well, in case of None
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.
You can use unwrap_or_else(|f|)
let connector_response = match connector_response_update { | ||
Some(connector_response_update) => { | ||
connector_response_update.apply_changeset(connector_response.clone()) | ||
} | ||
None => connector_response, | ||
}; |
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.
let connector_response = match connector_response_update { | |
Some(connector_response_update) => { | |
connector_response_update.apply_changeset(connector_response.clone()) | |
} | |
None => connector_response, | |
}; | |
let connector_response = connector_response_update.map(|connector_response_update| { | |
connector_response_update.apply_changeset(connector_response.clone()) | |
}); |
…ment_intent
Type of Change
Description
group connector_response, payment_attempt db update calls with payment_intent
Additional Changes
Motivation and Context
make db calls concurrent to improve api latency
How did you test it?
compare values of updated objects with db update returned object if they match
print connector_response in payment intent and connector_response returned from awaiting db update and compare
in payment confirm api
curl --location --request POST 'http://localhost:8080/payments/pay_xNnINZf39jNKoFPoHJ0B/confirm' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'api-key: ***' \ --data-raw ' {}'
Checklist
cargo +nightly fmt --all
cargo clippy