diff --git a/src/main/java/com/depromeet/domain/feed/application/FeedService.java b/src/main/java/com/depromeet/domain/feed/application/FeedService.java index d713aad8..2dce13d1 100644 --- a/src/main/java/com/depromeet/domain/feed/application/FeedService.java +++ b/src/main/java/com/depromeet/domain/feed/application/FeedService.java @@ -62,9 +62,11 @@ public FeedSliceResponse findFeed(int size, Long lastId, MissionVisibility visib @Transactional(readOnly = true) public Slice findFeedV2(FeedVisibility visibility, int size, Long lastId) { + // 전체 if (visibility == FeedVisibility.ALL) { return findAllFeedV2(size, lastId); } + // 팔로잉 return findFollowingFeedV2(size, lastId); } diff --git a/src/main/java/com/depromeet/domain/missionRecord/dao/MissionRecordRepositoryImpl.java b/src/main/java/com/depromeet/domain/missionRecord/dao/MissionRecordRepositoryImpl.java index a869b973..cb092ab2 100644 --- a/src/main/java/com/depromeet/domain/missionRecord/dao/MissionRecordRepositoryImpl.java +++ b/src/main/java/com/depromeet/domain/missionRecord/dao/MissionRecordRepositoryImpl.java @@ -168,8 +168,7 @@ public void deleteByMissionRecordId(Long missionRecordId) { } @Override - public Slice findAllFetch(int size, Long lastId) { - + public Slice findAllFetch(final int size, final Long lastId) { List missionRecords = jpaQueryFactory .selectFrom(missionRecord) @@ -180,7 +179,11 @@ public Slice findAllFetch(int size, Long lastId) { .leftJoin(missionRecord.reactions, reaction) .fetchJoin() .distinct() - .where(ltMissionRecordId(lastId)) + .where( + ltMissionRecordId(lastId) != null + ? ltMissionRecordId(lastId) + .and(checkMissionVisibilityNone()) + : checkMissionVisibilityNone()) .orderBy(missionRecord.finishedAt.desc()) .limit((long) size + 1) .fetch(); @@ -264,4 +267,8 @@ private boolean getHasNext(List list, int size) { } return hasNext; } + + private BooleanExpression checkMissionVisibilityNone() { + return mission.visibility.ne(MissionVisibility.NONE); + } } diff --git a/src/test/java/com/depromeet/domain/feed/application/FeedServiceTest.java b/src/test/java/com/depromeet/domain/feed/application/FeedServiceTest.java index bef602ef..36c38dc3 100644 --- a/src/test/java/com/depromeet/domain/feed/application/FeedServiceTest.java +++ b/src/test/java/com/depromeet/domain/feed/application/FeedServiceTest.java @@ -225,7 +225,7 @@ private void setFixture() { Slice response = feedService.findFeedV2(FeedVisibility.ALL, 10, 5L); // then - assertThat(response.getContent()).hasSize(4); + assertThat(response.getContent()).hasSize(3); } @Nested