feat(user): 찜 토글 + isWishlisted 노출 + 카운트 일관성 수정#80
Conversation
마이페이지 figma 02-main-login의 찜 기능을 백엔드에 도입한다. 하트 버튼 클릭 시 추가/해제하는 멱등 mutation과 목록 조회, 그리고 최근 본 상품에 isWishlisted 매핑까지 함께 반영한다. ## 변경 사항 - SDL 신규: user-wishlist.graphql (myWishlist / addToWishlist / removeFromWishlist) - SDL 갱신: RecentViewedProductSummary.isWishlisted: Boolean! - 신규 service: UserWishlistService (UserBaseService 상속) - 신규 resolver: UserWishlistQueryResolver / UserWishlistMutationResolver - UserRepository: upsertWishlistItem / softDeleteWishlistItem / findWishlistedProductIds (단일 IN 쿼리, N+1 회피) / findWishlistItems - ProductRepository: existsActiveProduct (active+soft-delete 검증, 재사용 가능한 가벼운 헬퍼) - 카운트 일관성 버그 수정: countWishlistItems / getViewerCounts.wishlistCount에 deleted_at: null 필터 누락 → soft-delete된 위시리스트도 카운트에 포함되던 문제 수정 - user-mypage.service / user-recent-view.service: 매핑 시 isWishlisted 계산 (findWishlistedProductIds set으로 일괄 조회, N+1 회피) - 회귀 테스트 다수 - UserWishlistService spec 15건 - UserWishlistResolver spec 2건 (NotFound 전파 / 추가→목록→해제 시나리오) - mypage spec: recentViewedProducts.isWishlisted 매핑 검증 보강 - recent-view spec: list isWishlisted 매핑 검증 추가
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
Coverage report
Test suite run success867 tests passing in 77 suites. Report generated by 🧪jest coverage report action from 02be4b2 |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9a0f2d75af
ℹ️ 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".
| async countWishlistItems(accountId: bigint): Promise<number> { | ||
| return this.prisma.wishlistItem.count({ | ||
| where: { account_id: accountId }, | ||
| where: { account_id: accountId, deleted_at: null }, |
There was a problem hiding this comment.
Match wishlist count filter to myWishlist visibility
countWishlistItems now excludes soft-deleted rows, but it still counts wishlist rows whose products/stores are inactive or soft-deleted, while findWishlistItems explicitly filters those out (product.is_active, product.deleted_at, store.is_active, store.deleted_at). If a user wishlist entry survives but the product/store is later deactivated, myPageOverview.counts.wishlistCount can be greater than myWishlist.totalCount, creating inconsistent badges vs. list contents in production.
Useful? React with 👍 / 👎.
countWishlistItems / getViewerCounts.wishlistCount 가 wishlist soft-delete만 필터링하고 비활성/삭제 product/store에 연결된 row는 카운트에 포함하던 문제 수정. findWishlistItems와 동일한 가시성 조건(product/store active+not-deleted)을 공유하도록 visibleWishlistWhere helper로 통일하여 카운트와 목록 길이가 항상 일치하도록 한다. (Codex 리뷰 P2: count badge vs. list contents 불일치 회피) - visibleWishlistWhere private helper 도입 (UserRepository) - getViewerCounts.wishlistCount / countWishlistItems / findWishlistItems 모두 동일 helper 사용 - 회귀 테스트 1건: 4건 wishlist 중 inactive product / soft-delete product / inactive store 의 product 3건은 카운트에서 제외, visible 1건만 카운트
Summary
마이페이지 figma 02-main-login 명세의 '하트 버튼 클릭 시 찜 추가/해제' 정책을 백엔드에 도입.
mypage figma 정합화 플랜의 마지막 stage.
변경 사항
SDL
Service / Resolver
Repository
카운트 일관성 수정
회귀 테스트
Breaking 여부
Test plan