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

Merged
pricelees merged 15 commits from feat/#46 into main 2025-09-27 06:38:44 +00:00
2 changed files with 30 additions and 28 deletions
Showing only changes of commit 6dc128202a - Show all commits

View File

@ -11,11 +11,11 @@ class ScheduleOverview(
val storeName: String,
val date: LocalDate,
val time: LocalTime,
val status: ScheduleStatus,
val themeId: Long,
val themeName: String,
val themeDifficulty: Difficulty,
val themeAvailableMinutes: Short,
val status: ScheduleStatus
val themeAvailableMinutes: Short
) {
fun getEndAt(): LocalTime {
return time.plusMinutes(themeAvailableMinutes.toLong())

View File

@ -8,7 +8,8 @@ import java.time.LocalTime
interface ScheduleRepository : JpaRepository<ScheduleEntity, Long> {
@Query("""
@Query(
"""
SELECT
COUNT(s) > 0
FROM
@ -18,7 +19,8 @@ interface ScheduleRepository : JpaRepository<ScheduleEntity, Long> {
AND s.date = :date
AND s.themeId = :themeId
AND s.time = :time
""")
"""
)
fun existsDuplicate(storeId: Long, date: LocalDate, themeId: Long, time: LocalTime): Boolean
@Query(
@ -30,22 +32,20 @@ interface ScheduleRepository : JpaRepository<ScheduleEntity, Long> {
st.name,
s.date,
s.time,
s.status,
t._id,
t.name,
t.difficulty,
t.availableMinutes,
s.status
t.availableMinutes
)
FROM
ScheduleEntity s
JOIN
ThemeEntity t ON t._id = s.themeId
ThemeEntity t ON t._id = s.themeId and (:themeId IS NULL OR t._id = :themeId)
JOIN
StoreEntity st ON st._id = s.storeId
StoreEntity st ON st._id = s.storeId and st._id = :storeId
WHERE
s.storeId = :storeId
AND s.date = :date
AND (:themeId IS NULL OR s.themeId = :themeId)
s.date = :date
"""
)
fun findStoreSchedulesWithThemeByDate(
@ -54,7 +54,8 @@ interface ScheduleRepository : JpaRepository<ScheduleEntity, Long> {
themeId: Long? = null
): List<ScheduleOverview>
@Query("""
@Query(
"""
SELECT
new roomescape.schedule.business.domain.ScheduleOverview(
s._id,
@ -62,11 +63,11 @@ interface ScheduleRepository : JpaRepository<ScheduleEntity, Long> {
st.name,
s.date,
s.time,
s.status,
t._id,
t.name,
t.difficulty,
t.availableMinutes,
s.status
t.availableMinutes
)
FROM
ScheduleEntity s
@ -76,6 +77,7 @@ interface ScheduleRepository : JpaRepository<ScheduleEntity, Long> {
StoreEntity st ON st._id = s.storeId
WHERE
s._id = :id
""")
"""
)
fun findOverviewByIdOrNull(id: Long): ScheduleOverview?
}