Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(support): fixing merge overwrite #475

Merged
merged 29 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
efe0ef2
fix(deps): update dependency com.nimbusds:nimbus-jose-jwt to v9.46 (#…
renovate[bot] Nov 18, 2024
c4ccfe8
chore: removing old and unused class reference
paulushcgcj Nov 18, 2024
83cd8e2
fix(SILVA-570): fixing recent openings
paulushcgcj Nov 19, 2024
327b0f5
chore: fixing cors issue
paulushcgcj Nov 18, 2024
814df17
fix: fixing wrong param passed
paulushcgcj Nov 18, 2024
3b8e1bb
fix: fixing wrong parameter
paulushcgcj Nov 18, 2024
51522ef
fix: making ALLOWED_ORIGINS required without a default value
paulushcgcj Nov 18, 2024
3e3350b
chore: forcing new build
paulushcgcj Nov 18, 2024
1e20026
chore: forcing new build
paulushcgcj Nov 18, 2024
fd9e58d
fix(SILVA-502): fixing map on silviculture search screen (#472)
paulushcgcj Nov 19, 2024
4abbc07
chore: fixing cors issue (#473)
paulushcgcj Nov 18, 2024
d57c1ea
Merge branch 'main' into support/resore
paulushcgcj Nov 19, 2024
15c3b75
chore: updated package lock
paulushcgcj Nov 19, 2024
ce534da
Merge remote-tracking branch 'origin/support/resore' into support/resore
paulushcgcj Nov 19, 2024
a1f8f7f
chore: fixing file
paulushcgcj Nov 19, 2024
0d14529
fix(SILVA-558): removing unused backend code
paulushcgcj Nov 19, 2024
484ca7c
fix(SILVA-570): fixing backend issues for recent openings
paulushcgcj Nov 19, 2024
77ee67b
test(SILVA-570): fixing tests
paulushcgcj Nov 19, 2024
d8031d7
fix(SILVA-538): fixing FRPA query filter
paulushcgcj Nov 19, 2024
7e9a4bc
test: fixing test
paulushcgcj Nov 19, 2024
41e3b0f
fix(SILVA-538): fixing FRPA parameter
paulushcgcj Nov 19, 2024
bbf4d9a
chore: updating route for PRs
paulushcgcj Nov 19, 2024
4934714
test: fixing tests
paulushcgcj Nov 19, 2024
5d2ade1
chore: reducing code duplication
paulushcgcj Nov 19, 2024
8c5504c
chore: fixing sonar issues
paulushcgcj Nov 19, 2024
c94a1e6
chore: added notification to error cases
paulushcgcj Nov 19, 2024
6dd766e
chore: updating commingsoon component
paulushcgcj Nov 19, 2024
c4d344a
chore: changing oracle pool
paulushcgcj Nov 19, 2024
9647508
Use route output in pr-open
DerekRoberts Nov 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -50,56 +50,6 @@ public class OpeningService {

private final ForestClientApiProvider forestClientApiProvider;

/**
* Gets all recent openings for the Home Screen.
*
* @param pagination A {@link PaginationParameters} with pagination settings.
* @return {@link List} of {@link RecentOpeningDto} containing all recent openings for that user.
*/
public PaginatedResult<RecentOpeningDto> getRecentOpeningsCurrentUser(
PaginationParameters pagination) {
log.info(
"Getting recent openings to logged user with page index {} and page size {}",
pagination.page(),
pagination.perPage());

if (pagination.perPage() > SilvaConstants.MAX_PAGE_SIZE) {
throw new MaxPageSizeException(SilvaConstants.MAX_PAGE_SIZE);
}

String entryUserId = loggedUserService.getLoggedUserId();

// Openings
Pageable pageable =
PageRequest.of(
pagination.page(), pagination.perPage(), Sort.by("updateTimestamp").descending());
Page<OpeningEntity> openingPage = openingRepository.findAllByEntryUserId(entryUserId, pageable);

PaginatedResult<RecentOpeningDto> paginatedResult = new PaginatedResult<>();
paginatedResult.setPageIndex(pagination.page());
paginatedResult.setPerPage(pagination.perPage());

if (openingPage.getContent().isEmpty()) {
log.info("No recent openings for this user given page index and size!");
paginatedResult.setData(List.of());
paginatedResult.setTotalPages(0);
paginatedResult.setHasNextPage(false);
return paginatedResult;
}

// Cut Block Open Admin
List<Long> openingIds = openingPage.getContent().stream().map(OpeningEntity::getId).toList();
List<CutBlockOpenAdminEntity> cutBlocks =
cutBlockOpenAdminService.findAllByOpeningIdIn(openingIds);

List<RecentOpeningDto> list = createDtoFromEntity(openingPage.getContent(), cutBlocks);
paginatedResult.setData(list);
paginatedResult.setTotalPages(openingPage.getTotalPages());
paginatedResult.setHasNextPage(openingPage.hasNext());

return paginatedResult;
}

/**
* Get recent openings given the opening creation date.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
import ca.bc.gov.restapi.results.postgres.dto.UserRecentOpeningDto;
import ca.bc.gov.restapi.results.postgres.entity.UserRecentOpeningEntity;
import ca.bc.gov.restapi.results.postgres.repository.UserRecentOpeningRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Map;
import java.util.stream.Collectors;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
Expand Down Expand Up @@ -79,20 +78,23 @@ public PaginatedResult<OpeningSearchResponseDto> getAllRecentOpeningsForUser(int
.findByUserIdOrderByLastViewedDesc(userId, pageable);

// Extract opening IDs as String
Map<String,LocalDateTime> openingIds = recentOpenings.getContent().stream()
Map<String, LocalDateTime> openingIds = recentOpenings.getContent().stream()
.collect(Collectors.toMap(UserRecentOpeningEntity::getOpeningId, UserRecentOpeningEntity::getLastViewed));
log.info("User with the userId {} has the following openindIds {}", userId, openingIds);
log.info("User with the userId {} has the following openingIds {}", userId, openingIds);

if (openingIds.isEmpty()) {
return new PaginatedResult<>();
// Ensure an empty data list instead of null
return new PaginatedResult<OpeningSearchResponseDto>()
.withData(Collections.emptyList());
}

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

return pageResult
.withData(
pageResult
Expand All @@ -104,4 +106,5 @@ public PaginatedResult<OpeningSearchResponseDto> getAllRecentOpeningsForUser(int
);
}


}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
Expand All @@ -44,39 +43,6 @@ class OpeningServiceTest extends AbstractTestContainerIntegrationTest {
@Autowired
private OpeningService openingService;

@Test
@DisplayName("Get a list of recent openings for logged user")
void getRecentOpenings_fetchPaginated_shouldSucceed() {
int pages = 3;
int currentPage = 0;

PaginationParameters pagination = new PaginationParameters(currentPage, pages);
PaginatedResult<RecentOpeningDto> paginatedResult =
openingService.getRecentOpeningsCurrentUser(pagination);

Assertions.assertNotNull(paginatedResult);
Assertions.assertEquals(currentPage, paginatedResult.getPageIndex());
Assertions.assertEquals(1, paginatedResult.getTotalPages());
Assertions.assertFalse(paginatedResult.getData().isEmpty());
Assertions.assertEquals(1, paginatedResult.getData().size());
}

@Test
@DisplayName("Get an empty list of recent openings for the home screen")
void getRecentOpenings_emptyPages_shouldSucceed() {

int currentPage = 0;
int pages = 1;
PaginationParameters pagination = new PaginationParameters(currentPage, pages);
PaginatedResult<RecentOpeningDto> paginatedResult =
openingService.getRecentOpeningsCurrentUser(pagination);

Assertions.assertNotNull(paginatedResult);
Assertions.assertEquals(currentPage, paginatedResult.getPageIndex());
Assertions.assertEquals(1, paginatedResult.getTotalPages());
Assertions.assertFalse(paginatedResult.getData().isEmpty());
}

@Test
@DisplayName("Get a list of recent openings without user")
void getRecentOpenings_fetchNoUserPaginated_shouldSucceed() {
Expand Down
Loading
Loading