Skip to content

Commit

Permalink
Merge pull request #725 from bounswe/backend/review-char-limit-fix
Browse files Browse the repository at this point in the history
review char limit fix
  • Loading branch information
zeynep-baydemir authored Nov 15, 2023
2 parents 292aab2 + 6f6f24a commit 4eee7ad
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@Setter
public class CreateReviewRequestDto {

@Size(max = 150, message = "Description must be at most 150 characters long")
@Size(max = 300, message = "Description must be at most 300 characters long")
private String reviewDescription = null;

@Max(value=5, message = "Rating cannot be more than 5")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.app.gamereview.dto.request.review;

import com.app.gamereview.enums.SortDirection;
import com.app.gamereview.util.validation.annotation.ValidSortDirection;
import lombok.Getter;
import lombok.Setter;

Expand All @@ -11,4 +13,7 @@ public class GetAllReviewsFilterRequestDto {
private String reviewedBy;

private Boolean withDeleted = false;

@ValidSortDirection(allowedValues = {SortDirection.ASCENDING, SortDirection.DESCENDING})
private String sortDirection = SortDirection.DESCENDING.name();
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.*;

@Service
public class ReviewService {
Expand Down Expand Up @@ -76,6 +74,13 @@ public List<GetAllReviewsResponseDto> getAllReviews(GetAllReviewsFilterRequestDt

List<Review> filteredReviews = mongoTemplate.find(query, Review.class);

if(filter.getSortDirection().equals("DESCENDING")){
Collections.sort(filteredReviews, Comparator.comparing(Review::getCreatedAt).reversed());
}
else{
Collections.sort(filteredReviews, Comparator.comparing(Review::getCreatedAt));
}

List<GetAllReviewsResponseDto> reviewDtos = new ArrayList<>();

for(Review review : filteredReviews){
Expand Down

0 comments on commit 4eee7ad

Please sign in to comment.