Skip to content

Commit dd5e020

Browse files
authored
[DEPLOY] 쿼리 수정
[DEPLOY] 쿼리 수정
2 parents 2cda9c0 + 1d3b0a1 commit dd5e020

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

clokey-api/src/main/java/org/clokey/domain/cloth/repository/ClothRepositoryImpl.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,24 @@ public Slice<ClothRecommendListResponse> findAllMemberRecommendClothesByCategory
4040
// 우선 순위에 맞게 페이징 합니다.
4141
// - Category는 고정입니다.
4242
// - 계절은 요청한 계절에 가까운 순서대로 페이징을 진행합니다.
43+
// @ElementCollection에서는 exists 서브쿼리가 더 안정적입니다.
44+
BooleanExpression seasonCondition =
45+
cloth.seasons
46+
.contains(season)
47+
.or(cloth.seasons.contains(nextSeason))
48+
.or(cloth.seasons.contains(previousSeason))
49+
.or(cloth.seasons.contains(oppositeSeason));
50+
4351
NumberExpression<Integer> seasonPriority =
4452
new CaseBuilder()
45-
.when(cloth.seasons.any().in(List.of(season)))
53+
.when(cloth.seasons.contains(season))
4654
.then(1)
4755
.when(
4856
cloth.seasons
49-
.any()
50-
.in(List.of(nextSeason))
51-
.or(cloth.seasons.any().in(List.of(previousSeason))))
57+
.contains(nextSeason)
58+
.or(cloth.seasons.contains(previousSeason)))
5259
.then(2)
53-
.when(cloth.seasons.any().in(List.of(oppositeSeason)))
60+
.when(cloth.seasons.contains(oppositeSeason))
5461
.then(3)
5562
.otherwise(4);
5663

@@ -60,7 +67,7 @@ public Slice<ClothRecommendListResponse> findAllMemberRecommendClothesByCategory
6067
.where(
6168
cloth.category.id.eq(categoryId),
6269
cloth.member.id.eq(memberId),
63-
cloth.seasons.any().in(targetSeasons))
70+
seasonCondition)
6471
.orderBy(seasonPriority.asc(), cloth.id.asc())
6572
.fetch();
6673

0 commit comments

Comments
 (0)