Skip to content

추천_물품_리스트_조회_시_사용자_반경_radiusInMeters_내_물품만_반환하도록_개선 : feat : 추천 리스트 조…#554

Merged
nayoung04 merged 2 commits intomainfrom
20260224_#538_추천_물품_리스트_조회_시_사용자_반경_radiusInMeters_내_물품만_반환하도록_개선
Feb 27, 2026

Hidden character warning

The head ref may contain hidden characters: "20260224_#538_\ucd94\ucc9c_\ubb3c\ud488_\ub9ac\uc2a4\ud2b8_\uc870\ud68c_\uc2dc_\uc0ac\uc6a9\uc790_\ubc18\uacbd_radiusInMeters_\ub0b4_\ubb3c\ud488\ub9cc_\ubc18\ud658\ud558\ub3c4\ub85d_\uac1c\uc120"
Merged

추천_물품_리스트_조회_시_사용자_반경_radiusInMeters_내_물품만_반환하도록_개선 : feat : 추천 리스트 조…#554
nayoung04 merged 2 commits intomainfrom
20260224_#538_추천_물품_리스트_조회_시_사용자_반경_radiusInMeters_내_물품만_반환하도록_개선

Conversation

@nayoung04
Copy link
Collaborator

@nayoung04 nayoung04 commented Feb 26, 2026

…회시 반경내 물품만 반환 #538

Summary by CodeRabbit

  • 새로운 기능

    • 추천(Recommended) 정렬 시 사용자의 위치를 기준으로 반경 내 항목만 반환하도록 지리적 필터가 적용되었습니다.
  • 개선 사항

    • 추천 정렬도 거리 기반 트리거에 포함되어 멤버 위치 로드가 확장되었습니다.
    • 검색 반경이 미설정일 때 기본값 10km가 적용되며, 해당 상황을 기록하는 디버그 로깅이 추가되었습니다.
  • 문서화

    • 추천 아이템 목록 관련 API 설명이 업데이트되었고, 관련 오류 코드(위치/임베딩 관련)가 문서에 추가되었습니다.

@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2026

Walkthrough

RECOMMENDED 정렬 경로에 사용자 위치 기반 반경 필터를 추가하고, ItemService에서 반경 계산 및 회원 위치 로딩 조건을 확장하며 API 문서의 변경 로그 및 오류 코드 설명을 업데이트합니다.

Changes

Cohort / File(s) Summary
Repository Geospatial Filtering
RomRom-Domain-Item/src/main/java/com/romrom/item/repository/postgres/ItemRepositoryImpl.java
RECOMMENDED 분기에서 longitude/latitude/radiusInMeters가 제공되면 ST_DistanceSphere 기반 반경 폴리곤 조건을 콘텐츠 및 카운트 쿼리에 적용하여 결과를 지정된 반경 내로 제한합니다.
Service Location & Radius Logic
RomRom-Domain-Item/src/main/java/com/romrom/item/service/ItemService.java
DISTANCE에 더해 RECOMMENDED도 회원 위치 기반 트리거에 포함하고, 반경 계산을 member.getSearchRadiusInMeters -> request.radiusInMeters -> 기본 10000.0(10km) 순으로 재작성하고, 기본값 적용 시 디버그 로그를 추가했습니다.
API Documentation
RomRom-Web/src/main/java/com/romrom/web/controller/api/ItemControllerDocs.java
postLike 변경 로그에 RECOMMENDED가 사용자 근처 항목만 반환함을 추가하고, getItemList 문서에 EMBEDDING_NOT_FOUNDMEMBER_LOCATION_NOT_FOUND 오류 코드를 추가했습니다.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant Controller as ItemController
  participant Service as ItemService
  participant MemberLoc as MemberLocationService
  participant Repo as ItemRepositoryImpl
  participant DB as Database

  Client->>Controller: getItemList(request)
  Controller->>Service: build request/context
  Service->>MemberLoc: load member location (if DISTANCE or RECOMMENDED)
  MemberLoc-->>Service: member location (lon, lat) or null
  Service->>Repo: filterItems(filters + lon/lat/radius)
  Repo->>DB: execute content query (ST_DistanceSphere filter if RECOMMENDED)
  DB-->>Repo: items
  Repo->>DB: execute count query (same geo filter)
  DB-->>Repo: count
  Repo-->>Service: items + count
  Service-->>Controller: response
  Controller-->>Client: return results
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

  • 이슈 #538: RECOMMENDED 경로에 반경 기반 필터링을 구현하는 요청과 직접적으로 일치합니다.

