Skip to content

feature/draft: Bot 드래프트 기능 추가 - #165

Merged
hwichoi0317 merged 2 commits into
devfrom
feature/draft
Aug 25, 2025
Merged

hwichoi0317 merged 2 commits into
devfrom
feature/draft

Conversation

@hwichoi0317

@hwichoi0317 hwichoi0317 commented Aug 25, 2025

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • 봇 자동 픽 도입: 봇 차례일 때 10초 후 자동으로 선수를 선택하여 드래프트가 끊김 없이 진행됩니다.
  • Refactor
    • 턴/라운드 계산 로직 단순화로 진행 흐름이 더 예측 가능해졌습니다.
    • 선수 및 관련 정보 로딩 최적화로 봇 선택 시 지연이 줄었습니다.
  • Chores
    • 드래프트 상태의 Redis TTL을 60분으로 설정해 오래된 상태를 자동 정리, 안정성과 리소스 효율을 개선했습니다.

@coderabbitai

coderabbitai Bot commented Aug 25, 2025

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

Walkthrough

비동기 봇 턴 처리 로직이 DraftService에 추가되고, Redis 상태 키에 TTL(60분)이 TurnService에서 적용되었습니다. PlayerRepository에는 팀/포지션(ElementType)을 즉시 로딩하는 조회 메서드가 추가되었습니다. DraftService는 스케줄러로 봇 턴을 10초 후 실행하며, 트랜잭션 보장을 위해 self 프록시를 사용합니다.

Changes

Cohort / File(s) Change Summary
봇 턴 자동화 및 트랜잭션 프록시
backendProject/src/main/java/likelion/mlb/backendProject/domain/draft/service/DraftService.java
봇 턴 예약 실행(ScheduledExecutorService) 추가, handleBotTurn(UUID, UUID) 도입(@transactional), self 프록시 주입(@lazy @Autowired)로 비동기 내부 호출 트랜잭션 보장, 드래프트/턴 진행 로직 일부 정리, Redis 퍼블리시 포함
턴 상태 TTL 적용
backendProject/src/main/java/likelion/mlb/backendProject/domain/draft/service/TurnService.java
startOrUpdateTurn 내 Redis 해시에 TTL 60분 설정(redis.expire(stateKey, 60, TimeUnit.MINUTES)) 추가
플레이어 즉시 로딩 조회 추가
backendProject/src/main/java/likelion/mlb/backendProject/domain/player/repository/PlayerRepository.java
팀/ElementType을 JOIN FETCH로 함께 로딩하는 findByIdWithTeamAndElementType(UUID) 메서드 추가

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User as 사람 참가자
  participant DraftSvc as DraftService
  participant Scheduler as ScheduledExecutorService
  participant SelfProxy as DraftService (proxy)
  participant Repo as PlayerRepository / Draft/Participant Repos
  participant TurnSvc as TurnService
  participant Redis as Redis

  rect rgba(230,240,255,0.5)
    User->>DraftSvc: 사람 턴 처리(기존 흐름)
    DraftSvc->>TurnSvc: 상태 업데이트/방송
    TurnSvc->>Redis: 해시 putAll + TTL 60분
  end

  alt 다음 참가자가 봇
    DraftSvc-->>Scheduler: 봇 턴 10초 후 스케줄
    Note over Scheduler: 지연 후 실행
    Scheduler-->>SelfProxy: handleBotTurn(draftId, botId)
    SelfProxy->>Repo: 드래프트/참가자/가용 선수 조회
    SelfProxy->>SelfProxy: 무작위 선수 선택/검증
    SelfProxy->>TurnSvc: 상태 업데이트/방송
    TurnSvc->>Redis: 해시 putAll + TTL 60분
  else 다음 참가자가 사람
    DraftSvc-->>User: 대기
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • Kim-Jaehyun0328
  • wjkim9
  • roode1017

Poem

깡총깡총, 열 번 세고 딱! 10초 뒤에 출발이야 🕒
토끼 봇이 줄을 서서 차례를 지켜봐요.
팀과 포지션 챙겨 들고, Redis에 소식 전하고,
바통은 둥글게 굴러가네—TTL로 따끈하게.
드래프트 밤하늘에, 별처럼 픽 픽 픽! ✨

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 3dadb47 and a547948.

📒 Files selected for processing (3)
  • backendProject/src/main/java/likelion/mlb/backendProject/domain/draft/service/DraftService.java (3 hunks)
  • backendProject/src/main/java/likelion/mlb/backendProject/domain/draft/service/TurnService.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 cf856db into dev Aug 25, 2025
1 check was pending
@hwichoi0317
hwichoi0317 deleted the feature/draft branch August 25, 2025 18:16
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