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

fix(mojaloop/#3564): move get queries outside of transaction #316

Closed
wants to merge 3 commits into from

Conversation

kleyow
Copy link
Contributor

@kleyow kleyow commented Oct 10, 2023

fix(mojaloop/#3564): move get queries outside of transaction - https://app.zenhub.com/workspaces/mojaloop-project-59edee71d1407922110cf083/issues/gh/mojaloop/project/3564

  • Move get queries before transaction is opened.

@kleyow kleyow marked this pull request as ready for review October 11, 2023 12:47
@@ -287,6 +274,36 @@ class QuotesModel {
// get amount type
refs.amountTypeId = await this.db.getAmountType(quoteRequest.amountType)

// get various enum ids (async, as parallel as possible)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could group a lot of these db requests/inserts but the code may look scary, for example.

        ;[
          refs.transactionInitiatorTypeId,
          refs.transactionInitiatorId,
          refs.transactionScenarioId,
          refs.amountTypeId,
          payerEnumVals[0],
          payerEnumVals[1],
          payerEnumVals[2],
          payerEnumVals[3],
          payerEnumVals[4],
          payeeEnumVals[0],
          payeeEnumVals[1],
          payeeEnumVals[2],
          payeeEnumVals[3],
          payeeEnumVals[4]
        ] = await Promise.all([
          this.db.getInitiatorType(quoteRequest.transactionType.initiatorType),
          this.db.getInitiator(quoteRequest.transactionType.initiator),
          this.db.getScenario(quoteRequest.transactionType.scenario),
          this.db.getAmountType(quoteRequest.amountType),
          this.db.getPartyType(LOCAL_ENUM.PAYER),
          this.db.getPartyIdentifierType(quoteRequest.payer.partyIdInfo.partyIdType),
          this.db.getParticipantByName(quoteRequest.payer.partyIdInfo.fspId),
          this.db.getTransferParticipantRoleType(LOCAL_ENUM.PAYER_DFSP),
          this.db.getLedgerEntryType(LOCAL_ENUM.PRINCIPLE_VALUE),
          this.db.getPartyType(LOCAL_ENUM.PAYEE),
          this.db.getPartyIdentifierType(quoteRequest.payee.partyIdInfo.partyIdType),
          this.db.getParticipantByName(quoteRequest.payee.partyIdInfo.fspId),
          this.db.getTransferParticipantRoleType(LOCAL_ENUM.PAYEE_DFSP),
          this.db.getLedgerEntryType(LOCAL_ENUM.PRINCIPLE_VALUE)
        ])
        ;[
          refs.payerId,
          refs.payeeId
        ] = await Promise.all([
          this.db.createPayerQuoteParty(txn, refs.quoteId, quoteRequest.payer,
            quoteRequest.amount.amount, quoteRequest.amount.currency, payerEnumVals),
          this.db.createPayeeQuoteParty(txn, refs.quoteId, quoteRequest.payee,
            quoteRequest.amount.amount, quoteRequest.amount.currency, payeeEnumVals)
        ])

@kleyow kleyow closed this Oct 12, 2023
@kleyow kleyow deleted the fix/3564-transaction branch October 12, 2023 17:33
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.

1 participant