Skip to content

feat: region-seed 추가 - #61

Merged
kwonwnsduf merged 1 commit into
developfrom
feature/region-seed
Aug 11, 2026
Merged

kwonwnsduf merged 1 commit into
developfrom
feature/region-seed

Conversation

@kwonwnsduf

@kwonwnsduf kwonwnsduf commented Aug 11, 2026 •

Copy link
Copy Markdown
Collaborator

🔗 관련 이슈


📝 What is this PR?

애플리케이션 실행 시 서울특별시와 25개 자치구 데이터를 자동으로 초기화합니다.

  • API 변경 사항 없음

✨ Changes

  • ApplicationRunner 기반의 RegionDataInitializer를 추가했습니다.
  • 서울특별시 데이터가 없으면 SIDO 레벨로 생성합니다.
  • 서울특별시 산하 25개 자치구를 SIGUNGU 레벨로 생성합니다.
  • 초기화 로직을 여러 번 실행해도 기존 지역 데이터가 중복 저장되지 않도록 구현했습니다.
  • 일부 자치구만 존재하는 경우 누락된 자치구만 추가합니다.
  • 기존에 "서울"로 저장된 데이터도 서울 지역으로 인식하도록 처리했습니다.
  • 지역 및 하위 자치구 조회를 위한 Repository 메서드를 추가했습니다.
  • 다음 상황을 검증하는 테스트를 추가했습니다.
    • 서울특별시와 25개 자치구 생성
    • 초기화 재실행 시 중복 방지
    • 일부 데이터가 존재할 때 누락된 자치구만 생성

🧪 Result

  • RegionDataInitializerTest 테스트 3건 통과
  • BUILD SUCCESSFUL

👀 To. Reviewer

  • 애플리케이션 실행 시 지역 데이터를 초기화하는 방식이 적절한지 확인 부탁드립니다.
  • 기존 "서울" 데이터와 "서울특별시" 데이터를 함께 고려한 중복 방지 로직을 집중적으로 확인 부탁드립니다.
  • 운영 환경에서 일부 지역 데이터가 이미 존재할 때 누락된 자치구만 추가되는 로직을 확인 부탁드립니다.

✅ 체크 리스트

  • base 브랜치(develop 또는 main) 최신 상태 pull 및 충돌 확인 완료
  • Reviewers 설정
  • Assignees 설정
  • Labels 설정

Summary by CodeRabbit

  • New Features
    • Automatically initializes Seoul region data, including its 25 districts.
    • Completes missing regional data without creating duplicates.
    • Safely supports repeated initialization when data already exists.

@kwonwnsduf kwonwnsduf self-assigned this Aug 11, 2026
@kwonwnsduf kwonwnsduf added the ✨ feature 새로운 기능을 추가하는 작업 label Aug 11, 2026
@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds transactional startup seeding for Seoul and its 25 districts. Repository queries locate existing regions. JPA tests verify complete, repeated, and partial initialization without duplicates.

Changes

Region data seeding

Layer / File(s) Summary
Region repository queries
src/main/java/com/daytodo/domain/region/repository/RegionRepository.java
Adds queries for top-level regions by level and name, and child regions by parent and level.
Transactional Seoul initialization and validation
src/main/java/com/daytodo/domain/region/config/RegionDataInitializer.java, src/test/java/com/daytodo/domain/region/config/RegionDataInitializerTest.java
Adds a Spring ApplicationRunner that creates missing Seoul region data. Tests verify complete seeding, idempotent repeated runs, and completion of partial data.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: nariming

Sequence Diagram(s)

sequenceDiagram
  participant ApplicationStartup
  participant RegionDataInitializer
  participant RegionRepository
  participant RegionDatabase
  ApplicationStartup->>RegionDataInitializer: run(ApplicationArguments)
  RegionDataInitializer->>RegionRepository: find Seoul and existing districts
  RegionRepository->>RegionDatabase: execute region queries
  RegionDataInitializer->>RegionRepository: save missing regions
  RegionRepository->>RegionDatabase: persist Seoul region data
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the addition of the region-seed feature, which matches the main change.
Linked Issues check ✅ Passed The PR implements issue #60 by adding Seoul and 25 district seed data with idempotent initialization.
Out of Scope Changes check ✅ Passed All production and test changes directly support the region-seed objective in issue #60.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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/region-seed

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/test/java/com/daytodo/domain/region/config/RegionDataInitializerTest.java`:
- Around line 64-68: Add a test case alongside
insertsOnlyMissingDistrictsWhenSomeDataAlreadyExists that seeds an existing SIDO
named "서울", runs RegionDataInitializer.run, and verifies the legacy root remains
the sole root with exactly 25 districts. Use the existing repository and
assertion patterns without changing initializer behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8abdbd84-0bbe-4df9-979b-eeac11209e5c

📥 Commits

Reviewing files that changed from the base of the PR and between be126b4 and e89ef30.

📒 Files selected for processing (3)
  • src/main/java/com/daytodo/domain/region/config/RegionDataInitializer.java
  • src/main/java/com/daytodo/domain/region/repository/RegionRepository.java
  • src/test/java/com/daytodo/domain/region/config/RegionDataInitializerTest.java

Comment on lines +64 to +68
void insertsOnlyMissingDistrictsWhenSomeDataAlreadyExists() throws Exception {
Region seoul = regionRepository.save(new Region(null, "서울특별시", RegionLevel.SIDO));
regionRepository.save(new Region(seoul, "종로구", RegionLevel.SIGUNGU));

new RegionDataInitializer(regionRepository).run(null);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add coverage for the legacy 서울 root.

The tests do not verify the stated behavior for an existing SIDO named "서울". Add a case that seeds this root, runs the initializer, and verifies that it remains the only root and has 25 districts.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/test/java/com/daytodo/domain/region/config/RegionDataInitializerTest.java`
around lines 64 - 68, Add a test case alongside
insertsOnlyMissingDistrictsWhenSomeDataAlreadyExists that seeds an existing SIDO
named "서울", runs RegionDataInitializer.run, and verifies the legacy root remains
the sole root with exactly 25 districts. Use the existing repository and
assertion patterns without changing initializer behavior.

@hyeoniss hyeoniss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

수고하셨습니다!!

@kwonwnsduf
kwonwnsduf merged commit 7b605ed into develop Aug 11, 2026
1 check passed
@kwonwnsduf
kwonwnsduf deleted the feature/region-seed branch August 11, 2026 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ feature 새로운 기능을 추가하는 작업

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FEAT: region-seed 추가

2 participants