Skip to content

Commit 17c7d4d

Browse files
HHS-korclaude
andcommitted
fix: Copilot AI 2차 코드 리뷰 반영 — 테스트명 수정, 도메인 검증 강화, 코드 품질 개선
Copilot pull-request-reviewer 2차 리뷰 지적 사항을 반영한다. 변경 사항: - HaversineTest: approxHundredKmBetweenSeoulAndSuwon → approxFortyFiveKmBetweenSeoulAndSuwon (메서드명이 실제 검증 거리 ~45km와 불일치하여 수정) - DateCoursePlace: create() 팩토리 메서드에 sequenceOrder >= 0 검사 추가 (정렬 키로 사용되는 필드의 도메인 불변식 명시) - CourseSelector: 선택 루프 후 O(n·m) pool 재조립 → O(n) 직접 구성으로 단순화 (List.contains/indexOf 대신 선택 시점에 pickedPlaces 직접 누적, 중복 방지용 picked Set<Long> 별도 유지) - BusinessHoursAtTimeChecker: java.util.Set FQN → import java.util.Set 추가 후 단순명 사용 (파일 내 다른 타입과 스타일 통일) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 29dc88a commit 17c7d4d

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/main/java/com/hufs/capstone/backend/course/application/BusinessHoursAtTimeChecker.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.time.Instant;
66
import java.time.ZoneId;
77
import java.time.ZonedDateTime;
8+
import java.util.Set;
89
import lombok.RequiredArgsConstructor;
910
import org.springframework.stereotype.Component;
1011

@@ -14,7 +15,7 @@ public class BusinessHoursAtTimeChecker {
1415

1516
private static final ZoneId SEOUL_ZONE = ZoneId.of("Asia/Seoul");
1617

17-
private static final java.util.Set<BusinessStatus> OPEN_STATUSES = java.util.Set.of(
18+
private static final Set<BusinessStatus> OPEN_STATUSES = Set.of(
1819
BusinessStatus.OPEN,
1920
BusinessStatus.OPEN_24_HOURS,
2021
BusinessStatus.CLOSING_SOON

src/main/java/com/hufs/capstone/backend/course/application/CourseSelector.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ CourseSelectionResult select(
3535
Instant plannedDateTime
3636
) {
3737
NormalizationContext ctx = buildNormalizationContext(pool, mode);
38-
List<Long> picked = new ArrayList<>();
38+
List<RoomPlace> pickedPlaces = new ArrayList<>();
39+
Set<Long> pickedIds = new HashSet<>();
3940
List<Integer> skipped = new ArrayList<>();
4041
AvailableCandidate prev = null;
4142

@@ -44,7 +45,7 @@ CourseSelectionResult select(
4445
final AvailableCandidate prevForLambda = prev;
4546
Optional<AvailableCandidate> best = pool.forSlot(slot).stream()
4647
.filter(c -> !globallyUsedIds.contains(c.roomPlace().getId()))
47-
.filter(c -> !picked.contains(c.roomPlace().getId()))
48+
.filter(c -> !pickedIds.contains(c.roomPlace().getId()))
4849
.filter(c -> mode != CourseMode.POPULAR || c.roomPlace().getOriginRoomLink() != null)
4950
.max(Comparator.comparingDouble(
5051
c -> scorer.score(c, prevForLambda, mode, ctx, plannedDateTime)
@@ -56,17 +57,12 @@ CourseSelectionResult select(
5657
}
5758

5859
AvailableCandidate chosen = best.get();
59-
picked.add(chosen.roomPlace().getId());
60+
pickedPlaces.add(chosen.roomPlace());
61+
pickedIds.add(chosen.roomPlace().getId());
6062
prev = chosen;
6163
}
6264

63-
List<RoomPlace> pickedPlaces = pool.all().stream()
64-
.filter(c -> picked.contains(c.roomPlace().getId()))
65-
.sorted(Comparator.comparingInt(c -> picked.indexOf(c.roomPlace().getId())))
66-
.map(AvailableCandidate::roomPlace)
67-
.toList();
68-
69-
globallyUsedIds.addAll(picked);
65+
globallyUsedIds.addAll(pickedIds);
7066
return new CourseSelectionResult(pickedPlaces, skipped);
7167
}
7268

src/main/java/com/hufs/capstone/backend/course/domain/entity/DateCoursePlace.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public static DateCoursePlace create(DateCourse dateCourse, RoomPlace roomPlace,
5252
if (dateCourse == null || roomPlace == null || sequenceOrder == null) {
5353
throw new IllegalArgumentException("DateCoursePlace required values are missing.");
5454
}
55+
if (sequenceOrder < 0) {
56+
throw new IllegalArgumentException("DateCoursePlace required values are missing.");
57+
}
5558
return new DateCoursePlace(dateCourse, roomPlace, sequenceOrder);
5659
}
5760
}

src/test/java/com/hufs/capstone/backend/course/application/HaversineTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void approxOneKmBetweenNearbyPoints() {
3232
}
3333

3434
@Test
35-
void approxHundredKmBetweenSeoulAndSuwon() {
35+
void approxFortyFiveKmBetweenSeoulAndSuwon() {
3636
// Seoul to Suwon (~45 km by Haversine)
3737
double km = Haversine.km(
3838
BigDecimal.valueOf(37.5665),

0 commit comments

Comments
 (0)