Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public Trip getValidTrip(Long memberId, Long tripId) {
}

public Slice<Trip> getTripsSliceByMemberId(Long memberId, int page, int size) {
return tripQueryRepository.findSliceByMemberId(memberId, PageRequest.of(page, size));
return tripQueryRepository.findSliceByMemberIdAndCompletedFalseAndDeletedAtIsNull(
memberId, PageRequest.of(page, size));
}

public TripCount getActiveTripCountsByMemberId(Long memberId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import org.springframework.data.domain.Slice;

public interface TripQueryRepository {
Slice<Trip> findSliceByMemberId(Long memberId, Pageable pageable);
Slice<Trip> findSliceByMemberIdAndCompletedFalseAndDeletedAtIsNull(
Long memberId, Pageable pageable);

long countActiveTripsByMemberIdAndCategory(Long memberId, TripCategory category);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ public class TripQueryRepositoryAdapter implements TripQueryRepository {
private final QMember member = QMember.member;

@Override
public Slice<Trip> findSliceByMemberId(Long memberId, Pageable pageable) {
public Slice<Trip> findSliceByMemberIdAndCompletedFalseAndDeletedAtIsNull(
Long memberId, Pageable pageable) {
List<Trip> content =
queryFactory
.selectFrom(trip)
.where(trip.member.id.eq(memberId).and(trip.deletedAt.isNull()))
.where(
trip.member.id.eq(memberId),
trip.completed.isFalse(),
trip.deletedAt.isNull())
.offset(pageable.getOffset())
.limit(pageable.getPageSize() + 1)
.fetch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public ResponseEntity<StandardResponse> deleteTrip(

@Operation(
summary = "여행 목록 조회",
description = "여행 목록을 조회하는 API 입니다. 무한 스크롤을 위해 슬라이스를 적용하고, D-DAY 정보가 이른 순으로 정렬합니다.")
description =
"여행 목록을 조회하는 API 입니다. 무한 스크롤을 위해 슬라이스를 적용하고, D-DAY 정보가 이른 순으로 정렬합니다. 완료되지 않은 여행 목록만 조회합니다.")
@GetMapping
public ResponseEntity<StandardResponse> loadTrips(
@AuthenticationPrincipal String memberId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,18 @@ void shouldGetTripByTripIdReturnValidTrip() {
class GetTripsSliceByMemberId {

@Test
@DisplayName("로그인된 사용자의 여행 목록을 DB에서 조회하고 슬라이스 처리해 반환한다")
@DisplayName("로그인된 사용자의 완료되지 않고 삭제되지 않은 여행 목록을 DB에서 조회하고 슬라이스 처리해 반환한다")
void shouldGetTripsReturnSlicePaged() {
// given
Long memberId = member.getId();
List<Trip> trips = List.of(trip);
Pageable pageable = PageRequest.of(DEFAULT_PAGE, DEFAULT_SIZE);
Slice<Trip> results = new SliceImpl<>(trips, pageable, false);
given(tripQueryRepository.findSliceByMemberId(memberId, pageable)).willReturn(results);
given(
tripQueryRepository
.findSliceByMemberIdAndCompletedFalseAndDeletedAtIsNull(
memberId, pageable))
.willReturn(results);

// when
Slice<Trip> sliceTrips =
Expand Down