feat(store): 인기 매장 리스트 API (popularStores·실시간 랭킹 집계)#145
Conversation
🧹 knip — dead-code 리포트전체 리포트
|
🩺 NestJS Doctor — 88/100 (Good)진단 252건 (error 0).
architecture / security 상위 항목
|
|
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 |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Coverage report
Test suite run success1302 tests passing in 153 suites. Report generated by 🧪jest coverage report action from 4ea7aeb |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0f33849638
ℹ️ 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".
| order: { | ||
| status: { in: [...RANKING_VALID_ORDER_STATUSES] }, | ||
| created_at: { gte: since }, |
There was a problem hiding this comment.
Exclude soft-deleted orders from rank counts
When an order row has been soft-deleted but its order items remain, this groupBy still counts those items as recent valid orders because the nested order predicate only checks status and created_at; the soft-delete extension in src/prisma/soft-delete.middleware.ts only amends the root OrderItem read, not nested relation filters. That can let removed/test orders continue boosting a store's popularity, so add deleted_at: null inside the order filter.
Useful? React with 👍 / 👎.
| const products = await this.prisma.product.findMany({ | ||
| where: { store_id: { in: storeIds }, is_active: true, deleted_at: null }, | ||
| orderBy: [{ store_id: 'asc' }, { id: 'desc' }], |
There was a problem hiding this comment.
Limit cake image lookup before materializing products
For stores with more than four active products, this query loads every active product and its first image for every page store, then discards extras in JS after acc.length reaches the card limit. A popular store with thousands of products would make each popularStores request scan and return thousands of rows despite needing at most four URLs per store; cap the query per store before materializing the product rows.
Useful? React with 👍 / 👎.
|
Codex P2 2건 반영 (4ea7aeb): (1) aggregateRecentOrderCounts에 order.deleted_at IS NULL 추가 — nested relation은 soft-delete extension 미적용이라 명시. (2) findStoreCakeImages 매장당 take 4로 쿼리 제한 — 전체 product materialize 제거. |
Summary
인기 매장 리스트(figma 화면 01) 백엔드인 PR2 / 인기 매장 + 랭킹입니다. 지역 필터·인기순 정렬·매장 카드(평점·리뷰수·위치·케이크 이미지)를 제공하는
popularStores쿼리를 신설했습니다.@nestjs/schedule같은 배치 인프라 도입(위험 게이트)을 피하기 위해 실시간 집계 방식으로 구현했습니다. 스키마 변경·마이그레이션·의존성 추가가 전혀 없습니다.Scope
popularStores(input)— 비로그인 public queryw_order·ln(1+최근30일주문) + w_wishlist·ln(1+찜수) + w_rating·베이지안평점regionIds(2차 시군구 다중) →store.region_id INgroupBy로 실시간 산출region_id, store-wishlist)진행 상황
전체 4개 PR 중 2번째 (PR1 지역 마스터는 머지 완료):
isWishlisted)Impact
region_idoverride·store-wishlist 추가(기존 테스트 무영향, 기본값 유지).Test plan
yarn validate전체 통과 — 152 suites / 1296 tests / 커버리지 임계 충족후속(이 PR 범위 밖)
isWishlisted(매장 찜 상태): PR3에서 매장 찜과 함께 SDL·로직 추가@nestjs/schedule): 매장 규모 확대 시 실시간→사전계산 최적화. 의존성 추가라 별도 결정·PR로 분리