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

[MODFIN-391]. Minimize amount of requests to retrieve transactions for ledger #270

Merged
merged 7 commits into from
Jan 9, 2025

Conversation

BKadirkhodjaev
Copy link
Contributor

Purpose

Approach

  • Create a new service which will fetch aggregated transaction totals from storage and use it in Ledger total calculation
  • Update LedgerTotalsService to use new TransactionTotalService instead of TransactionService

@BKadirkhodjaev BKadirkhodjaev requested a review from a team January 6, 2025 12:15
@BKadirkhodjaev BKadirkhodjaev marked this pull request as ready for review January 6, 2025 12:15
@BKadirkhodjaev BKadirkhodjaev changed the title [MODFIN-391]. Minimize amount of requests to retrieve transactions fo… [MODFIN-391]. Minimize amount of requests to retrieve transactions for ledger Jan 7, 2025

private List<TransactionTotal> filterFundIdsByAllocationDirection(List<String> fundIds, List<TransactionTotal> transactions, String direction) {
// Note that here getToFundId() is used when direction is from (a negation is used afterward)
Function<TransactionTotal, String> getFundId = "from".equals(direction) ? TransactionTotal::getToFundId : TransactionTotal::getFromFundId;
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume it should be

"from".equals(direction) ? TransactionTotal::getFromFundId : TransactionTotal::getToFundId;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assume it should be

"from".equals(direction) ? TransactionTotal::getFromFundId : TransactionTotal::getToFundId;

I think it was intentional like this, this code is taken from TransactionService

String fundIdField = "from".equals(direction) ? "fromFundId" : "toFundId";
String fundQuery = convertIdsToCqlQuery(fundIds, fundIdField, "==", " OR ");
List<String> trTypeValues = trTypes.stream().map(TransactionTotal.TransactionType::value).toList();
String trTypeQuery = convertIdsToCqlQuery(trTypeValues, "transactionType", "==", " OR ");
Copy link
Contributor

Choose a reason for hiding this comment

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

from method name we are incorrectly using this by setting type value, better to use other method or create new one which take value and fieldName only


public Future<List<TransactionTotal>> getTransactionsToFunds(List<String> fundIds, String fiscalYearId,
List<TransactionTotal.TransactionType> trTypes, RequestContext requestContext) {
return getTransactionsFromOrToFunds(fundIds, fiscalYearId, trTypes, "to", requestContext);
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest to use string variable instead as static or enum variable

@BKadirkhodjaev BKadirkhodjaev merged commit 928b147 into master Jan 9, 2025
6 checks passed
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