Skip to content

Commit

Permalink
Merge pull request #201 from TripInfoWeb/fix/groupBy-error
Browse files Browse the repository at this point in the history
fix: join -> 서브쿼리로 처리후 group by 수정
  • Loading branch information
hyeonjaez authored Sep 22, 2024
2 parents f756a4d + a07f083 commit efe1c5a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ public List<GatheringBriefResponse> getGatheringRecommend(Long gatheringId, Long
.and(gathering.isDeleted.eq(Boolean.FALSE))
.and(gathering.deadline.after(LocalDateTime.now()))
)
.groupBy(gathering.id, zoneCategoryChild.id, zoneCategoryParent.id, category.id,
gathering.title, gathering.viewCount, gathering.user.name,
gathering.scheduleStartDate, gathering.scheduleEndDate,
gathering.deadline, gathering.allowedSex,
gathering.startAge, gathering.endAge, gathering.personCount)
.groupBy(gathering.id, zoneCategoryChild.id, zoneCategoryParent.id)
.orderBy(gathering.createdAt.desc())
.select(Projections.constructor(
GatheringBriefResponse.class,
Expand Down Expand Up @@ -100,11 +96,7 @@ public Page<GatheringBriefResponse> getGatheringPageFilterAndOrder(Pageable page
.join(zoneCategoryChild).on(zoneCategoryChild.id.eq(gathering.zoneCategory.id))
.leftJoin(zoneCategoryParent).on(zoneCategoryParent.id.eq(zoneCategoryChild.parentZoneCategory.id))
.where(booleanBuilder)
.groupBy(gathering.id, zoneCategoryChild.id, zoneCategoryParent.id, category.id,
gathering.title, gathering.viewCount, gathering.user.name,
gathering.scheduleStartDate, gathering.scheduleEndDate,
gathering.deadline, gathering.allowedSex,
gathering.startAge, gathering.endAge, gathering.personCount)
.groupBy(gathering.id, zoneCategoryChild.id, zoneCategoryParent.id)
.orderBy(getOrderSpecifier(gatheringPageRequest.getSort(), gathering.id))
.select(Projections.constructor(
GatheringBriefResponse.class,
Expand Down Expand Up @@ -216,11 +208,7 @@ public List<GatheringBriefResponse> getGatheringLikeCountFromCreatedIn3(Long use
.and(gathering.isDeleted.eq(Boolean.FALSE))
.and(gathering.createdAt.after(LocalDateTime.now().minusMonths(3)))
.and(gathering.deadline.after(LocalDateTime.now())))
.groupBy(gathering.id, zoneCategoryChild.id, zoneCategoryParent.id, category.id,
gathering.title, gathering.viewCount, gathering.user.name,
gathering.scheduleStartDate, gathering.scheduleEndDate,
gathering.deadline, gathering.allowedSex,
gathering.startAge, gathering.endAge, gathering.personCount)
.groupBy(gathering.id, zoneCategoryChild.id, zoneCategoryParent.id)
.orderBy(countGreatGatheringByGatheringById(gathering.id).desc())
.select(Projections.constructor(
GatheringBriefResponse.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,8 @@ public List<InformationMainResponse> getInformationLikeCountFromCreatedIn3(Long
.leftJoin(image).on(image.information.id.eq(information.id).and(image.imageStatus.eq(ImageStatus.THUMBNAIL)))
.leftJoin(category).on(category.id.eq(information.category.id))
.where(information.createdDate.after(LocalDateTime.now().minusMonths(3)))
.groupBy(information.id, information.title, zoneCategoryParent.name, zoneCategoryChild.name,
bookMarkInformation.id, image.address)
.orderBy(countGreatInformationByInformationById(information.id).desc()) // 파라미터로 information.id 전달
.groupBy(information.id, zoneCategoryParent.name, zoneCategoryChild.name, image.address)
.orderBy(countGreatInformationByInformationById(information.id).desc())
.select(Projections.constructor(
InformationMainResponse.class,
information.id,
Expand Down

0 comments on commit efe1c5a

Please sign in to comment.