Skip to content

Commit

Permalink
[refactor] TripRecordScheduleVideoRepositoryImpl 묵시적 조인 가능성 있는 쿼리 joi…
Browse files Browse the repository at this point in the history
…n 추가 리팩토링

related to: #127
  • Loading branch information
jo0oy committed Jan 26, 2024
1 parent 64174f2 commit 0b96279
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.time.LocalDateTime;
import java.util.List;

import static com.haejwo.tripcometrue.domain.city.entity.QCity.city;
import static com.haejwo.tripcometrue.domain.member.entity.QMember.member;
import static com.haejwo.tripcometrue.domain.place.entity.QPlace.place;
import static com.haejwo.tripcometrue.domain.triprecord.entity.QTripRecord.tripRecord;
Expand Down Expand Up @@ -48,10 +49,11 @@ public Slice<TripRecordScheduleVideoQueryDto> findByCityId(Long cityId, Pageable
.from(tripRecordScheduleVideo)
.join(tripRecordScheduleVideo.tripRecordSchedule, tripRecordSchedule)
.join(tripRecordSchedule.place, place)
.join(place.city, city)
.join(tripRecordSchedule.tripRecord, tripRecord)
.join(tripRecord.member, member)
.where(
place.city.id.eq(cityId)
city.id.eq(cityId)
)
.orderBy(getSort(pageable))
.offset(pageable.getOffset())
Expand Down Expand Up @@ -87,10 +89,11 @@ public List<TripRecordScheduleVideoQueryDto> findByCityIdOrderByCreatedAtDescLim
.from(tripRecordScheduleVideo)
.join(tripRecordScheduleVideo.tripRecordSchedule, tripRecordSchedule)
.join(tripRecordSchedule.place, place)
.join(place.city, city)
.join(tripRecordSchedule.tripRecord, tripRecord)
.join(tripRecord.member, member)
.where(
place.city.id.eq(cityId)
city.id.eq(cityId)
)
.limit(size)
.fetch();
Expand Down Expand Up @@ -218,7 +221,7 @@ private OrderSpecifier<?>[] getSort(Pageable pageable) {
case "createdAt":
return new OrderSpecifier[] {new OrderSpecifier<>(direction, tripRecordScheduleVideo.createdAt)};
case "storedCount":
return new OrderSpecifier[] {new OrderSpecifier<>(direction, tripRecordSchedule.tripRecord.storeCount), newest};
return new OrderSpecifier[] {new OrderSpecifier<>(direction, tripRecord.storeCount), newest};
}
}
}
Expand Down

0 comments on commit 0b96279

Please sign in to comment.