-
Notifications
You must be signed in to change notification settings - Fork 3
[feat] 방 게임 시작 구현 #51
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
Conversation
backend/src/main/java/io/f1/backend/domain/game/app/RoomService.java
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| public GameStartData gameStart(Long roomId, Long quizId) { | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분은 gameService로 분리하면 좋을 것 같습니다! 🧚♀️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 확인했습니다 ! 🪄
|
|
||
| Long roomQuizId = gameSetting.getQuizId(); | ||
|
|
||
| if (!roomQuizId.equals(quizId)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[L5-참고의견]
if(!gameSetting.getQuizId().eqauls(quizId)) 형태의 조건문을 GameSetting 내부에 위치시키는 것이 좋을 것 같습니다 !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
확인했습니다 ! 수정했습니다 !
sehee123
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
빠르십니다.. 💨 수고하셨습니다!
LimKangHyun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다!
jiwon1217
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
확인했습니다 ! 고생하셨습니다아
🛰️ Issue Number
🪐 작업 내용
1. 게임 시작 흐름
GameStartRequest에 quizId를 담아온다.2. 문제 랜덤 추출
(1)
order by rand()(2)
Collections.shuffle()랜덤 추출을 위해 DB에서 전체 조회한 후
Collections.shuffle()을 사용할 수도 있습니다.이 방법은 우선은 전체 결과를 조회해오는 방법입니다.
최대 80개의 크기라고 했을 때 이 방법도 큰 무리가 없습니다.
서비스 단에서 섞고, 원하는 라운드만큼 subList를 만들어줘야 하는 코드가 필요합니다.
비교해봤을 때, 둘 다 문제 수가 적어 성능상 문제가 없고, 그렇게 했을 때 한 줄로 깔끔하게 의도를 보여줄 수 있는 방법이 낫다고 생각하여
order by rand()를 선택했습니다.(3) 이후 문제 개수가 늘어난다면..?
randId를 추가하여, 해당 컬럼에 인덱스를 붙여 사용할 수 있는 방법이 있다고 합니다.📚 Reference
✅ Check List