Skip to content

Commit

Permalink
Merge pull request #334 from congyuluo/identifier_refactorings
Browse files Browse the repository at this point in the history
Refactored Identifiers
  • Loading branch information
Sunagatov authored Aug 20, 2024
2 parents e6f81a7 + 699c453 commit 4a7c198
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ private List<ShoppingCartItem> createItems(Set<NewShoppingCartItemDto> itemsToAd
Map<UUID, Integer> productsWithQuantity = itemsToAdd.stream()
.collect(Collectors.toMap(NewShoppingCartItemDto::getProductId, NewShoppingCartItemDto::getProductQuantity));

Set<UUID> existedProductIds = shoppingCart.getItems().stream()
Set<UUID> existingProductIds = shoppingCart.getItems().stream()
.map(ShoppingCartItem::getProductInfo)
.map(ProductInfo::getProductId)
.collect(Collectors.toSet());

Set<UUID> newProductIds = productsWithQuantity.keySet().stream()
.filter(productId -> !existedProductIds.contains(productId))
.filter(productId -> !existingProductIds.contains(productId))
.collect(Collectors.toSet());

return productInfoRepository.findAllById(newProductIds).stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public TimeTokenException(String email, OffsetDateTime expireTime) {

private static String buildMessageError(String email, OffsetDateTime expireTime) {
StringBuilder stringBuilder = new StringBuilder();
Duration restTime = Duration.between(OffsetDateTime.now(), expireTime);
long minutes = restTime.toMinutesPart();
long seconds = restTime.toSecondsPart();
Duration remainingTime = Duration.between(OffsetDateTime.now(), expireTime);
long minutes = remainingTime.toMinutesPart();
long seconds = remainingTime.toSecondsPart();

stringBuilder.append("Token for email '").append(email).append("' will be expired after: ");
if (minutes != 0) {
Expand Down

0 comments on commit 4a7c198

Please sign in to comment.