diff --git a/src/main/java/org/sunbird/halloffame/service/HallOfFameServiceImpl.java b/src/main/java/org/sunbird/halloffame/service/HallOfFameServiceImpl.java index 182a81f83..8669b56dd 100644 --- a/src/main/java/org/sunbird/halloffame/service/HallOfFameServiceImpl.java +++ b/src/main/java/org/sunbird/halloffame/service/HallOfFameServiceImpl.java @@ -31,12 +31,20 @@ public Map fetchHallOfFameData() { int lastMonthYearValue = lastMonthDate.getYear(); String formattedDateLastMonth = currentDate.minusMonths(1).format(DateTimeFormatter.ofPattern("MMMM yyyy")); - Map propertymap = new HashMap<>(); - propertymap.put(Constants.MONTH, lastMonthValue); - propertymap.put(Constants.YEAR, lastMonthYearValue); + Map propertyMap = new HashMap<>(); + propertyMap.put(Constants.MONTH, lastMonthValue); + propertyMap.put(Constants.YEAR, lastMonthYearValue); List> dptList = cassandraOperation.getRecordsByPropertiesWithoutFiltering( - Constants.KEYSPACE_SUNBIRD, Constants.MDO_KARMA_POINTS, propertymap, null); + Constants.KEYSPACE_SUNBIRD, Constants.MDO_KARMA_POINTS, propertyMap, null); + if (dptList.isEmpty()) { + formattedDateLastMonth = currentDate.minusMonths(2).format(DateTimeFormatter.ofPattern("MMMM yyyy")); + propertyMap.clear(); + propertyMap.put(Constants.MONTH, currentDate.minusMonths(2).getMonthValue()); + propertyMap.put(Constants.YEAR, currentDate.minusMonths(2).getYear()); + dptList = cassandraOperation.getRecordsByPropertiesWithoutFiltering( + Constants.KEYSPACE_SUNBIRD, Constants.MDO_KARMA_POINTS, propertyMap, null); + } resultMap.put(Constants.MDO_LIST, dptList); resultMap.put(Constants.TITLE, formattedDateLastMonth); return resultMap;