Skip to content

feat: 7일간 가족 걸음 수 랭킹 API 구현#149

Merged
Neibce merged 1 commit intomainfrom
be/feat/7days-avg-steps-rank
Aug 18, 2025
Merged

feat: 7일간 가족 걸음 수 랭킹 API 구현#149
Neibce merged 1 commit intomainfrom
be/feat/7days-avg-steps-rank

Conversation

@Neibce
Copy link
Owner

@Neibce Neibce commented Aug 18, 2025

Summary by CodeRabbit

  • 신규 기능
    • 가족 걸음 수 랭킹 조회를 추가했습니다. 금주(월요일부터 오늘까지) 누적 걸음 수를 가족 구성원 수로 나눈 평균 기준으로 순위를 제공합니다.
    • 사용자가 속한 가족을 목록에서 구분 표시합니다.
    • 결과는 평균 걸음 수 기준 내림차순으로 정렬되어 반환됩니다.
    • 기존의 가족별 걸음 수 조회 기능은 변경 없이 그대로 사용할 수 있습니다.

@coderabbitai
Copy link

coderabbitai bot commented Aug 18, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

주간 기준일(LocalDate.now())로 가족별 평균 걸음 수 순위를 반환하는 신규 REST 엔드포인트(GET /steps/rank)를 추가했다. 이를 위해 랭킹 DTO를 신설하고, 기존 빈 DTO를 제거했으며, 리포지토리에 가족 단위 집계용 프로젝션/쿼리를 도입하고, 서비스에 랭킹 산출 로직과 정렬을 구현했다.

Changes

Cohort / File(s) Summary of changes
Controller: Rank endpoint
backend/ongi/src/main/java/ongi/step/controller/StepController.java
GET /steps/rank 엔드포인트 추가. 현재 사용자와 현재 날짜를 사용해 서비스 getFamilyStepRank 호출 후 응답 반환. 필요한 DTO/컬렉션 import 추가.
DTOs: Rank response 추가/정리
backend/ongi/src/main/java/ongi/step/dto/FamilyStepRankResponse.java, backend/ongi/src/main/java/ongi/step/dto/FamilyStepRankingResponse.java
FamilyStepRankResponse(record) 신규 추가(가족명, 평균걸음, 자가족 여부). 기존 빈 클래스 FamilyStepRankingResponse 삭제.
Repository: 집계 프로젝션 도입
backend/ongi/src/main/java/ongi/step/repository/StepRepository.java
가족별 기간 집계 쿼리 findStepsAndSizeBetween(start,end) 추가와 프로젝션 FamilyStepsAndSizeView 정의. 기존 가족/기간별 상세 조회 및 합계 관련 메서드 3종 제거.
Service: 랭킹 로직 구현
backend/ongi/src/main/java/ongi/step/service/StepService.java
getFamilyStepRank(User, LocalDate) 추가: 주간 시작일부터 지정일까지 가족별 총합과 인원수를 조회해 1인당 평균 계산, 자가족 플래그 설정, 평균 내림차순 정렬. 기존 Ranking 메서드 대체. getFamilySteps@transactional 추가(동작 변경 없음).

Sequence Diagram(s)

sequenceDiagram
  participant C as Client
  participant Ctrl as StepController
  participant Svc as StepService
  participant Repo as StepRepository
  participant DB as Database

  C->>Ctrl: GET /steps/rank (authenticated)
  Ctrl->>Svc: getFamilyStepRank(user, today)
  Svc->>Repo: findStepsAndSizeBetween(weekStart, today)
  Repo->>DB: JPQL aggregation (family, steps, memberCount)
  DB-->>Repo: Aggregated rows
  Repo-->>Svc: FamilyStepsAndSizeView list
  Svc-->>Ctrl: List<FamilyStepRankResponse> (sorted by average desc)
  Ctrl-->>C: 200 OK (JSON)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

토끼 발끝, 또각또각 트랙 위 춤사위 —
가족별 발자국 모아 별처럼 줄 세우네.
주의 첫 아침부터 오늘까지 착착,
평균의 달빛 따라 순위가 반짝!
점프! 제 가족 깃발 아래 더 높이 🐇✨

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 38210b7 and d8c51d3.

📒 Files selected for processing (5)
  • backend/ongi/src/main/java/ongi/step/controller/StepController.java (2 hunks)
  • backend/ongi/src/main/java/ongi/step/dto/FamilyStepRankResponse.java (1 hunks)
  • backend/ongi/src/main/java/ongi/step/dto/FamilyStepRankingResponse.java (0 hunks)
  • backend/ongi/src/main/java/ongi/step/repository/StepRepository.java (1 hunks)
  • backend/ongi/src/main/java/ongi/step/service/StepService.java (3 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.

@Neibce Neibce merged commit 53ef2b2 into main Aug 18, 2025
3 of 4 checks passed
@Neibce Neibce deleted the be/feat/7days-avg-steps-rank branch August 21, 2025 08:57
Neibce added a commit to 2025-PNU-SW-Hackathon/PNUSW-2025-OnGi-10 that referenced this pull request Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant