Skip to content

[SOU-456] 우선순위가 있는 도시를 변경시 중복되는 버그 수정#179

Merged
Develop-KIM merged 3 commits intodevelopfrom
fix/SOU-456-update-city-priority-logic
Feb 24, 2026
Merged

[SOU-456] 우선순위가 있는 도시를 변경시 중복되는 버그 수정#179
Develop-KIM merged 3 commits intodevelopfrom
fix/SOU-456-update-city-priority-logic

Conversation

@Develop-KIM
Copy link
Member

@Develop-KIM Develop-KIM commented Feb 24, 2026

Summary by CodeRabbit

릴리스 노트

  • 버그 수정

    • 도시 우선순위 조정 로직을 개선하여 상향 조정 시 동작을 최적화했습니다.
  • 테스트

    • 우선순위 변경에 대한 테스트 커버리지를 대폭 확대했습니다. 인접한 우선순위 변경, 특수 사례 및 경계 조건을 포함한 다양한 시나리오를 추가하여 안정성을 강화했습니다.

Copilot AI review requested due to automatic review settings February 24, 2026 10:09
@Develop-KIM Develop-KIM added the bug 기능이 의도대로 동작하지 않거나, 오류가 발생하는 이슈에 사용합니다. label Feb 24, 2026
@Develop-KIM Develop-KIM merged commit 736e5c4 into develop Feb 24, 2026
2 of 3 checks passed
@coderabbitai
Copy link

coderabbitai bot commented Feb 24, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7a73da0 and 4790b8b.

📒 Files selected for processing (2)
  • src/main/java/com/souzip/api/domain/city/service/CityPriorityDomainService.java
  • src/test/java/com/souzip/api/domain/city/service/CityPriorityDomainServiceTest.java

Walkthrough

우선순위 상향 이동 시 oldPriority 값을 oldPriority + 1에서 oldPriority로 변경하여 우선순위 조정 범위를 축소했습니다. 이에 따라 테스트 케이스를 확대하여 다양한 시나리오의 우선순위 조정 및 저장소 조회 동작을 검증합니다.

Changes

Cohort / File(s) Summary
우선순위 조정 로직 수정
src/main/java/com/souzip/api/domain/city/service/CityPriorityDomainService.java
adjustPriorities의 상향 이동 경로에서 pullOldPriorityIfExists 호출 시 매개변수를 oldPriority + 1에서 oldPriority로 변경하여 pull 범위 조정.
우선순위 조정 테스트 강화
src/test/java/com/souzip/api/domain/city/service/CityPriorityDomainServiceTest.java
목표 도시 제외, 인접 우선순위 변경, 양쪽 null 케이스 등 다양한 시나리오 추가. 기존 테스트 업데이트로 pull/push 조회 단계와 updatePriority 호출 시퀀스 검증 강화.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

bug

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/SOU-456-update-city-priority-logic

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 and usage tips.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4790b8bf99

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if (isMovingUp(oldPriority, newPriority)) {
pushNewPriorityIfExists(excludeCityId, newPriority, countryId);
pullOldPriorityIfExists(excludeCityId, oldPriority + 1, countryId);
pullOldPriorityIfExists(excludeCityId, oldPriority, countryId);

Choose a reason for hiding this comment

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

P1 Badge 이동 업에서 pull 시작 인자를 oldPriority+1로 유지하세요

isMovingUp 분기에서 pullOldPriorityIfExistsoldPriority를 넘기면, 내부 구현이 다시 oldPriority + 1부터 조회/당김을 수행하므로 실제로는 기존 oldPriority + 1 도시를 oldPriority로 내리게 됩니다. 같은 분기의 pushNewPriorityIfExists(newPriority)가 이미 oldPriority-1 도시를 oldPriority로 올린 상태(예: 5→2 이동, 2/3/4/6 존재)에서는 두 도시가 동일 우선순위(5)를 갖는 중복이 발생해 정렬/노출 결과가 깨집니다.

Useful? React with 👍 / 👎.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes a bug in the city priority adjustment logic where changing a city's priority to a lower number (higher priority) was incorrectly querying for cities to pull. The bug caused the system to skip one priority level when filling the gap left by the moved city.

Changes:

  • Fixed the isMovingUp case in CityPriorityDomainService to query from the correct priority level when pulling cities
  • Updated existing tests to verify the actual priority update operations
  • Added comprehensive test coverage for edge cases including adjacent priority changes, target city filtering, and null-to-null changes

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/main/java/com/souzip/api/domain/city/service/CityPriorityDomainService.java Fixed bug by changing oldPriority + 1 to oldPriority in the pull operation when moving a city to a higher priority
src/test/java/com/souzip/api/domain/city/service/CityPriorityDomainServiceTest.java Updated existing tests with proper verifications, added new test cases for edge scenarios, and corrected test expectations to match the bug fix

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +284 to +286
// then
verify(city3).updatePriority(2); // 3->2로 당겨짐
}
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

This test is missing verification of the repository method calls. Consistent with other tests in this file, you should verify which repository queries were made. For this scenario, you should verify that the repository was called with the correct priority values to ensure the test properly validates the implementation behavior.

Copilot uses AI. Check for mistakes.
cityPriorityDomainService.adjustPriorities(excludeCityId, oldPriority, newPriority, countryId);

// then
verify(city2).updatePriority(3); // 2->3으로 밀림
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

This test is missing verification of the repository method calls. Consistent with other tests in this file, you should verify which repository queries were made. For this scenario, you should verify that the repository was called with the correct priority values to ensure the test properly validates the implementation behavior.

Suggested change
verify(city2).updatePriority(3); // 2->3으로 밀림
verify(city2).updatePriority(3); // 2->3으로 밀림
verify(cityRepository).findByCountryIdAndPriorityGoeOrderByPriorityAsc(countryId, 2);
verify(cityRepository).findByCountryIdAndPriorityGoeOrderByPriorityAsc(countryId, 4);

Copilot uses AI. Check for mistakes.
// when
cityPriorityDomainService.adjustPriorities(excludeCityId, oldPriority, newPriority, countryId);

// then
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

This test is missing verification of the repository method calls. Consistent with other tests in this file, you should verify which repository queries were made. For this scenario, you should verify that the repository was called with priority value 3 to ensure the test properly validates that the target city filtering logic is working as expected.

Suggested change
// then
// then
verify(cityRepository, times(1)).findByCountryIdAndPriorityGoeOrderByPriorityAsc(countryId, 3);

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 기능이 의도대로 동작하지 않거나, 오류가 발생하는 이슈에 사용합니다.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants