Skip to content

Commit

Permalink
limit offset change
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhang-eGov committed Dec 18, 2024
1 parent 710920d commit d696e38
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,24 @@ public class HouseholdRepository {
public Tuple<Long, List<Household>> findByViewCLF(String localityCode, Integer limit, Integer offset, String tenantId, Long lastModifiedTime, String householdId) {
String query = null;
Map<String, Object> paramsMap = new HashMap<>();
Long totalCount = null;

query = "select * from household_address_clf_mv where localitycode=:localitycode and rank between :start and :end ";
query = "select * from household_address_clf_mv where localitycode=:localitycode ";
if (StringUtils.hasLength(householdId)) {
query = query + " and id=:id";
paramsMap.put("id", householdId);
} else {
paramsMap.put("start", offset);
paramsMap.put("end", offset+limit);
query = query + " and rank between :start and :end ";

Map<String, Object> paramsMapCount = new HashMap<>();
paramsMapCount.put("localitycode", localityCode);
paramsMapCount.put("lastModifiedTime", lastModifiedTime);
Integer maxRank = namedParameterJdbcTemplate.queryForObject("select max(rank) from household_address_clf_mv where localitycode=:localitycode and lastModifiedTime>=:lastModifiedTime", paramsMapCount, Integer.class);
totalCount = maxRank == null ? 0L : Long.valueOf(maxRank);
}
paramsMap.put("localitycode", localityCode);
paramsMap.put("start", offset);
paramsMap.put("end", offset+limit);

Map<String, Object> paramsMapCount = new HashMap<>();
paramsMapCount.put("localitycode", localityCode);
paramsMapCount.put("lastModifiedTime", lastModifiedTime);


Integer maxRank = namedParameterJdbcTemplate.queryForObject("select max(rank) from household_address_clf_mv where localitycode=:localitycode and lastModifiedTime>=:lastModifiedTime", paramsMapCount, Integer.class);
Long totalCount = maxRank == null ? 0L : Long.valueOf(maxRank);
return new Tuple<>(totalCount, this.namedParameterJdbcTemplate.query(query, paramsMap, householdRowMapper));

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ public Downsync prepareDownsyncData(DownsyncRequest downsyncRequest, boolean isC
List<Household> households = null;
if (isCLF) {
households = searchHouseholdsCLF(downsyncRequest);
downsyncCriteria.setTotalCount(null);
}else {
householdIds = searchHouseholds(downsyncRequest, downsync);
}
Expand Down

0 comments on commit d696e38

Please sign in to comment.