Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/118#discussion_r66388686
  
    --- Diff: 
fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsSchedularServiceImpl.java
 ---
    @@ -37,42 +40,66 @@
     
         private final SavingsAccountAssembler savingAccountAssembler;
         private final SavingsAccountWritePlatformService 
savingsAccountWritePlatformService;
    -    private final SavingsAccountRepository savingAccountRepository;
         private final SavingsAccountReadPlatformService 
savingAccountReadPlatformService;
     
         @Autowired
         public SavingsSchedularServiceImpl(final SavingsAccountAssembler 
savingAccountAssembler,
                 final SavingsAccountWritePlatformService 
savingsAccountWritePlatformService,
    -            final SavingsAccountRepository savingAccountRepository,
                 final SavingsAccountReadPlatformService 
savingAccountReadPlatformService) {
             this.savingAccountAssembler = savingAccountAssembler;
             this.savingsAccountWritePlatformService = 
savingsAccountWritePlatformService;
    -        this.savingAccountRepository = savingAccountRepository;
             this.savingAccountReadPlatformService = 
savingAccountReadPlatformService;
         }
     
    -    @CronTarget(jobName = JobName.POST_INTEREST_FOR_SAVINGS)
    -    @Override
    -    public void postInterestForAccounts() throws JobExecutionException {
    -        final List<SavingsAccount> savingsAccounts = 
this.savingAccountRepository.findSavingAccountByStatus(SavingsAccountStatusType.ACTIVE
    -                .getValue());
    -        StringBuffer sb = new StringBuffer();
    -        for (final SavingsAccount savingsAccount : savingsAccounts) {
    -            try {
    -                
this.savingAccountAssembler.assignSavingAccountHelpers(savingsAccount);
    -                
this.savingsAccountWritePlatformService.postInterest(savingsAccount);
    -            } catch (Exception e) {
    -                Throwable realCause = e;
    -                if (e.getCause() != null) {
    -                    realCause = e.getCause();
    -                }
    -                sb.append("failed to post interest for Savings with id " + 
savingsAccount.getId() + " with message "
    -                        + realCause.getMessage());
    -            }
    -        }
    -        
    -        if (sb.length() > 0) { throw new 
JobExecutionException(sb.toString()); }
    -    }
    +   @Transactional
    +   @CronTarget(jobName = JobName.POST_INTEREST_FOR_SAVINGS)
    +   @Override
    +   public void postInterestForAccounts() throws JobExecutionException {
    +           final int maxPazeSize = 100;
    +           boolean hasErrorOccurred = false;
    +           int offSet = 1;
    +           Integer initialSize = 100;
    +           final Integer status = 
SavingsAccountStatusType.ACTIVE.getValue();
    +           
    +           
    +           do {
    +                   Page<SavingsAccountData> savingsAccounts = 
this.savingAccountReadPlatformService.retrieveSavingsAccount(maxPazeSize, 
offSet,
    --- End diff --
    
    By reading Savings Account Entities page wise, you can avoid lot of db 
calls.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to