Skip to content

Conversation

@Yyang-YE
Copy link
Collaborator

@Yyang-YE Yyang-YE commented Aug 6, 2025

#️⃣연관된 이슈

#186

📝작업 내용

  • 개인 통계 조회 시 userId 필터가 미적용 되어있는 오류를 수정하였습니다.

📷스크린샷 (선택)

💬리뷰 요구사항(선택)

Summary by CodeRabbit

  • 신규 기능

    • 카테고리 및 브랜드 순위 집계 시, 현재 월의 데이터만을 반영하도록 필터가 추가되었습니다.
  • 버그 수정

    • 불필요한 빈 import 라인이 제거되었습니다.

@Yyang-YE Yyang-YE requested a review from hayong39 August 6, 2025 09:26
@Yyang-YE Yyang-YE self-assigned this Aug 6, 2025
@Yyang-YE Yyang-YE added the fix 버그 수정 label Aug 6, 2025
@coderabbitai
Copy link

coderabbitai bot commented Aug 6, 2025

Walkthrough

이번 변경에서는 사용 내역 집계 쿼리에서 사용자와 현재 달로 한정하는 필터가 추가되었습니다. 또한, 서비스 계층에서 집계 버킷 추출 방식이 필터 집계 하위의 "rank" 서브 집계를 통해 가져오도록 수정되었습니다. 기타 로직에는 변화가 없습니다.

Changes

Cohort / File(s) Change Summary
집계 쿼리 필터 및 집계 구조 변경
src/main/java/com/ureca/uble/domain/users/repository/CustomUsageHistoryDocumentRepositoryImpl.java
- 현재 달 필터 쿼리 메서드 추가
- 집계 쿼리에 사용자+현재달 필터 적용
- category/brand 집계에 filter+rank 구조 적용, brand 집계 상위 5개로 축소
집계 결과 파싱 방식 변경
src/main/java/com/ureca/uble/domain/users/service/UserService.java
- 집계 결과에서 filter 집계 하위의 "rank" terms 집계로 버킷 추출 방식 변경
- 불필요한 빈 import 제거

Sequence Diagram(s)

sequenceDiagram
    participant UserService
    participant CustomUsageHistoryDocumentRepositoryImpl
    participant Elasticsearch

    UserService->>CustomUsageHistoryDocumentRepositoryImpl: getUsageDateAndDiffAndCount(user)
    CustomUsageHistoryDocumentRepositoryImpl->>Elasticsearch: Query with user+current month filter, filter+rank aggs
    Elasticsearch-->>CustomUsageHistoryDocumentRepositoryImpl: Aggregated results (with filter+rank)
    CustomUsageHistoryDocumentRepositoryImpl-->>UserService: Aggregation results
    UserService->>UserService: Extract buckets from filter->rank sub-aggregation
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested labels

BE

Suggested reviewers

  • Eric-HAN-01

Poem

🐇
달마다 집계, 필터로 꽁꽁,
사용자별 랭킹도 쏙쏙!
"rank" 집계 속에 숨어있는
브랜드, 카테고리 톱5 뽑기.
엘라스틱도 깔끔하게,
코드도 한층 더 단단하게!
🥕

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f9d8719 and ce6d0c1.

📒 Files selected for processing (2)
  • src/main/java/com/ureca/uble/domain/users/repository/CustomUsageHistoryDocumentRepositoryImpl.java (3 hunks)
  • src/main/java/com/ureca/uble/domain/users/service/UserService.java (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: Yyang-YE
PR: MapChillE/uble-be#28
File: docker-compose.yml:15-22
Timestamp: 2025-07-10T07:27:35.823Z
Learning: Yyang-YE prefers to use hardcoded passwords in docker-compose.yml files for local development environments, considering them safe since they're only used locally with arbitrary passwords.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (6)
src/main/java/com/ureca/uble/domain/users/repository/CustomUsageHistoryDocumentRepositoryImpl.java (4)

52-52: 개인 통계에 현재 월 필터 추가가 올바르게 구현됨

userId 필터와 함께 현재 월 필터를 추가하여 개인 통계 조회 시 해당 사용자의 이번 달 데이터만 집계하도록 수정되었습니다. 이는 PR 목표와 정확히 일치합니다.


74-83: 카테고리 집계에 필터링 로직 적용 완료

기존의 단순한 terms 집계에서 필터된 집계로 변경되어 userId와 현재 월 조건이 올바르게 적용됩니다. 중첩된 "rank" 서브 집계 구조도 적절합니다.


88-97: 브랜드 집계 크기 감소 검토 필요

필터링 로직은 올바르게 적용되었으나, 브랜드 집계의 size가 기존 10에서 5로 감소했습니다. 이 변경이 의도된 것인지 확인이 필요합니다.

AI 요약에 따르면 크기가 10에서 5로 줄어들었다고 하는데, 이것이 요구사항의 일부인지 확인해주세요.


481-487: 현재 월 필터 구현 검증

now/M을 사용한 날짜 범위 필터링은 Elasticsearch의 표준 구문으로 올바르게 구현되었습니다. 현재 월의 시작부터 현재 시점까지의 데이터를 정확히 필터링합니다.

src/main/java/com/ureca/uble/domain/users/service/UserService.java (2)

216-217: 카테고리 순위 집계 결과 추출 로직 올바르게 수정됨

Repository의 필터된 집계 구조 변경에 맞춰 .filter().aggregations().get("rank") 경로로 올바르게 수정되었습니다. 이는 새로운 중첩 집계 구조와 완벽히 호환됩니다.


224-225: 브랜드 순위 집계 결과 추출 로직 올바르게 수정됨

Repository의 필터된 집계 구조 변경에 맞춰 서비스 계층에서도 동일하게 수정되어 일관성이 유지됩니다.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/UBLE-185-user-statistics

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
🪧 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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
  • 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 src/utils.ts and explain its main purpose.
    • @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? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • 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.

Copy link
Collaborator

@hayong39 hayong39 left a comment

Choose a reason for hiding this comment

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

수고하셨습니다!

@Yyang-YE Yyang-YE merged commit 9a56ef0 into develop Aug 6, 2025
2 checks passed
@Yyang-YE Yyang-YE deleted the fix/UBLE-185-user-statistics branch August 7, 2025 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix 버그 수정

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants