Skip to content

Commit

Permalink
Merge pull request #206 from TripInfoWeb/fix/gathering_tag_search
Browse files Browse the repository at this point in the history
fix: applicatns 부분 join -> 서브쿼리로 수정
  • Loading branch information
hyeonjaez authored Sep 22, 2024
2 parents 866434d + 36d536a commit 6d80eb6
Showing 1 changed file with 13 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,31 +128,24 @@ public Page<GatheringBriefResponse> getGatheringPageFilterAndOrder(Pageable page

@Override
public Page<GatheringBriefResponse> getPageGatheringByTag(Pageable pageable,
GatheringPageRequest gatheringPageRequest, Long userId,
GatheringPageRequest gatheringPageRequest,
Long userId,
String decodedTag) {
BooleanBuilder booleanBuilder = makeWhereSQL(gatheringPageRequest);
booleanBuilder.and(gatheringTag.tag.name.eq(decodedTag));

long total = from(gathering)
.join(zoneCategoryChild).on(zoneCategoryChild.id.eq(gathering.zoneCategory.id))
.leftJoin(zoneCategoryParent).on(zoneCategoryParent.id.eq(zoneCategoryChild.parentZoneCategory.id))
.leftJoin(bookMarkGathering)
.on(bookMarkGathering.gathering.id.eq(gathering.id).and(bookMarkGathering.user.id.eq(userId)))
.leftJoin(gatheringApplicants).on(gatheringApplicants.gathering.id.eq(gathering.id))
.leftJoin(gatheringTag)
.on(gatheringTag.gathering.id.eq(gathering.id).and(gatheringTag.tag.name.eq(decodedTag)))
.where(booleanBuilder.and(gatheringTag.tag.name.eq(decodedTag)))
.select(gathering.id.count()).fetchCount();
.leftJoin(gatheringTag).on(gatheringTag.gathering.id.eq(gathering.id))
.where(booleanBuilder)
.select(gathering.id.count())
.fetchCount();

List<GatheringBriefResponse> content = from(gathering)
.join(zoneCategoryChild).on(zoneCategoryChild.id.eq(gathering.zoneCategory.id))
.leftJoin(zoneCategoryParent).on(zoneCategoryParent.id.eq(zoneCategoryChild.parentZoneCategory.id))
.leftJoin(bookMarkGathering)
.on(gatheringApplicants.gathering.id.eq(gathering.id).and(gatheringApplicants.gatheringStatus.eq(GatheringStatus.CONSENT)))
.leftJoin(gatheringApplicants).on(gatheringApplicants.gathering.id.eq(gathering.id).and(gatheringApplicants.gatheringStatus.eq(GatheringStatus.CONSENT)))
.leftJoin(gatheringTag)
.on(gatheringTag.gathering.id.eq(gathering.id).and(gatheringTag.tag.name.eq(decodedTag)))
.where(booleanBuilder.and(gatheringTag.tag.name.eq(decodedTag)))
.groupBy(gathering.id, zoneCategoryChild.id, zoneCategoryParent.id, category.id)
.leftJoin(gatheringTag).on(gatheringTag.gathering.id.eq(gathering.id))
.where(booleanBuilder)
.groupBy(gathering.id, zoneCategoryChild.id, zoneCategoryParent.id)
.orderBy(getOrderSpecifier(gatheringPageRequest.getSort(), gathering.id))
.select(Projections.constructor(
GatheringBriefResponse.class,
Expand All @@ -161,18 +154,18 @@ public Page<GatheringBriefResponse> getPageGatheringByTag(Pageable pageable,
zoneCategoryParent.name,
zoneCategoryChild.name,
gathering.viewCount,
bookMarkGathering.user.id.isNotNull(),
isGatheringBookmark(userId, gathering.id),
countGreatGatheringByGatheringById(gathering.id),
gathering.gatheringCategory.name,
gathering.user.name,
gathering.user.nickname,
gathering.scheduleStartDate,
gathering.scheduleEndDate,
gathering.deadline,
gathering.allowedSex,
gathering.startAge,
gathering.endAge,
gathering.personCount,
gatheringApplicants.count().coalesce(0L).intValue(),
applicantsCountNowConsent(gathering.id),
isUserGreatGathering(userId)
))
.offset(pageable.getOffset())
Expand Down

0 comments on commit 6d80eb6

Please sign in to comment.