Aman-Mittal commented on code in PR #5400:
URL: https://github.com/apache/fineract/pull/5400#discussion_r2747285927


##########
fineract-provider/src/main/java/org/apache/fineract/cob/savings/RetrieveSavingsIdServiceImpl.java:
##########
@@ -0,0 +1,118 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.cob.savings;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import lombok.RequiredArgsConstructor;
+import org.apache.fineract.cob.data.COBIdAndExternalIdAndAccountNo;
+import org.apache.fineract.cob.data.COBIdAndLastClosedBusinessDate;
+import org.apache.fineract.cob.data.COBParameter;
+import org.apache.fineract.cob.data.COBPartition;
+import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
+import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
+import org.apache.fineract.portfolio.savings.domain.SavingsAccountRepository;
+import org.apache.fineract.portfolio.savings.domain.SavingsAccountStatusType;
+import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
+import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
+import org.springframework.stereotype.Service;
+
+@Service
+@RequiredArgsConstructor
+public class RetrieveSavingsIdServiceImpl implements RetrieveSavingsIdService {
+
+    private static final Collection<Integer> NON_CLOSED_SAVINGS_STATUSES = new 
ArrayList<>(
+            
Arrays.asList(SavingsAccountStatusType.SUBMITTED_AND_PENDING_APPROVAL.getValue(),
 SavingsAccountStatusType.APPROVED.getValue(),
+                    SavingsAccountStatusType.ACTIVE.getValue(), 
SavingsAccountStatusType.TRANSFER_IN_PROGRESS.getValue(),
+                    SavingsAccountStatusType.TRANSFER_ON_HOLD.getValue()));
+
+    private final SavingsAccountRepository savingsAccountRepository;
+    private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
+
+    @Override
+    public List<COBPartition> retrieveSavingsCOBPartitions(Long numberOfDays, 
LocalDate businessDate, boolean isCatchUp,
+            int partitionSize) {

Review Comment:
   I think you can refractor it like this
   
   StringBuilder sql = new StringBuilder();
   
   sql.append("""
           select min(id) as min,
                  max(id) as max,
                  page,
                  count(id) as count
           from (
               select floor(((row_number() over(order by id)) - 1) / :pageSize) 
as page, t.*
               from (
                   select id
                   from m_savings_account
                   where status_enum in (:statusIds)
                     and 
           """);
   
   if (isCatchUp) {
       sql.append("last_closed_business_date = :businessDate\n");
   } else {
       sql.append("(last_closed_business_date = :businessDate or 
last_closed_business_date is null)\n");
   }
   
   sql.append("""
                   order by id
               ) t
           ) t2
           group by page
           order by page
           """);
   
   This will make this more readable



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to