Skip to content

Commit 134e21f

Browse files
committed
refactor: DB 인덱스 추가
1 parent faba4be commit 134e21f

13 files changed

Lines changed: 138 additions & 93 deletions

File tree

app/src/main/java/com/mangoboss/app/infra/persistence/WorkReportRepositoryImpl.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.springframework.stereotype.Repository;
1111

1212
import java.time.LocalDate;
13+
import java.time.LocalDateTime;
1314
import java.util.List;
1415

1516

@@ -32,11 +33,15 @@ public WorkReportEntity getByStoreIdAndWorkReportId(Long storeId, Long workRepor
3233

3334
@Override
3435
public List<WorkReportEntity> findByStoreIdAndDateOrderByCreatedAtDesc(final Long storeId, final LocalDate date) {
35-
return workReportJpaRepository.findByStoreIdAndDateOrderByCreatedAtDesc(storeId, date);
36+
LocalDateTime start = date.atStartOfDay();
37+
LocalDateTime end = start.plusDays(1);
38+
return workReportJpaRepository.findByStoreIdAndDateOrderByCreatedAtDesc(storeId, start, end);
3639
}
3740

3841
@Override
3942
public List<WorkReportEntity> findByStoreIdAndDateAndTargetTypeOrderByCreatedAtDesc(final Long storeId, final LocalDate date, final WorkReportTargetType targetType) {
40-
return workReportJpaRepository.findByStoreIdAndDateAndTargetTypeOrderByCreatedAtDesc(storeId, date, targetType);
43+
LocalDateTime start = date.atStartOfDay();
44+
LocalDateTime end = start.plusDays(1);
45+
return workReportJpaRepository.findByStoreIdAndDateAndTargetTypeOrderByCreatedAtDesc(storeId, start, end, targetType);
4146
}
4247
}

