Skip to content

Commit

Permalink
전체 피드 미션 visibility 조건 추가 (#417)
Browse files Browse the repository at this point in the history
  • Loading branch information
char-yb authored Dec 7, 2024
2 parents 5747f90 + 4418184 commit 06d153b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ public FeedSliceResponse findFeed(int size, Long lastId, MissionVisibility visib

@Transactional(readOnly = true)
public Slice<FeedOneResponse> findFeedV2(FeedVisibility visibility, int size, Long lastId) {
// 전체
if (visibility == FeedVisibility.ALL) {
return findAllFeedV2(size, lastId);
}
// 팔로잉
return findFollowingFeedV2(size, lastId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ public void deleteByMissionRecordId(Long missionRecordId) {
}

@Override
public Slice<MissionRecord> findAllFetch(int size, Long lastId) {

public Slice<MissionRecord> findAllFetch(final int size, final Long lastId) {
List<MissionRecord> missionRecords =
jpaQueryFactory
.selectFrom(missionRecord)
Expand All @@ -180,7 +179,11 @@ public Slice<MissionRecord> 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();
Expand Down Expand Up @@ -264,4 +267,8 @@ private boolean getHasNext(List<?> list, int size) {
}
return hasNext;
}

private BooleanExpression checkMissionVisibilityNone() {
return mission.visibility.ne(MissionVisibility.NONE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ private void setFixture() {
Slice<FeedOneResponse> response = feedService.findFeedV2(FeedVisibility.ALL, 10, 5L);

// then
assertThat(response.getContent()).hasSize(4);
assertThat(response.getContent()).hasSize(3);
}

@Nested
Expand Down

0 comments on commit 06d153b

Please sign in to comment.