From 4fcb87b4b1de10a3c9ee0c547a6e56683929d194 Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Fri, 8 Nov 2024 08:45:21 -0800 Subject: [PATCH] chore: code changes --- .../oracle/dto/OpeningSearchFiltersDto.java | 2 +- .../service/UserRecentOpeningService.java | 34 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/oracle/dto/OpeningSearchFiltersDto.java b/backend/src/main/java/ca/bc/gov/restapi/results/oracle/dto/OpeningSearchFiltersDto.java index 453af52b..b1444222 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/oracle/dto/OpeningSearchFiltersDto.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/oracle/dto/OpeningSearchFiltersDto.java @@ -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; diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/postgres/service/UserRecentOpeningService.java b/backend/src/main/java/ca/bc/gov/restapi/results/postgres/service/UserRecentOpeningService.java index 3068401f..c5e219d5 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/postgres/service/UserRecentOpeningService.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/postgres/service/UserRecentOpeningService.java @@ -80,28 +80,28 @@ public PaginatedResult getAllRecentOpeningsForUser(int // Extract opening IDs as String Map 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 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 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()) + ); } }