Skip to content

feat/draft : 랜덤 드래프트 기능 추가 - #119

Merged
hwichoi0317 merged 1 commit into
devfrom
feature/draft
Aug 20, 2025
Merged

feat/draft : 랜덤 드래프트 기능 추가#119
hwichoi0317 merged 1 commit into
devfrom
feature/draft

Conversation

@hwichoi0317

@hwichoi0317 hwichoi0317 commented Aug 20, 2025

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • 신기능
    • 드래프트에서 ‘랜덤 선수 선택’이 가능해졌습니다. 현재 참가자의 포지션 보유 현황과 스쿼드 제한을 반영해 선택 가능한 선수 중 1명을 무작위로 배정합니다.
    • 선택 결과는 드래프트 참가자들에게 실시간으로 반영되어 즉시 확인할 수 있습니다. 기존 수동 선택 흐름과 함께 사용할 수 있어 드래프트 진행을 더 빠르고 유연하게 지원합니다.

@coderabbitai

coderabbitai Bot commented Aug 20, 2025

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

Walkthrough

랜덤 선수 선택 기능이 드래프트 플로우에 추가되었다. 컨트롤러에 WebSocket 엔드포인트가 추가되고, 서비스에 랜덤 선택 로직과 Redis 발행이 구현되었다. DTO에 빌더가 도입되었고, Player 엔티티에 DraftRequest 변환 유틸이 추가되었다. 레포지토리에 가용 포지션 조회와 랜덤 선수 조회 쿼리가 추가되었다.

Changes

Cohort / File(s) Summary
Draft random flow (Controller/Service)
backendProject/src/main/java/likelion/mlb/backendProject/domain/draft/controller/DraftController.java, backendProject/src/main/java/likelion/mlb/backendProject/domain/draft/service/DraftService.java
컨트롤러에 /draft/selectRandomPlayer WebSocket 핸들러 추가. 서비스에 selectRandomPlayer(...) 추가: Principal로 사용자/참가자 확인, 가용 포지션 조회, 해당 포지션에서 랜덤 선수 선택, 저장 후 Redis 채널 draft.{draftId}로 전송.
DTO construction
backendProject/src/main/java/likelion/mlb/backendProject/domain/draft/dto/DraftRequest.java
Lombok @Builder 추가로 빌더 API 제공. 기존 필드/동작 변경 없음.
Entity → DTO mapping
backendProject/src/main/java/likelion/mlb/backendProject/domain/player/entity/Player.java
PlayerDraftRequest로 변환하는 toDraftRequest(Player) 정적 메서드 추가.
Repositories: eligibility and random pick
backendProject/src/main/java/likelion/mlb/backendProject/domain/player/repository/ElementTypeRepository.java, backendProject/src/main/java/likelion/mlb/backendProject/domain/player/repository/PlayerRepository.java
가용 포지션 조회 JPQL findAvailableElementTypesByParticipant(...) 추가. 드래프트 미선택 + 포지션 필터에서 랜덤 1명 반환하는 네이티브 쿼리 findRandomAvailablePlayer(draftId, elementTypeIds) 추가.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant C as Client (WebSocket)
  participant DC as DraftController
  participant DS as DraftService
  participant ER as ElementTypeRepository
  participant PR as PlayerRepository
  participant S as SaveDraft/Persistence
  participant R as Redis (draft.{draftId})

  C->>DC: /draft/selectRandomPlayer (DraftRequest, Principal)
  DC->>DS: selectRandomPlayer(request, principal)
  DS->>ER: findAvailableElementTypesByParticipant(participantId)
  ER-->>DS: List<ElementType>
  DS->>PR: findRandomAvailablePlayer(draftId, elementTypeIds)
  PR-->>DS: Optional<Player>
  alt player found
    DS->>S: saveDraft(DraftRequest.from(Player))
    S-->>DS: saved
    DS->>R: publish serialized DraftRequest
    R-->>C: message on channel draft.{draftId}
  else none
    DS-->>DC: IllegalArgumentException
    DC-->>C: error propagated
  end
  note over DC,DS: 신규 랜덤 선택 플로우
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • Kim-Jaehyun0328
  • wjkim9
  • roode1017

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: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between d092158 and e20bb31.

📒 Files selected for processing (6)
  • backendProject/src/main/java/likelion/mlb/backendProject/domain/draft/controller/DraftController.java (1 hunks)
  • backendProject/src/main/java/likelion/mlb/backendProject/domain/draft/dto/DraftRequest.java (2 hunks)
  • backendProject/src/main/java/likelion/mlb/backendProject/domain/draft/service/DraftService.java (4 hunks)
  • backendProject/src/main/java/likelion/mlb/backendProject/domain/player/entity/Player.java (2 hunks)
  • backendProject/src/main/java/likelion/mlb/backendProject/domain/player/repository/ElementTypeRepository.java (1 hunks)
  • backendProject/src/main/java/likelion/mlb/backendProject/domain/player/repository/PlayerRepository.java (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/draft

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.
    • 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? Create a ticket on our support page 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.

@hwichoi0317
hwichoi0317 merged commit 8f06f83 into dev Aug 20, 2025
1 check was pending
@hwichoi0317
hwichoi0317 deleted the feature/draft branch August 20, 2025 16:42
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