Skip to content

[FEATURE] 시드 데이터 정리 — 허브 3개(서울/경기/제주)로 축소 및 초기 데이터 추가 - #50

Closed
afterrest wants to merge 2 commits into
developfrom
feature/#49-hubDelete-e2e-test
Closed

afterrest wants to merge 2 commits into
developfrom
feature/#49-hubDelete-e2e-test

Conversation

@afterrest

@afterrest afterrest commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

📌 PR 제목

[Feature] / [Fix] / [Refactor] 제목작성 (#49)


✨ 작업 내용

허브 삭제 시나리오와 관련된 시드 데이터를 추가했습니다.


🔍 상세 내용


🔗 관련 이슈

Closes #49


⚠️ 리뷰 포인트 (선택)


✅ 체크리스트

  • 코드가 정상적으로 동작합니다.
  • 테스트를 완료했습니다.
  • 코드 스타일을 준수했습니다.

Summary by CodeRabbit

릴리스 노트

  • Chores
    • 시스템 초기 데이터 설정 추가 (사용자, 관리자, 회사 정보)
    • 허브 네트워크 구성 최적화 (3개 주요 허브 및 배송 경로 설정)

- 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>
@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

이 변경사항은 PostgreSQL 초기화 스크립트와 Java 데이터 초기화 로직을 업데이트합니다. 새로운 SQL 스크립트(02-init-data.sql)는 사용자, 배송 관리자, 회사 데이터를 데이터베이스에 시드하고, DataInitializer.java는 3개의 고정 허브(서울, 경기, 제주)만 생성하도록 변경됩니다. 기존의 동적 경로 생성 로직(HashSet 사용)을 제거하고 3개 허브 간의 명시적인 양방향 연결로 대체합니다.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive 설명은 템플릿 구조를 따르고 있으나, 상세 내용(🔍 상세 내용) 섹션이 비워있어 변경사항에 대한 구체적 설명이 부족합니다. 상세 내용 섹션을 채워 DataInitializer 변경사항과 SQL 초기 데이터 추가에 대한 구체적 설명을 추가해주세요.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목은 주요 변경사항을 명확하게 요약합니다: 시드 데이터 정리와 허브 3개(서울/경기/제주)로의 축소 및 초기 데이터 추가.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/#49-hubDelete-e2e-test

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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

📥 Commits

Reviewing files that changed from the base of the PR and between ae3056d and 33194e2.

📒 Files selected for processing (2)
  • docker/postgres/init/02-init-data.sql
  • hub-service/src/main/java/com/shipflow/hubservice/infrastructure/initializer/DataInitializer.java

@afterrest afterrest closed this Apr 7, 2026
@afterrest
afterrest deleted the feature/#49-hubDelete-e2e-test branch April 7, 2026 03:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] 허브 삭제 시나리오 용 시드 데이터 정리

1 participant