Repository navigation
Conversation
Contributor
|
지금 PR은 recalculate_challenge_score() 함수만 추가되어 있고 실제 flag 제출 경로에는 연결되어 있지 않습니다 현재 상태로 이 PR만 머지해도 사용자가 문제를 풀었을 때 current_score가 갱신되지는 않습니다 PR #29에서 이미 정답 제출 트랜잭션 연결과 팀 점수 갱신까지 구현하고 있어서, 별도 함수로 중복 구현하기보다는 PR #29 쪽 하나의 service로 통합하는 게 좋을 것 같습니다 추가로 아래 케이스까지 테스트가 있으면 좋겠습니다 실제 submit API 호출 시 점수가 갱신되는지 함수 자체 테스트는 통과하지만 현재 사용자 흐름에는 연결되지 않은 상태라서 이대로는 머지하기 어렵습니다 |
Collaborator
Author
|
PR #29에 update_dynamic_score_and_team_scores()가 있고 calculate_dynamic_score()를 호출해 팀 점수까지 갱신하고 있어서, 이 PR은 중복이라 닫을게요 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
recalculate_challenge_score(challenge_id) 추가
정답 제출 후 Challenge.current_score를 다시 계산하는 함수입니다. 리뷰에서 별도 이슈로 분리된 "점수 갱신 경로 미연결" 건을 위한 것입니다. 현재는 문제를 맞혀도 점수가 1000에서 바뀌지 않아 다이나믹 스코어링이 실제로 동작하지 않습니다.
동작
select_for_update()로 Challenge 행을 잠급니다
그 문제를 푼 고유 팀 수를 셉니다
calculate_dynamic_score()로 새 점수를 구합니다
current_score에 저장합니다
호출 위치
challenge 앱(규민)의 정답 처리 트랜잭션 안에서 solve 생성 직후에 호출해야 합니다.
from apps.ranking.scoring import recalculate_challenge_score
with transaction.atomic():
solve = Solve.objects.create(...)
recalculate_challenge_score(challenge_id)
트랜잭션 밖에서는 select_for_update()가 동작하지 않고, 정답 처리가 롤백되면 점수 재계산도 함께 되돌아가야 하기 때문. 호출 연결은 규민이가.
테스트
decay=2, minimum=600 기준으로 확인합니다.
solve가 없으면 초기 점수 1000 유지
첫 solve 후 900, 둘째 solve 후 600
current_score에 실제로 저장되는지
decay를 넘어서도 최저점 아래로 내려가지 않는지
랭킹 앱 테스트 37개, 전체 테스트 통과합니다.