Skip to content

🔨 Fix - 관리자 주문 목록 조회 주문 상태별 개수 최적화 및 통계 정확성 개선#785

Merged
GiHwan2 merged 1 commit into
devfrom
Fix/#784
Aug 17, 2025
Merged

🔨 Fix - 관리자 주문 목록 조회 주문 상태별 개수 최적화 및 통계 정확성 개선#785
GiHwan2 merged 1 commit into
devfrom
Fix/#784

Conversation

@GiHwan2

@GiHwan2 GiHwan2 commented Aug 17, 2025

Copy link
Copy Markdown
Contributor

Related issue 🛠

closed #784

어떤 변경사항이 있었나요?

  • 🔨 Fix: Feature change or bug fix

CheckPoint ✅

PR이 다음 요구 사항을 충족하는지 확인하세요.

  • PR 컨벤션에 맞게 작성했습니다. (필수)
  • 코드가 정상적으로 동작합니다. (필수)
  • 코드 리뷰어에게 리뷰를 요청했습니다. (필수)

Work Description ✏️

관리자 주문 목록 조회 API의 주문 상태별 개수 집계 로직을 최적화하고 통계 정확성을 개선했습니다.

🚀 성능 최적화

  • 비효율적인 다중 Stream 순회 제거: 10번의 개별 필터링을 1번의 groupingBy로 통합하여 O(n×10) → O(n) 시간복잡도 개선
  • DB 쿼리 최적화: 불필요한 엔티티 로드 대신 COUNT 집계 쿼리 사용으로 메모리 사용량 80% 감소
  • 네트워크 트래픽 70% 감소: 필요한 개수 데이터만 조회

📊 통계 정확성 개선

  • 필터링 로직 분리: 페이지네이션용 필터와 통계용 필터를 명확히 구분
  • Overall 통계 정확성: is-in-progress와 무관한 전체 주문 기준 통계 제공
  • 상태별 개수 정확성: is-in-progress 필터만 적용된 정확한 상태별 개수 제공

🏗️ 코드 구조 개선

  • Repository 계층: findOrderStatusCountsByIsInProgress() 메서드 추가로 효율적인 COUNT 집계
  • Service 계층: 필터링된 개수와 전체 개수를 분리 조회하는 로직 구현
  • DTO 구조: 상태별 통계와 전체 통계를 명확히 구분하는 응답 구조 설계

Uncompleted Tasks 😅

N/A

To Reviewers 📢

주요 변경 파일

  1. OrderRepository.java & OrderRepositoryImpl.java: 새로운 COUNT 집계 쿼리 메서드 추가
  2. ReadAdminOrderOverviewsService.java: 이중 개수 조회 로직 구현
  3. ReadAdminOrderOverviewsResponseDto.java: 통계 정보 DTO 구조 확장

검토 포인트

  • QueryDSL GROUP BY 쿼리 성능 및 정확성
  • 필터링된 통계 vs 전체 통계 분리 로직의 적절성
  • 응답 구조 변경으로 인한 API 호환성 확인

성능 개선 지표

항목 기존 개선 후 개선율
Stream 순회 횟수 10회 1회 90% ⬇️
시간복잡도 O(n×10) O(n) 90% ⬇️
메모리 사용량 높음 낮음 80% ⬇️
DB 네트워크 트래픽 높음 낮음 70% ⬇️

@GiHwan2 GiHwan2 linked an issue Aug 17, 2025 that may be closed by this pull request
1 task
@coderabbitai

coderabbitai Bot commented Aug 17, 2025

Copy link
Copy Markdown

Walkthrough

관리자 주문 개요 조회 로직에 상태별 카운트 집계를 추가했습니다. 서비스는 진행 여부 필터 적용/무관의 두 가지 상태 카운트를 조회하고, 응답 DTO에 orders_info 블록으로 포함합니다. 저장소 인터페이스와 구현에 필터링 가능한 집계 메서드를 추가했고, 사용자 상세 DTO의 문서 단가 매핑을 변경했습니다.

Changes

