[#46] 더미 데이터 생성 및 1개의 슬로우쿼리 개선 #47

Merged
pricelees merged 15 commits from feat/#46 into main 2025-09-27 06:38:44 +00:00
4 changed files with 0 additions and 54 deletions
Showing only changes of commit a4d28322fb - Show all commits

View File

@ -121,23 +121,6 @@ class ReservationService(
}
}
@Transactional(readOnly = true)
fun findMostReservedThemeIds(count: Int): MostReservedThemeIdListResponse {
log.info { "[ReservationService.findMostReservedThemeIds] 인기 테마 조회 시작: count=$count" }
val previousWeekSunday = DateUtils.getSundayOfPreviousWeek(LocalDate.now())
val previousWeekSaturday = previousWeekSunday.plusDays(6)
val themeIds: List<Long> = reservationRepository.findMostReservedThemeIds(
dateFrom = previousWeekSunday,
dateTo = previousWeekSaturday,
count = count
)
return MostReservedThemeIdListResponse(themeIds = themeIds).also {
log.info { "[ReservationService.findMostReservedThemeIds] 인기 테마 조회 완료: count=${it.themeIds.size}" }
}
}
private fun findOrThrow(id: Long): ReservationEntity {
log.info { "[ReservationService.findOrThrow] 예약 조회 시작: reservationId=${id}" }

View File

@ -16,14 +16,6 @@ import roomescape.common.dto.response.CommonApiResponse
import roomescape.reservation.web.*
interface ReservationAPI {
@Public
@Operation(summary = "가장 많이 예약된 테마 ID 조회")
@ApiResponses(ApiResponse(responseCode = "200", useReturnTypeSchema = true))
fun findMostReservedThemeIds(
@RequestParam count: Int
): ResponseEntity<CommonApiResponse<MostReservedThemeIdListResponse>>
@Operation(summary = "결제 전 임시 예약 저장")
@ApiResponses(ApiResponse(responseCode = "200", useReturnTypeSchema = true))
fun createPendingReservation(

View File

@ -1,27 +1,8 @@
package roomescape.reservation.infrastructure.persistence
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.query.Param
import java.time.LocalDate
interface ReservationRepository : JpaRepository<ReservationEntity, Long> {
fun findAllByUserIdAndStatusIsIn(userId: Long, statuses: List<ReservationStatus>): List<ReservationEntity>
@Query("""
SELECT s.themeId
FROM ReservationEntity r
JOIN ScheduleEntity s ON s._id = r.scheduleId
WHERE r.status = roomescape.reservation.infrastructure.persistence.ReservationStatus.CONFIRMED
AND s.date BETWEEN :dateFrom AND :dateTo
GROUP BY s.themeId
ORDER BY count(r) DESC
LIMIT :count
""")
fun findMostReservedThemeIds(
@Param("dateFrom") dateFrom: LocalDate,
@Param("dateTo") dateTo: LocalDate,
@Param("count") count: Int
): List<Long>
}

View File

@ -14,16 +14,6 @@ import roomescape.reservation.docs.ReservationAPI
class ReservationController(
private val reservationService: ReservationService
) : ReservationAPI {
@GetMapping("/popular-themes")
override fun findMostReservedThemeIds(
@RequestParam count: Int
): ResponseEntity<CommonApiResponse<MostReservedThemeIdListResponse>> {
val response = reservationService.findMostReservedThemeIds(count)
return ResponseEntity.ok(CommonApiResponse(response))
}
@PostMapping("/pending")
override fun createPendingReservation(
@User user: CurrentUserContext,