추천_물품_리스트_조회_시_사용자_반경_radiusInMeters_내_물품만_반환하도록_개선 : feat : 추천 리스트 조…#554
Hidden character warning
Conversation
WalkthroughRECOMMENDED 정렬 경로에 사용자 위치 기반 반경 필터를 추가하고, ItemService에서 반경 계산 및 회원 위치 로딩 조건을 확장하며 API 문서의 변경 로그 및 오류 코드 설명을 업데이트합니다. Changes
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (3)
RomRom-Domain-Item/src/main/java/com/romrom/item/repository/postgres/ItemRepositoryImpl.javaRomRom-Domain-Item/src/main/java/com/romrom/item/service/ItemService.javaRomRom-Web/src/main/java/com/romrom/web/controller/api/ItemControllerDocs.java
RomRom-Domain-Item/src/main/java/com/romrom/item/service/ItemService.java
Show resolved
Hide resolved
RomRom-Web/src/main/java/com/romrom/web/controller/api/ItemControllerDocs.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
♻️ 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
📒 Files selected for processing (2)
RomRom-Domain-Item/src/main/java/com/romrom/item/service/ItemService.javaRomRom-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
…회시 반경내 물품만 반환 #538
Summary by CodeRabbit
새로운 기능
개선 사항
문서화