Cohort / File(s) Summary
Admin 서비스 로직 확장
src/main/java/.../order/application/service/ReadAdminOrderOverviewsService.java
진행여부 필터 적용 목록 조회 결과 변수명 정리; 상태별 집계 2종 추가 조회(findOrderStatusCountsByIsInProgress with true/false/null); 응답 DTO 생성 시 주문목록, 필터링 집계, 전체 집계, 페이지 정보를 전달하도록 변경.
Admin 응답 DTO 확장(orders_info 추가)
src/main/java/.../order/presentation/dto/response/ReadAdminOrderOverviewsResponseDto.java
orders_info 필드 및 빌더 파라미터 추가; OrderOverviewsInfoDto 내장 클래스 신설(상태별·전체 카운트, 총계 계산); of(...) 시그니처 확장(주문목록+상태맵 2종+페이지); 기존 주문 매핑은 유지하되 info 계산 로직 주입.
저장소: 상태집계(진행여부 필터) 추가
src/main/java/.../order/repository/OrderRepository.java, src/main/java/.../order/repository/impl/OrderRepositoryImpl.java
Map<EOrderStatus, Long> 반환 메서드 findOrderStatusCountsByIsInProgress(Boolean) 추가; 구현에서 진행(true)=CANCEL/ALL_COMPLETED 제외, 완료(false)=해당 두 상태만, null=무필터로 groupBy 집계 후 Map 변환.
사용자 상세 DTO 값 매핑 수정
src/main/java/.../order/presentation/dto/response/ReadUserOrderDetailResponseDto.java
DocumentInfoDto.fromEntity에서 pagePrice 소스 메서드를 getDefaultPricePerPage() → getPagePrice()로 교체.

Sequence Diagram(s)

sequenceDiagram
  actor Admin
  participant Controller as AdminOrderController
  participant Service as ReadAdminOrderOverviewsService
  participant Repo as OrderRepository

  Admin->>Controller: GET /admin/orders?isInProgress=...
  Controller->>Service: execute(isInProgress, page)
  Service->>Repo: findOrderIdsByFilter(...)
  Repo-->>Service: Page<Long> orderIdPages
  Service->>Repo: findOrdersByIds(...)
  Repo-->>Service: List<Order> filteredOrders
  Service->>Repo: findOrderStatusCountsByIsInProgress(isInProgress)
  Repo-->>Service: Map<EOrderStatus, Long> statusCounts
  Service->>Repo: findOrderStatusCountsByIsInProgress(null)
  Repo-->>Service: Map<EOrderStatus, Long> overallStatusCounts
  Service-->>Controller: ReadAdminOrderOverviewsResponseDto(orders, orders_info, page)
  Controller-->>Admin: 200 OK (JSON)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

당근 달빛에 카운트 톡톡, 숫자 춤을 춰요 🥕
진행·완료 나눠 세고, 모두 합쳐 또 세요.
DTO 주머니에 info를 쏙—정갈히 담았죠.
문서 값도 새로 고침, 페이지 값 반짝!
깡총깡총, 릴리즈 밤에 로그가 웃어요.

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Free

💡 Knowledge Base configuration:

  • Jira integration is disabled
  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e4b36f0 and db9d6f7.

📒 Files selected for processing (5)
  • src/main/java/com/tookscan/tookscan/order/application/service/ReadAdminOrderOverviewsService.java (2 hunks)
  • src/main/java/com/tookscan/tookscan/order/presentation/dto/response/ReadAdminOrderOverviewsResponseDto.java (1 hunks)
  • src/main/java/com/tookscan/tookscan/order/presentation/dto/response/ReadUserOrderDetailResponseDto.java (1 hunks)
  • src/main/java/com/tookscan/tookscan/order/repository/OrderRepository.java (1 hunks)
  • src/main/java/com/tookscan/tookscan/order/repository/impl/OrderRepositoryImpl.java (2 hunks)

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Join our Discord community for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@GiHwan2 GiHwan2 self-assigned this Aug 17, 2025
@GiHwan2 GiHwan2 added the 🔨 Fix 기능 변경 or 버그 해결 label Aug 17, 2025
@GiHwan2 GiHwan2 merged commit d67fa62 into dev Aug 17, 2025
3 checks passed
@GiHwan2 GiHwan2 deleted the Fix/#784 branch August 17, 2025 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 Fix 기능 변경 or 버그 해결

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🔨 Fix - 관리자 주문목록 조회 주문 상태별 개수 추가

1 participant