Skip to content

Commit

Permalink
Month format fix for Hall of fame Api
Browse files Browse the repository at this point in the history
  • Loading branch information
shankaragoudab committed Jan 9, 2024
1 parent c8702b1 commit 70cad9e
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public Map<String, Object> 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<String, Object> propertymap = new HashMap<>();
List<Object> monthList = Arrays.asList(lastMonthValue, previousToLastMonth);
propertymap.put(Constants.MONTH, monthList);
Expand All @@ -57,7 +57,7 @@ public Map<String, Object> fetchHallOfFameData() {
.collect(Collectors.toList());

if (lastToPreviousMonthList.isEmpty() && !lastMonthList.isEmpty()) {
resultMap.put(Constants.TITLE, formattedDate);
resultMap.put(Constants.TITLE, formattedDateLastMonth);
Map<String, Map<String, Object>> monthWithRankList = processRankBasedOnKpPoints(lastMonthList);

List<Map<String, Object>> trialmapList = monthWithRankList.values().stream()
Expand All @@ -72,6 +72,7 @@ public Map<String, Object> 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();
Expand All @@ -94,6 +95,7 @@ public Map<String, Object> fetchHallOfFameData() {
.filter(record -> ((int) record.get(Constants.MONTH)) == pvsToLastMonth
&& ((int) record.get(Constants.YEAR)) == pvsToLastMonthsYear)
.collect(Collectors.toList());
resultMap.put(Constants.TITLE,formattedDatePreviousToLastMonth);
}

Map<String, Map<String, Object>> lastMonthWithRankList = processRankBasedOnKpPoints(lastMonthList);
Expand All @@ -119,7 +121,9 @@ public Map<String, Object> 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;
}
Expand Down

0 comments on commit 70cad9e

Please sign in to comment.