Skip to content

Commit

Permalink
chore: code changes
Browse files Browse the repository at this point in the history
  • Loading branch information
paulushcgcj committed Nov 8, 2024
1 parent ec5c476 commit 4fcb87b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public OpeningSearchFiltersDto(
this.statusList = new ArrayList<>();
this.openingIds = openingIds;
this.myOpenings = null;
this.submittedToFrpa = false;
this.submittedToFrpa = null;
this.disturbanceDateStart = null;
this.disturbanceDateEnd = null;
this.regenDelayDateStart = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,28 +80,28 @@ public PaginatedResult<OpeningSearchResponseDto> getAllRecentOpeningsForUser(int

// Extract opening IDs as String
Map<String,LocalDateTime> openingIds = recentOpenings.getContent().stream()
//.map(opening -> String.valueOf(opening.getOpeningId())) // Convert Integer to String
//.collect(Collectors.toList());
.collect(Collectors.toMap(UserRecentOpeningEntity::getOpeningId, UserRecentOpeningEntity::getLastViewed));
log.info("User with the userId {} has the following openindIds {}", userId, openingIds);
if (openingIds.isEmpty()) {
return new PaginatedResult<>();
}
// Call the oracle service method to fetch opening details for the given opening IDs
//convert the openingIds to a list of strings and pass it to the OpeningSearchFiltersDto constructor
OpeningSearchFiltersDto filtersDto = new OpeningSearchFiltersDto(new ArrayList<>(openingIds.keySet()));
PaginationParameters paginationParameters = new PaginationParameters(0, 10);
PaginatedResult<OpeningSearchResponseDto> pageResult = openingService.openingSearch(filtersDto, paginationParameters);
// perform the sorting and set the lastViewDate to the OpeningSearchResponseDto
pageResult.setData(
pageResult
.getData()
.stream()
.peek(result -> result.setLastViewDate(openingIds.get(result.getOpeningId().toString())))
.sorted(Comparator.comparing(OpeningSearchResponseDto::getLastViewDate).reversed())
.collect(Collectors.toList())
);
return pageResult;

PaginatedResult<OpeningSearchResponseDto> pageResult =
openingService
.openingSearch(
new OpeningSearchFiltersDto(new ArrayList<>(openingIds.keySet())),
new PaginationParameters(0, 10)
);

return pageResult
.withData(
pageResult
.getData()
.stream()
.peek(result -> result.setLastViewDate(openingIds.get(result.getOpeningId().toString())))
.sorted(Comparator.comparing(OpeningSearchResponseDto::getLastViewDate).reversed())
.collect(Collectors.toList())
);
}

}

0 comments on commit 4fcb87b

Please sign in to comment.