Possibly related PRs

  • PR #455: ItemRepositoryImpl의 RECOMMENDED 경로 변경(지리적 필터 추가)과 직접적인 코드적 연관이 있습니다.
  • PR #292: ItemRepositoryImpl 및 ItemService의 정렬/지리공간 필터링 변경 작업과 겹칩니다.
  • PR #401: ItemService의 검색 반경 계산/사용 방식 변경과 관련된 연속 작업입니다.

Suggested reviewers

  • Cassiiopeia
  • Chuseok22
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목이 주요 변경 사항을 명확하게 설명합니다. 추천 물품 리스트 조회 시 사용자 반경 내 물품만 반환하도록 개선하는 내용이 코드 변경 사항과 일치합니다.

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

✨ 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 20260224_#538_추천_물품_리스트_조회_시_사용자_반경_radiusInMeters_내_물품만_반환하도록_개선

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

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@RomRom-Domain-Item/src/main/java/com/romrom/item/service/ItemService.java`:
- Around line 229-239: The radius selection logic in ItemService incorrectly
prioritizes member.getSearchRadiusInMeters() over request.getRadiusInMeters()
and applies the default/ warning unconditionally; change it so radius is only
computed for distance-based searches (when request.getSearchType() is DISTANCE
or RECOMMENDED), give request.getRadiusInMeters() higher priority than
member.getSearchRadiusInMeters(), and only apply the 10000.0 default and log the
warning when the effective radius is still null inside that distance-only
branch; update the variable radiusInMeters and logging accordingly (refer to
radiusInMeters, request.getRadiusInMeters(),
request.getMember().getSearchRadiusInMeters(), and the search type check in
ItemService).

In
`@RomRom-Web/src/main/java/com/romrom/web/controller/api/ItemControllerDocs.java`:
- Around line 345-348: The documented error codes in ItemControllerDocs (lines
listing INVALID_SOCIAL_TOKEN, SOCIAL_AUTH_FAILED, MEMBER_NOT_FOUND) do not match
the controller's actual failure paths; update the API error-code section in
ItemControllerDocs to reflect the real errors thrown by the implementation
(e.g., MEMBER_LOCATION_NOT_FOUND, EMBEDDING_NOT_FOUND, MEMBER_NOT_FOUND if still
applicable) and remove or relocate social-auth related codes
(INVALID_SOCIAL_TOKEN, SOCIAL_AUTH_FAILED) that belong to auth endpoints; ensure
the list and descriptions match the exceptions/enum names used by the
ItemController and related services so the docs and implementation stay in sync.

ℹ️ 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 ebbf906 and dbc4ea1.

📒 Files selected for processing (3)
  • RomRom-Domain-Item/src/main/java/com/romrom/item/repository/postgres/ItemRepositoryImpl.java
  • RomRom-Domain-Item/src/main/java/com/romrom/item/service/ItemService.java
  • RomRom-Web/src/main/java/com/romrom/web/controller/api/ItemControllerDocs.java

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
RomRom-Domain-Item/src/main/java/com/romrom/item/service/ItemService.java (1)

229-239: ⚠️ Potential issue | 🟠 Major

반경 우선순위/적용 범위가 의도와 다를 수 있습니다.

Line 229-233은 요청 반경(request.getRadiusInMeters())보다 회원 저장 반경을 우선 적용하고, Line 235-239 기본값 적용도 정렬 타입과 무관하게 실행됩니다. RECOMMENDED/DISTANCE에서만 반경을 계산하고, 요청 반경 우선으로 두는 쪽이 PR 목적에 맞습니다.

수정 예시
-    // 회원 탐색 범위 조회
-    Double radiusInMeters = request.getMember().getSearchRadiusInMeters();
-
-    if (radiusInMeters == null) {
-      radiusInMeters = request.getRadiusInMeters();
-    }
-
-    // 회원 탐색 범위 미설정 시 10km로 적용
-    if (radiusInMeters == null) {
-      radiusInMeters = 10000.0;
-      log.debug("회원 탐색 범위 미설정 - 10km 적용: memberId={}", request.getMember().getMemberId());
-    }
+    Double radiusInMeters = null;
+    if (sortField == ItemSortField.DISTANCE || sortField == ItemSortField.RECOMMENDED) {
+      // 요청값 우선, 미지정 시 회원 설정 반경 fallback
+      radiusInMeters = request.getRadiusInMeters();
+      if (radiusInMeters == null) {
+        radiusInMeters = request.getMember().getSearchRadiusInMeters();
+      }
+
+      // 둘 다 없으면 기본값 적용
+      if (radiusInMeters == null) {
+        radiusInMeters = 10000.0;
+        log.debug("회원 탐색 범위 미설정 - 10km 적용: memberId={}", request.getMember().getMemberId());
+      }
+    }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@RomRom-Domain-Item/src/main/java/com/romrom/item/service/ItemService.java`
around lines 229 - 239, The current logic in ItemService sets radiusInMeters
from the member's stored search radius before falling back to
request.getRadiusInMeters() and always applies a 10,000m default, which
contradicts the intended behavior to prefer the request radius and to only apply
radius filtering for RECOMMENDED/DISTANCE sorts; update the radius determination
to: 1) prefer request.getRadiusInMeters() when non-null, 2) if request radius is
null then use request.getMember().getSearchRadiusInMeters(), and 3) only apply
the default 10000.0 and any radius-based filtering when the sort type is
RECOMMENDED or DISTANCE (otherwise treat radius as null/no-filter). Modify the
block using the radiusInMeters variable in ItemService so sorting/type checks
(RECOMMENDED/DISTANCE) guard the default and filtering behavior and ensure
log.debug still records when the member default or system default is applied.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@RomRom-Domain-Item/src/main/java/com/romrom/item/service/ItemService.java`:
- Around line 229-239: The current logic in ItemService sets radiusInMeters from
the member's stored search radius before falling back to
request.getRadiusInMeters() and always applies a 10,000m default, which
contradicts the intended behavior to prefer the request radius and to only apply
radius filtering for RECOMMENDED/DISTANCE sorts; update the radius determination
to: 1) prefer request.getRadiusInMeters() when non-null, 2) if request radius is
null then use request.getMember().getSearchRadiusInMeters(), and 3) only apply
the default 10000.0 and any radius-based filtering when the sort type is
RECOMMENDED or DISTANCE (otherwise treat radius as null/no-filter). Modify the
block using the radiusInMeters variable in ItemService so sorting/type checks
(RECOMMENDED/DISTANCE) guard the default and filtering behavior and ensure
log.debug still records when the member default or system default is applied.

ℹ️ 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 dbc4ea1 and b547917.

📒 Files selected for processing (2)
  • RomRom-Domain-Item/src/main/java/com/romrom/item/service/ItemService.java
  • RomRom-Web/src/main/java/com/romrom/web/controller/api/ItemControllerDocs.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • RomRom-Web/src/main/java/com/romrom/web/controller/api/ItemControllerDocs.java

Copy link
Member

@Chuseok22 Chuseok22 left a comment

Choose a reason for hiding this comment

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

고고 머지합시다

@nayoung04 nayoung04 merged commit 082ad0c into main Feb 27, 2026
1 check passed
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.

2 participants