Skip to content

[25.06.27 / TASK-210] Feature - 리더보드 username 대응 개발 #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 30, 2025

Conversation

ooheunda
Copy link
Contributor

@ooheunda ooheunda commented Jun 27, 2025

🔥 변경 사항

리더보드 화면에서의 글/사용자 홈 바로가기를 위해 username 대응 개발을 하였습니다!
기존엔 Full URL을 응답에 내려주는 것으로 생각했었는데, 기준님과 대화 나눈 결과, URL은 일관성을 위해 FE에서 조합하는 방식으로 진행될 예정입니다~!! (유저 리더보드의 경우엔 https://velog.io/@username/posts 형식)

  • 리더보드 응답값에 username 필드 추가
    • 게시물 리더보드에선 username nullish함!!!
    • username 없는 사용자가 아주 드물음 && (username 없음 = 사용자 업데이트 안됨 = 리더보드에 올라올 일 없음) => 그냥 Required라고 생각하셔도 될 것 같긴 합니다!
  • 유저 리더보드 집계 포함 조건을 email is not null 에서 username is not null로 수정
    • 사용자 식별 목적 필드 email -> username
    • 따라서 원래 같이 내려주던 email 필드는 이제 nullish 합니다!!! (아예 삭제도 고려)
  • 관련 테스트 수정

🏷 관련 이슈

  • X

📸 스크린샷 (UI 변경 시 필수)

X

📌 체크리스트

  • 기능이 정상적으로 동작하는지 테스트 완료
  • 코드 스타일 가이드 준수 여부 확인
  • 관련 문서 업데이트 완료 (필요 시)

Summary by CodeRabbit

  • 신규 기능

    • 사용자 및 게시글 리더보드 결과에 username(사용자명) 정보가 추가되었습니다.
  • 버그 수정

    • 리더보드에서 이메일이 없는 사용자 대신 사용자명이 없는 사용자가 제외되도록 변경되었습니다.
  • 문서

    • API 응답 문서에 username 필드가 추가 및 설명되었습니다.
  • 테스트

    • 모든 관련 테스트 데이터와 검증에 username 필드가 반영되었습니다.

리더보드 응답값에 username 필드 추가
유저 리더보드 집계 조건을 email is not null 에서 username is not null로 수정
@ooheunda ooheunda self-assigned this Jun 27, 2025
@ooheunda ooheunda added the enhancement New feature or request label Jun 27, 2025
Copy link

Copy link
Contributor

coderabbitai bot commented Jun 27, 2025

"""

Walkthrough

리더보드 관련 기능에서 사용자와 게시글의 결과에 username 필드를 추가하고, 기존의 email 필드는 nullable로 변경하였습니다. 데이터 모델, 쿼리, 서비스, DTO, 그리고 관련 테스트 코드 모두가 username을 다루도록 일관성 있게 수정되었습니다.

Changes

파일/경로 그룹 변경 요약
src/repositories/leaderboard.repository.ts 사용자/게시글 리더보드 쿼리에 username 필드 추가, 쿼리 및 GROUP BY, JOIN 조건 수정
src/services/leaderboard.service.ts 매핑 로직에서 username 필드 처리, 관련 인터페이스 필드명 및 타입 변경
src/types/dto/responses/leaderboardResponse.type.ts DTO에 username 필드 추가, email을 nullable로 변경, Swagger 문서 갱신
src/repositories/test/integration/leaderboard.repo.integration.test.ts
src/repositories/test/leaderboard.repo.test.ts
src/services/test/leaderboard.service.test.ts
테스트 데이터 및 검증에 username 필드 추가, email 관련 검증을 username으로 변경 및 보강

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant LeaderboardService
    participant LeaderboardRepository
    participant Database

    Client->>LeaderboardService: getUserLeaderboard()
    LeaderboardService->>LeaderboardRepository: fetchUserLeaderboard()
    LeaderboardRepository->>Database: SELECT ... username ... WHERE username IS NOT NULL ...
    Database-->>LeaderboardRepository: User leaderboard rows (with username)
    LeaderboardRepository-->>LeaderboardService: Raw results (with username)
    LeaderboardService-->>Client: LeaderboardUser[] (username 포함)

    Client->>LeaderboardService: getPostLeaderboard()
    LeaderboardService->>LeaderboardRepository: fetchPostLeaderboard()
    LeaderboardRepository->>Database: SELECT ... username ... JOIN users_user ...
    Database-->>LeaderboardRepository: Post leaderboard rows (with username)
    LeaderboardRepository-->>LeaderboardService: Raw results (with username)
    LeaderboardService-->>Client: LeaderboardPost[] (username 포함)
Loading

Possibly related PRs

  • #27: 리더보드 도메인 전체 최초 구현, 이번 PR의 기반이 되는 코드 포함

Suggested reviewers

  • six-standard
  • Jihyun3478

Poem

🐰
유저 이름, 게시글마다
username 필드가 반짝인다!
이메일은 nullable,
데이터는 더 풍성해졌네.
리더보드에 토끼 춤을,
코드 속에 봄바람이 분다.
🎉
"""


📜 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 206ac7d and 1c6fd93.

📒 Files selected for processing (1)
  • src/repositories/__test__/integration/leaderboard.repo.integration.test.ts (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/repositories/test/integration/leaderboard.repo.integration.test.ts
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: build-and-test (20)
  • GitHub Check: build-and-test (23)
  • GitHub Check: build-and-test (21)
  • GitHub Check: build-and-test (22)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branch feature/leaderboard-username

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.
    • @coderabbitai modularize this function.
  • 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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

@ooheunda
Copy link
Contributor Author

테스트 failed(타임아웃)는 성능 관련이라 다른 브랜치에서 쿼리 최적화 작업 진행하겠습니다 🥲

Copy link
Member

@Nuung Nuung left a comment

Choose a reason for hiding this comment

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

캬 크게 이견없습니다! 유지보수가 쉽게 짜여져서 있어서 그런지, type 과 field 수정 정도로 잘 마무리가 될 것 같아요 :) @six-standard 기준님의 대응 개발만 잘 마무리 되면 깔금할 것 같네여!!

@@ -154,7 +157,7 @@ describe('LeaderboardRepository', () => {

expect(mockPool.query).toHaveBeenCalledWith(
expect.stringContaining('WHERE date >='), // pastDateKST를 사용하는 부분 확인
[expect.any(Number)] // limit
[expect.any(Number)], // limit
Copy link
Member

@six-standard six-standard Jun 30, 2025

Choose a reason for hiding this comment

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

이 부분과 위의 동일한 코드는 단순 린팅 적용이나 변경일까요?
콤마 하나만 수정되어있는데, 왜 추가된건지 궁금합니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

넵 단순 린팅 적용이 맞습니다! 😅

Copy link
Member

@six-standard six-standard left a comment

Choose a reason for hiding this comment

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

코드 잘 읽었습니다!
큰 수정이 아닌지라 저도 현우님과 큰 이견 없고, 위에 남겨둔 코멘트 정도만 답장해주시면 될 것 같네요~
빠르게 대응개발해서 PR 올려두겠습니다!

Copy link
Contributor

@Jihyun3478 Jihyun3478 left a comment

Choose a reason for hiding this comment

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

코드 잘 읽었습니다! 고생하셨습니다~!!
다른 부분은 크게 이견 없는 것 같네요!!:)

@ooheunda ooheunda merged commit bf4afa2 into main Jun 30, 2025
8 of 9 checks passed
@ooheunda ooheunda deleted the feature/leaderboard-username branch June 30, 2025 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants