From 70cad9eac8f8a2b6b12d21d6eb97b009fcdb9b94 Mon Sep 17 00:00:00 2001 From: shankaragoudab <140387294+shankaragoudab@users.noreply.github.com> Date: Tue, 9 Jan 2024 17:31:52 +0530 Subject: [PATCH] Month format fix for Hall of fame Api --- .../halloffame/service/HallOfFameServiceImpl.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/sunbird/halloffame/service/HallOfFameServiceImpl.java b/src/main/java/org/sunbird/halloffame/service/HallOfFameServiceImpl.java index 157fc60bb..b1b45e904 100644 --- a/src/main/java/org/sunbird/halloffame/service/HallOfFameServiceImpl.java +++ b/src/main/java/org/sunbird/halloffame/service/HallOfFameServiceImpl.java @@ -33,7 +33,7 @@ public Map fetchHallOfFameData() { int previousToLastMonth = lastToPreviousMonthDate.getMonthValue(); int previousToLastMonthsYearValue = lastToPreviousMonthDate.getYear(); - String formattedDate = currentDate.format(DateTimeFormatter.ofPattern("MMMM yyyy")); + String formattedDateLastMonth = currentDate.minusMonths(1).format(DateTimeFormatter.ofPattern("MMMM yyyy")); Map propertymap = new HashMap<>(); List monthList = Arrays.asList(lastMonthValue, previousToLastMonth); propertymap.put(Constants.MONTH, monthList); @@ -57,7 +57,7 @@ public Map fetchHallOfFameData() { .collect(Collectors.toList()); if (lastToPreviousMonthList.isEmpty() && !lastMonthList.isEmpty()) { - resultMap.put(Constants.TITLE, formattedDate); + resultMap.put(Constants.TITLE, formattedDateLastMonth); Map> monthWithRankList = processRankBasedOnKpPoints(lastMonthList); List> trialmapList = monthWithRankList.values().stream() @@ -72,6 +72,7 @@ public Map fetchHallOfFameData() { return resultMap; } if (lastMonthList.isEmpty()) { + String formattedDatePreviousToLastMonth = LocalDate.now().minusMonths(2).format(DateTimeFormatter.ofPattern("MMMM yyyy")); int pvsToLastMonth = LocalDate.now().minusMonths(2).getMonthValue(); int pvsToLastMonthsYear = LocalDate.now().minusMonths(2).getYear(); int previousToLastTwoMonths = LocalDate.now().minusMonths(3).getMonthValue(); @@ -94,6 +95,7 @@ public Map fetchHallOfFameData() { .filter(record -> ((int) record.get(Constants.MONTH)) == pvsToLastMonth && ((int) record.get(Constants.YEAR)) == pvsToLastMonthsYear) .collect(Collectors.toList()); + resultMap.put(Constants.TITLE,formattedDatePreviousToLastMonth); } Map> lastMonthWithRankList = processRankBasedOnKpPoints(lastMonthList); @@ -119,7 +121,9 @@ public Map fetchHallOfFameData() { return trialmap; }) .collect(Collectors.toList()); - resultMap.put(Constants.TITLE, formattedDate); + if (!resultMap.containsKey(Constants.TITLE)) { + resultMap.put(Constants.TITLE, formattedDateLastMonth); + } resultMap.put(Constants.MDO_LIST, trialmapList); return resultMap; }