Skip to content
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

Merged
merged 5 commits into from
Nov 7, 2023

Conversation

akshay-97
Copy link
Contributor

@akshay-97 akshay-97 commented Nov 5, 2023

…ment_intent

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • [ x] Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

group connector_response, payment_attempt db update calls with payment_intent

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

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

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible
  • I added a CHANGELOG entry if applicable

@akshay-97 akshay-97 requested review from a team as code owners November 5, 2023 17:11
@github-actions github-actions bot added the S-conventions-not-followed Status: This PR does not follow contributing guidelines label Nov 5, 2023
@akshay-97 akshay-97 changed the title #3059 group connector_response, payment_attempt update calls with pay… #3059 group db update calls Nov 6, 2023
@akshay-97 akshay-97 changed the title #3059 group db update calls refactor: #3059 group db update calls Nov 6, 2023
@github-actions github-actions bot removed the S-conventions-not-followed Status: This PR does not follow contributing guidelines label Nov 6, 2023
Comment on lines 595 to 602
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,
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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()),
)
});

Copy link
Contributor Author

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

Copy link
Member

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|)

Comment on lines 630 to 635
let connector_response = match connector_response_update {
Some(connector_response_update) => {
connector_response_update.apply_changeset(connector_response.clone())
}
None => connector_response,
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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())
});

@jarnura jarnura merged commit 35173a1 into pref/pool Nov 7, 2023
8 of 11 checks passed
@jarnura jarnura deleted the 3059-group-concurrent-calls-post-update branch November 7, 2023 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants