diff --git a/avni-server-api/src/main/java/org/avni/server/service/IndividualSearchService.java b/avni-server-api/src/main/java/org/avni/server/service/IndividualSearchService.java index 84dd2bdcd..d6055b64f 100644 --- a/avni-server-api/src/main/java/org/avni/server/service/IndividualSearchService.java +++ b/avni-server-api/src/main/java/org/avni/server/service/IndividualSearchService.java @@ -36,11 +36,12 @@ public LinkedHashMap search(SubjectSearchRequest subjectSearchRe logger.info("Searching for individuals"); List> searchResults = subjectSearchRepository.search(subjectSearchRequest, new SubjectSearchQueryBuilder()); long resultsEnd = new DateTime().getMillis(); + BigInteger totalCount = subjectSearchRequest.getIncludeDisplayCount().booleanValue() == true ? subjectSearchRepository.getTotalCount(subjectSearchRequest, new SubjectSearchQueryBuilder()) : new BigInteger("-1"); logger.info(String.format("Subject search: Time Taken: %dms. Sorted: %s", (resultsEnd - startTime), subjectSearchRequest.getPageElement().getSortColumn())); - return constructIndividual(searchResults); + return constructIndividual(searchResults,totalCount); } - private LinkedHashMap constructIndividual(List> individualList) { + private LinkedHashMap constructIndividual(List> individualList,BigInteger totalCount) { LinkedHashMap recordsMap = new LinkedHashMap(); List individualIds = individualList.stream() .map(individualRecord -> Long.valueOf((Integer) individualRecord.get("id"))) @@ -64,6 +65,7 @@ private LinkedHashMap constructIndividual(List addressIds = new ArrayList<>(); private List concept; private List gender; @@ -56,6 +57,14 @@ public void setIncludeVoided(Boolean includeVoided) { this.includeVoided = includeVoided; } + public Boolean getIncludeDisplayCount() { + return includeDisplayCount; + } + + public void setIncludeDisplayCount(Boolean includeDisplayCount) { + this.includeDisplayCount = includeDisplayCount; + } + public List getAddressIds() { return addressIds; }