app/src/main/resources/data.sql

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -75,33 +75,33 @@ VALUES
7575
(6, 2, null, '2025-04-07', '2025-04-07 08:30:00', '2025-04-07 14:30:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
7676
(7, 2, null, '2025-05-01', '2025-05-01 13:00:00', '2025-05-01 18:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
7777
(8, 1, null, '2025-05-03', '2025-05-03 10:00:00', '2025-05-03 18:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
78-
(10, 1, null, '2025-05-05', '2025-05-05 09:00:00', '2025-05-05 14:30:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
79-
(11, 3, null, '2025-05-06', '2025-05-06 09:00:00', '2025-05-06 14:30:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
80-
(12, 2, null, '2025-05-07', '2025-05-07 10:30:00', '2025-05-07 15:30:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
81-
(13, 3, null, '2025-05-07', '2025-05-07 10:00:00', '2025-05-07 14:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
82-
(14, 1, null, '2025-05-08', '2025-05-08 09:00:00', '2025-05-08 14:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
83-
(15, 3, null, '2025-05-08', '2025-05-08 13:00:00', '2025-05-08 19:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
84-
(16, 1, null, '2025-05-09', '2025-05-09 12:00:00', '2025-05-09 18:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
85-
(17, 2, null, '2025-05-10', '2025-05-10 08:00:00', '2025-05-10 13:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
86-
(18, 1, null, '2025-05-10', '2025-05-10 10:00:00', '2025-05-10 14:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
87-
(19, 3, null, '2025-05-11', '2025-05-11 09:30:00', '2025-05-11 15:30:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
88-
(20, 1, null, '2025-05-12', '2025-05-12 08:30:00', '2025-05-12 14:30:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
89-
(21, 2, null, '2025-05-13', '2025-05-13 11:30:00', '2025-05-13 19:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
90-
(22, 2, null, '2025-05-14', '2025-05-14 09:30:00', '2025-05-14 17:30:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
91-
(23, 2, null, '2025-05-15', '2025-05-15 08:00:00', '2025-05-15 16:30:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
92-
(24, 2, null, '2025-05-16', '2025-05-16 10:00:00', '2025-05-16 15:30:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
93-
(25, 3, null, '2025-05-17', '2025-05-17 08:30:00', '2025-05-17 15:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
94-
(28, 3, null, '2025-05-20', '2025-05-20 08:30:00', '2025-05-20 15:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
95-
(29, 3, null, '2025-05-21', '2025-05-21 08:30:00', '2025-05-21 16:30:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
96-
(30, 1, null, '2025-05-22', '2025-05-22 09:30:00', '2025-05-22 17:30:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
97-
(31, 1, null, '2025-05-23', '2025-05-23 08:00:00', '2025-05-23 14:30:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
98-
(32, 3, null, '2025-05-24', '2025-05-24 08:00:00', '2025-05-24 15:30:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
99-
(33, 2, null, '2025-05-25', '2025-05-25 09:30:00', '2025-05-25 16:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
100-
(34, 1, null, '2025-05-26', '2025-05-26 08:00:00', '2025-05-26 15:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
101-
(35, 2, null, '2025-05-27', '2025-05-27 10:00:00', '2025-05-27 18:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
102-
(37, 2, null, '2025-05-29', '2025-05-29 10:00:00', '2025-05-29 15:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
103-
(38, 2, null, '2025-05-30', '2025-05-30 08:00:00', '2025-05-30 14:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
104-
(39, 3, null, '2025-05-31', '2025-05-31 09:00:00', '2025-05-31 17:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
78+
(9, 1, null, '2025-05-05', '2025-05-05 09:00:00', '2025-05-05 14:30:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
79+
(10, 3, null, '2025-05-06', '2025-05-06 09:00:00', '2025-05-06 14:30:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
80+
(11, 2, null, '2025-05-07', '2025-05-07 10:30:00', '2025-05-07 15:30:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
81+
(12, 3, null, '2025-05-07', '2025-05-07 10:00:00', '2025-05-07 14:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
82+
(13, 1, null, '2025-05-08', '2025-05-08 09:00:00', '2025-05-08 14:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
83+
(14, 3, null, '2025-05-08', '2025-05-08 13:00:00', '2025-05-08 19:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
84+
(15, 1, null, '2025-05-09', '2025-05-09 12:00:00', '2025-05-09 18:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
85+
(16, 2, null, '2025-05-10', '2025-05-10 08:00:00', '2025-05-10 13:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
86+
(17, 1, null, '2025-05-10', '2025-05-10 10:00:00', '2025-05-10 14:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
87+
(18, 3, null, '2025-05-11', '2025-05-11 09:30:00', '2025-05-11 15:30:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
88+
(19, 1, null, '2025-05-12', '2025-05-12 08:30:00', '2025-05-12 14:30:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
89+
(20, 2, null, '2025-05-13', '2025-05-13 11:30:00', '2025-05-13 19:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
90+
(21, 2, null, '2025-05-14', '2025-05-14 09:30:00', '2025-05-14 17:30:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
91+
(22, 2, null, '2025-05-15', '2025-05-15 08:00:00', '2025-05-15 16:30:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
92+
(23, 2, null, '2025-05-16', '2025-05-16 10:00:00', '2025-05-16 15:30:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
93+
(24, 3, null, '2025-05-17', '2025-05-17 08:30:00', '2025-05-17 15:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
94+
(25, 3, null, '2025-05-20', '2025-05-20 08:30:00', '2025-05-20 15:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
95+
(26, 3, null, '2025-05-21', '2025-05-21 08:30:00', '2025-05-21 16:30:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
96+
(27, 1, null, '2025-05-22', '2025-05-22 09:30:00', '2025-05-22 17:30:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
97+
(28, 1, null, '2025-05-23', '2025-05-23 08:00:00', '2025-05-23 14:30:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
98+
(29, 3, null, '2025-05-24', '2025-05-24 08:00:00', '2025-05-24 15:30:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
99+
(30, 2, null, '2025-05-25', '2025-05-25 09:30:00', '2025-05-25 16:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
100+
(31, 1, null, '2025-05-26', '2025-05-26 08:00:00', '2025-05-26 15:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
101+
(32, 2, null, '2025-05-27', '2025-05-27 10:00:00', '2025-05-27 18:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
102+
(33, 2, null, '2025-05-29', '2025-05-29 10:00:00', '2025-05-29 15:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
103+
(34, 2, null, '2025-05-30', '2025-05-30 08:00:00', '2025-05-30 14:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
104+
(35, 3, null, '2025-05-31', '2025-05-31 09:00:00', '2025-05-31 17:00:00', 1, 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
105105

106106
INSERT INTO attendance (attendance_id, schedule_id, clock_in_time, clock_out_time, clock_in_status, clock_out_status, attendance_state, created_at, modified_at)
107107
VALUES
@@ -113,30 +113,30 @@ VALUES
113113
(6, 6, '2025-04-07 08:30:00', '2025-04-07 14:30:00', 'NORMAL', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
114114
(7, 7, '2025-05-01 13:00:00', '2025-05-01 18:00:00', 'NORMAL', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
115115
(8, 8, '2025-05-03 10:05:00', '2025-05-03 18:00:00', 'LATE', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
116-
(9, 10, '2025-05-05 09:00:00', '2025-05-05 14:30:00', 'NORMAL', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
117-
(10, 11, '2025-05-06 09:05:00', '2025-05-06 14:25:00', 'LATE', 'EARLY_LEAVE', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
118-
(11, 12, '2025-05-07 10:30:00', '2025-05-07 15:30:00', 'NORMAL', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
119-
(12, 13, null, null, 'ABSENT', 'ABSENT', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
120-
(13, 14, '2025-05-08 09:00:00', '2025-05-08 14:10:00', 'NORMAL', 'OVERTIME', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
121-
(14, 15, '2025-05-08 13:00:00', '2025-05-08 19:00:00', 'NORMAL', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
122-
(15, 16, '2025-05-09 12:05:00', '2025-05-09 18:00:00', 'LATE', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
123-
(16, 17, '2025-05-10 08:00:00', '2025-05-10 13:00:00', 'NORMAL', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
124-
(17, 18, null, null, 'ABSENT', 'ABSENT', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
125-
(18, 19, '2025-05-11 09:30:00', '2025-05-11 15:30:00', 'NORMAL', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
126-
(19, 20, '2025-05-12 08:40:00', '2025-05-12 14:20:00', 'LATE', 'EARLY_LEAVE', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
127-
(20, 21, '2025-05-13 11:30:00', '2025-05-13 19:00:00', 'NORMAL', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
128-
(21, 22, null, null, 'ABSENT', 'ABSENT', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
129-
(22, 23, '2025-05-15 08:00:00', '2025-05-15 16:30:00', 'NORMAL', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
130-
(23, 24, '2025-05-16 10:00:00', '2025-05-16 15:20:00', 'NORMAL', 'EARLY_LEAVE', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
131-
(24, 25, '2025-05-17 08:35:00', '2025-05-17 15:00:00', 'LATE', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
132-
(25, 28, '2025-05-20 08:30:00', '2025-05-20 15:00:00', 'NORMAL', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
133-
(26, 29, null, null, 'ABSENT', 'ABSENT', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
134-
(27, 30, '2025-05-22 09:30:00', '2025-05-22 17:30:00', 'NORMAL', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
135-
(28, 31, '2025-05-23 08:10:00', '2025-05-23 14:30:00', 'LATE', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
136-
(29, 32, '2025-05-24 08:00:00', '2025-05-24 15:30:00', 'NORMAL', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
137-
(30, 33, '2025-05-25 09:35:00', '2025-05-25 16:00:00', 'LATE', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
138-
(31, 34, '2025-05-26 08:00:00', '2025-05-26 15:00:00', 'NORMAL', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
139-
(32, 35, null, null, 'ABSENT', 'ABSENT', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
140-
(33, 37, '2025-05-29 10:05:00', '2025-05-29 15:10:00', 'LATE', 'OVERTIME', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
141-
(34, 38, '2025-05-30 08:00:00', '2025-05-30 14:00:00', 'NORMAL', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
142-
(35, 39, '2025-05-31 09:00:00', '2025-05-31 17:00:00', 'NORMAL', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
116+
(9, 9, '2025-05-05 09:00:00', '2025-05-05 14:30:00', 'NORMAL', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
117+
(10, 10, '2025-05-06 09:05:00', '2025-05-06 14:25:00', 'LATE', 'EARLY_LEAVE', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
118+
(11, 11, '2025-05-07 10:30:00', '2025-05-07 15:30:00', 'NORMAL', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
119+
(12, 12, null, null, 'ABSENT', 'ABSENT', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
120+
(13, 13, '2025-05-08 09:00:00', '2025-05-08 14:10:00', 'NORMAL', 'OVERTIME', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
121+
(14, 14, '2025-05-08 13:00:00', '2025-05-08 19:00:00', 'NORMAL', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
122+
(15, 15, '2025-05-09 12:05:00', '2025-05-09 18:00:00', 'LATE', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
123+
(16, 16, '2025-05-10 08:00:00', '2025-05-10 13:00:00', 'NORMAL', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
124+
(17, 17, null, null, 'ABSENT', 'ABSENT', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
125+
(18, 18, '2025-05-11 09:30:00', '2025-05-11 15:30:00', 'NORMAL', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
126+
(19, 19, '2025-05-12 08:40:00', '2025-05-12 14:20:00', 'LATE', 'EARLY_LEAVE', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
127+
(20, 20, '2025-05-13 11:30:00', '2025-05-13 19:00:00', 'NORMAL', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
128+
(21, 21, null, null, 'ABSENT', 'ABSENT', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
129+
(22, 22, '2025-05-15 08:00:00', '2025-05-15 16:30:00', 'NORMAL', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
130+
(23, 23, '2025-05-16 10:00:00', '2025-05-16 15:20:00', 'NORMAL', 'EARLY_LEAVE', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
131+
(24, 24, '2025-05-17 08:35:00', '2025-05-17 15:00:00', 'LATE', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
132+
(25, 25, '2025-05-20 08:30:00', '2025-05-20 15:00:00', 'NORMAL', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
133+
(26, 26, null, null, 'ABSENT', 'ABSENT', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
134+
(27, 27, '2025-05-22 09:30:00', '2025-05-22 17:30:00', 'NORMAL', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
135+
(28, 28, '2025-05-23 08:10:00', '2025-05-23 14:30:00', 'LATE', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
136+
(29, 29, '2025-05-24 08:00:00', '2025-05-24 15:30:00', 'NORMAL', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
137+
(30, 30, '2025-05-25 09:35:00', '2025-05-25 16:00:00', 'LATE', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
138+
(31, 31, '2025-05-26 08:00:00', '2025-05-26 15:00:00', 'NORMAL', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
139+
(32, 32, null, null, 'ABSENT', 'ABSENT', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
140+
(33, 33, '2025-05-29 10:05:00', '2025-05-29 15:10:00', 'LATE', 'OVERTIME', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
141+
(34, 34, '2025-05-30 08:00:00', '2025-05-30 14:00:00', 'NORMAL', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
142+
(35, 35, '2025-05-31 09:00:00', '2025-05-31 17:00:00', 'NORMAL', 'NORMAL', 'NONE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);

storage/src/main/java/com/mangoboss/storage/attendance/AttendanceEntity.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
@Getter
1313
@NoArgsConstructor(access = AccessLevel.PROTECTED)
1414
@Entity
15-
@Table(name = "attendance")
15+
@Table(
16+
name = "attendance",
17+
indexes = {
18+
@Index(name = "idx_attendance_schedule_id", columnList = "schedule_id"),
19+
}
20+
)
1621
public class AttendanceEntity extends BaseTimeEntity {
1722

1823
@Id

storage/src/main/java/com/mangoboss/storage/attendance/AttendanceJpaRepository.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ ORDER BY DATE(s.workDate)
3434
List<WorkDotProjection> findWorkDotProjections(Long storeId, LocalDate start, LocalDate end);
3535

3636
@Query("""
37-
SELECT s AS staff,
38-
SUM(CASE WHEN a.clockInStatus = 'NORMAL' THEN 1 ELSE 0 END) AS normalCount,
39-
SUM(CASE WHEN a.clockInStatus = 'LATE' THEN 1 ELSE 0 END) AS lateCount,
40-
SUM(CASE WHEN a.clockInStatus = 'ABSENT' THEN 1 ELSE 0 END) AS absentCount
41-
FROM StaffEntity s
42-
LEFT JOIN AttendanceEntity a
43-
ON a.schedule.staff.id = s.id
44-
AND a.schedule.workDate BETWEEN :start AND :end
45-
WHERE s.store.id =:storeId
46-
GROUP BY s.id
37+
SELECT f AS staff,
38+
SUM(CASE WHEN a.clockInStatus = 'NORMAL' THEN 1 ELSE 0 END) AS normalCount,
39+
SUM(CASE WHEN a.clockInStatus = 'LATE' THEN 1 ELSE 0 END) AS lateCount,
40+
SUM(CASE WHEN a.clockInStatus = 'ABSENT' THEN 1 ELSE 0 END) AS absentCount
41+
FROM ScheduleEntity s
42+
JOIN s.staff f
43+
LEFT JOIN AttendanceEntity a ON a.schedule.id = s.id
44+
WHERE f.store.id = :storeId
45+
AND s.workDate BETWEEN :start AND :end
46+
GROUP BY f.id
4747
""")
4848
List<StaffAttendanceCountProjection> findAttendanceCountsByStoreId(Long storeId, LocalDate start, LocalDate end);
4949

storage/src/main/java/com/mangoboss/storage/notification/NotificationEntity.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@
99

1010
@Getter
1111
@Entity
12-
@Table(name = "notification")
12+
@Table(
13+
name = "notification",
14+
indexes = {
15+
@Index(name = "idx_notification_type_meta", columnList = "type, meta_id"),
16+
@Index(name = "idx_notification_sendstatus_retry", columnList = "send_status, retry_count"),
17+
@Index(name = "idx_notification_user_store", columnList = "user_id, store_id")
18+
}
19+
)
1320
@NoArgsConstructor(access = AccessLevel.PROTECTED)
1421
public class NotificationEntity extends BaseTimeEntity {
1522

storage/src/main/java/com/mangoboss/storage/schedule/ScheduleEntity.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@
1717
@Getter
1818
@NoArgsConstructor(access = AccessLevel.PROTECTED)
1919
@Entity
20-
@Table(name = "schedule")
20+
@Table(
21+
name = "schedule",
22+
indexes = {
23+
@Index(name = "idx_schedule_work_date", columnList = "store_id, work_date"),
24+
@Index(name = "idx_end_time", columnList = "end_time"),
25+
@Index(name = "idx_schedule_staff_workdate", columnList = "staff_id, work_date")
26+
}
27+
)
2128
public class ScheduleEntity extends BaseTimeEntity {
2229
@Id
2330
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -103,7 +110,7 @@ public void substituted(final StaffEntity staff) {
103110
this.substitutionState = SubstitutionState.SUBSTITUTED;
104111
}
105112

106-
public void rejected(){
113+
public void rejected() {
107114
this.substitutionState = SubstitutionState.NONE;
108115
}
109116
}

storage/src/main/java/com/mangoboss/storage/schedule/ScheduleJpaRepository.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,13 @@ public interface ScheduleJpaRepository extends JpaRepository<ScheduleEntity, Lon
2626

2727
List<ScheduleEntity> findAllByStaffIdAndWorkDate(Long staffId, LocalDate date);
2828

29-
@Query(
30-
"""
31-
SELECT s AS schedule, f.name AS staffName, st.boss.id AS bossId, st.id AS storeId
32-
FROM ScheduleEntity s
33-
JOIN StaffEntity f ON s.staff.id = f.id
34-
JOIN StoreEntity st ON f.store.id = st.id
35-
LEFT JOIN s.attendance a
36-
WHERE s.endTime <= :standardTime
37-
AND (a.clockOutStatus is NULL OR a is NULL)
38-
"""
39-
)
40-
List<ScheduleForNotificationProjection> findAllSchedulesWithoutClockOut(LocalDateTime standardTime);
29+
@Query("""
30+
SELECT s FROM ScheduleEntity s
31+
LEFT JOIN s.attendance a
32+
WHERE s.endTime <= :standardTime
33+
AND (a.clockOutStatus is NULL OR a is NULL)
34+
""")
35+
List<ScheduleEntity> findAllSchedulesWithoutClockOut(LocalDateTime standardTime);
4136

4237
Boolean existsByRegularGroupId(Long regularGroupId);
4338

0 commit comments

Comments
 (0)