Conversation
- DataInitializer: 허브를 서울/경기/제주 3개로 축소, 허브 UUID 고정, 매니저 UUID 각각 다르게 설정 - DataInitializer: 허브 경로를 3개 허브 간 양방향 6개로 재구성 - 02-init-data.sql: MASTER, HUB_MANAGER(3), COMPANY_MANAGER(5), SHIPMENT_MANAGER(5) 유저 추가 - 02-init-data.sql: p_company 5개, p_shipment_manager 5개 초기 데이터 추가 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
📝 WalkthroughWalkthrough이 변경사항은 PostgreSQL 초기화 스크립트와 Java 데이터 초기화 로직을 업데이트합니다. 새로운 SQL 스크립트( Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Contributor
There was a problem hiding this comment.
🧹 Nitpick comments (2)
hub-service/src/main/java/com/shipflow/hubservice/infrastructure/initializer/DataInitializer.java (2)
86-124: 양방향 라우트 생성 중복을 헬퍼로 추출하는 것을 권장합니다.동일 패턴 반복이 많아 거리/시간 값 수정 시 누락 가능성이 있습니다.
리팩터링 예시
List<HubRoute> routes = new ArrayList<>(); @@ - // 서울 ↔ 경기 - routes.add(HubRoute.builder() - .departureHub(seoul) - .arrivalHub(gyeonggi) - .distance(new BigDecimal("30.00")) - .duration(45) - .build()); - routes.add(HubRoute.builder() - .departureHub(gyeonggi) - .arrivalHub(seoul) - .distance(new BigDecimal("30.00")) - .duration(45) - .build()); - // 서울 ↔ 제주 - routes.add(HubRoute.builder() - .departureHub(seoul) - .arrivalHub(jeju) - .distance(new BigDecimal("465.00")) - .duration(480) - .build()); - routes.add(HubRoute.builder() - .departureHub(jeju) - .arrivalHub(seoul) - .distance(new BigDecimal("465.00")) - .duration(480) - .build()); - // 경기 ↔ 제주 - routes.add(HubRoute.builder() - .departureHub(gyeonggi) - .arrivalHub(jeju) - .distance(new BigDecimal("480.00")) - .duration(500) - .build()); - routes.add(HubRoute.builder() - .departureHub(jeju) - .arrivalHub(gyeonggi) - .distance(new BigDecimal("480.00")) - .duration(500) - .build()); + addBidirectionalRoute(routes, seoul, gyeonggi, "30.00", 45); + addBidirectionalRoute(routes, seoul, jeju, "465.00", 480); + addBidirectionalRoute(routes, gyeonggi, jeju, "480.00", 500); @@ return routes; } + + private void addBidirectionalRoute( + List<HubRoute> routes, Hub a, Hub b, String distance, int duration + ) { + BigDecimal d = new BigDecimal(distance); + routes.add(HubRoute.builder().departureHub(a).arrivalHub(b).distance(d).duration(duration).build()); + routes.add(HubRoute.builder().departureHub(b).arrivalHub(a).distance(d).duration(duration).build()); + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@hub-service/src/main/java/com/shipflow/hubservice/infrastructure/initializer/DataInitializer.java` around lines 86 - 124, Extract the repeated bidirectional route creation into a helper method (e.g., addBidirectionalRoute) in DataInitializer that takes parameters (List<HubRoute> routes, Hub departure, Hub arrival, BigDecimal distance, int duration) and internally calls routes.add(HubRoute.builder()...build()) twice for departure→arrival and arrival→departure using HubRoute.builder(); then replace the repeated blocks that call routes.add(HubRoute.builder()...) for 서울↔경기, 서울↔제주, 경기↔제주 with calls to addBidirectionalRoute(routes, seoul, gyeonggi, new BigDecimal("30.00"), 45), addBidirectionalRoute(routes, seoul, jeju, new BigDecimal("465.00"), 480), and addBidirectionalRoute(routes, gyeonggi, jeju, new BigDecimal("480.00"), 500) respectively so distance/duration are set in one place.
82-84: 허브 조회를 인덱스 의존 대신 ID 기반으로 바꾸면 안전합니다.현재
Line 82~Line 84는 리스트 순서 변경 시 오동작 위험이 있습니다.변경 예시
- Hub seoul = hubs.get(0); - Hub gyeonggi = hubs.get(1); - Hub jeju = hubs.get(2); + Hub seoul = hubs.stream() + .filter(h -> SEOUL_HUB_ID.equals(h.getId())) + .findFirst() + .orElseThrow(() -> new IllegalStateException("Seoul hub not found")); + Hub gyeonggi = hubs.stream() + .filter(h -> GYEONGGI_HUB_ID.equals(h.getId())) + .findFirst() + .orElseThrow(() -> new IllegalStateException("Gyeonggi hub not found")); + Hub jeju = hubs.stream() + .filter(h -> JEJU_HUB_ID.equals(h.getId())) + .findFirst() + .orElseThrow(() -> new IllegalStateException("Jeju hub not found"));🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@hub-service/src/main/java/com/shipflow/hubservice/infrastructure/initializer/DataInitializer.java` around lines 82 - 84, The code in DataInitializer currently assigns Hub seoul/gyeonggi/jeju via hubs.get(0/1/2), which is fragile if list order changes; replace those index-based accesses with ID-based lookups from the hubs collection (e.g., build a Map<Id,Hub> or use hubs.stream().filter(h -> h.getId().equals(<SEOUl_ID>)).findFirst().orElseThrow(...)) and assign seoul/gyeonggi/jeju by their known hub IDs; update any constants or test data to supply the correct IDs and throw a clear exception if an expected ID is missing.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@hub-service/src/main/java/com/shipflow/hubservice/infrastructure/initializer/DataInitializer.java`:
- Around line 86-124: Extract the repeated bidirectional route creation into a
helper method (e.g., addBidirectionalRoute) in DataInitializer that takes
parameters (List<HubRoute> routes, Hub departure, Hub arrival, BigDecimal
distance, int duration) and internally calls
routes.add(HubRoute.builder()...build()) twice for departure→arrival and
arrival→departure using HubRoute.builder(); then replace the repeated blocks
that call routes.add(HubRoute.builder()...) for 서울↔경기, 서울↔제주, 경기↔제주 with calls
to addBidirectionalRoute(routes, seoul, gyeonggi, new BigDecimal("30.00"), 45),
addBidirectionalRoute(routes, seoul, jeju, new BigDecimal("465.00"), 480), and
addBidirectionalRoute(routes, gyeonggi, jeju, new BigDecimal("480.00"), 500)
respectively so distance/duration are set in one place.
- Around line 82-84: The code in DataInitializer currently assigns Hub
seoul/gyeonggi/jeju via hubs.get(0/1/2), which is fragile if list order changes;
replace those index-based accesses with ID-based lookups from the hubs
collection (e.g., build a Map<Id,Hub> or use hubs.stream().filter(h ->
h.getId().equals(<SEOUl_ID>)).findFirst().orElseThrow(...)) and assign
seoul/gyeonggi/jeju by their known hub IDs; update any constants or test data to
supply the correct IDs and throw a clear exception if an expected ID is missing.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d1d74bb2-ffaa-407b-8814-a4b1bd210ee8
📒 Files selected for processing (2)
docker/postgres/init/02-init-data.sqlhub-service/src/main/java/com/shipflow/hubservice/infrastructure/initializer/DataInitializer.java
…는 문제 반영. sql은 직접 실행해야함. -
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 PR 제목
[Feature] / [Fix] / [Refactor] 제목작성 (#49)
✨ 작업 내용
허브 삭제 시나리오와 관련된 시드 데이터를 추가했습니다.
🔍 상세 내용
🔗 관련 이슈
Closes #49
✅ 체크리스트
Summary by CodeRabbit
릴리스 노트