You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by "taskain7 (via GitHub)" <gi...@apache.org> on 2023/04/12 09:29:22 UTC

[GitHub] [fineract] taskain7 commented on a diff in pull request #3112: [FINERACT-1678] Exclude loan IDs from execution context

taskain7 commented on code in PR #3112:
URL: https://github.com/apache/fineract/pull/3112#discussion_r1163869860


##########
fineract-provider/src/main/java/org/apache/fineract/cob/loan/FetchAndLockLoanTasklet.java:
##########
@@ -46,67 +40,44 @@ public class FetchAndLockLoanTasklet implements Tasklet {
 
     private static final Long NUMBER_OF_DAYS_BEHIND = 1L;
 
-    private final LoanAccountLockRepository loanAccountLockRepository;
-
     private final RetrieveLoanIdService retrieveLoanIdService;
 
-    private final FineractProperties fineractProperties;
-
     private final JdbcTemplate jdbcTemplate;
 
     @Override
     public RepeatStatus execute(@NotNull StepContribution contribution, @NotNull ChunkContext chunkContext) throws Exception {
         String businessDateParameter = (String) contribution.getStepExecution().getJobExecution().getExecutionContext()
                 .get(LoanCOBConstant.BUSINESS_DATE_PARAMETER_NAME);
         LocalDate businessDate = LocalDate.parse(Objects.requireNonNull(businessDateParameter));
-        List<Long> allNonClosedLoanIds = retrieveLoanIdService.retrieveLoanIdsNDaysBehind(NUMBER_OF_DAYS_BEHIND, businessDate);
-        if (allNonClosedLoanIds.isEmpty()) {
-            contribution.getStepExecution().getJobExecution().getExecutionContext().put(LoanCOBConstant.LOAN_IDS, Collections.emptyList());
+        LoanCOBMinANdMaxLoanId minAndMaxLoanId = retrieveLoanIdService.retrieveMinAndMaxLoanIdsNDaysBehind(NUMBER_OF_DAYS_BEHIND,
+                businessDate);
+        if (Objects.isNull(minAndMaxLoanId)
+                || (Objects.isNull(minAndMaxLoanId.getMinLoanId()) && Objects.isNull(minAndMaxLoanId.getMaxLoanId()))) {
+            contribution.getStepExecution().getJobExecution().getExecutionContext().put(LoanCOBConstant.LOAN_IDS, null);
             return RepeatStatus.FINISHED;
         }
-        List<Long> remainingIds = new ArrayList<>(allNonClosedLoanIds);
-
-        List<List<Long>> remainingIdPartitions = Lists.partition(remainingIds, getInClauseParameterSizeLimit());
-        List<LoanAccountLock> loanAccountLocks = new ArrayList<>();
-        remainingIdPartitions.forEach(
-                remainingIdPartition -> loanAccountLocks.addAll(loanAccountLockRepository.findAllByLoanIdIn(remainingIdPartition)));
-

Review Comment:
   native query, that places the locks covers them



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org