Skip to content

Conversation

@thezz9
Copy link
Collaborator

@thezz9 thezz9 commented Jul 1, 2025

Summary by CodeRabbit

  • 신규 기능

    • 코드 제출 및 테스트 관련 이벤트에 사용자 식별자(principalName)가 추가되어, 메시지가 개별 사용자에게 전달됩니다.
  • 버그 수정

    • WebSocket 구독 경로가 /topic/submission/{sessionKey}에서 /user/queue/submission/{sessionKey}로 변경되어, 제출 결과 및 상태 메시지가 본인에게만 전달됩니다.
  • 문서화

    • API 및 템플릿 내 WebSocket 경로 안내가 최신 사용자별 큐 경로로 수정되었습니다.
  • 테스트

    • 변경된 이벤트 생성 방식에 맞춰 테스트 코드가 업데이트되었습니다.

@thezz9 thezz9 added the bug Something isn't working label Jul 1, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jul 1, 2025

Walkthrough

이 변경은 제출 관련 이벤트 객체에 사용자 식별자(principalName)를 추가하고, 이벤트 생성 시 단순 세션 키 대신 SubmissionContext 객체를 전달하도록 수정합니다. 또한 WebSocket 메시지 전송 경로를 브로드캐스트 토픽에서 사용자별 큐로 변경하며, 관련 서비스, 리스너, 테스트 코드, 문서, 템플릿 등을 이에 맞게 일관성 있게 업데이트합니다.

Changes

파일/경로 요약 변경 요약
.../dto/event/GitPushStatusEvent.java
.../dto/event/SubmissionJudgingFinishedEvent.java
.../dto/event/TestcaseEvaluatedEvent.java
.../dto/event/TestcaseListInitializedEvent.java
이벤트 record에 principalName 필드 추가, static factory method가 sessionKey 대신 SubmissionContext를 받도록 변경
.../dto/event/SubmissionErrorEvent.java resolveCode 메서드의 공백 수정, 로직 변화 없음
.../model/SubmissionContext.java getUserEmail() 메서드 추가
.../service/GitHubPushService.java GitPushStatusEvent 생성 시 sessionKey 대신 SubmissionContext 전달
.../service/JudgementService.java 이벤트 객체 생성 시 생성자 대신 static factory method 사용
.../service/SubmissionService.java createSubmissionContext 메서드 위치 이동, 일부 import 추가(사용 안 됨)
.../infrastructure/event/config/WebSocketConfig.java 메시지 브로커 application destination prefix에 "/app" 추가
.../infrastructure/event/listener/SubmissionEventListener.java messageService 호출 시 principalName 추가 전달
.../infrastructure/event/publisher/StompMessageService.java 메시지 전송 경로를 /queue/submission/%s로 변경, convertAndSendToUser 사용, principalName 인자 추가
.../presentation/submission/SubmissionController.java WebSocket 구독 경로 설명을 /user/queue/submission/{sessionKey}/로 변경
.../resources/templates/submit-test.html WebSocket 구독 base path를 /user/queue/submission/${sessionKey}로 변경
.../GitHubPushServiceTest.java 테스트에서 sessionKey 대신 ctx(SubmissionContext)로 이벤트 생성 검증

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Controller
    participant JudgementService
    participant EventPublisher
    participant StompMessageService

    Client->>Controller: 코드 제출(WebSocket)
    Controller->>JudgementService: 제출 처리
    JudgementService->>EventPublisher: TestcaseListInitializedEvent.of(ctx, payload)
    EventPublisher->>StompMessageService: sendInitTestcases(sessionKey, principalName, payload)
    StompMessageService->>Client: /user/queue/submission/{sessionKey}/init 메시지 전송
Loading

Suggested labels

Test

Suggested reviewers

  • NCookies
  • minjee2758
  • Kimminu7
  • pokerbearkr
  • chat26666

Poem

🐇
사용자별 큐로 hop hop hop,
principalName도 챙겨서 점프!
이벤트는 더 똑똑해졌고,
메시지는 내게만 콕!
토픽에서 큐로,
토끼는 즐겁게 춤추네—
코드의 들판에 봄바람 솔솔!


📜 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 ec617a9 and b3ecddf.

📒 Files selected for processing (15)
  • src/main/java/org/ezcode/codetest/application/submission/dto/event/GitPushStatusEvent.java (1 hunks)
  • src/main/java/org/ezcode/codetest/application/submission/dto/event/SubmissionErrorEvent.java (1 hunks)
  • src/main/java/org/ezcode/codetest/application/submission/dto/event/SubmissionJudgingFinishedEvent.java (1 hunks)
  • src/main/java/org/ezcode/codetest/application/submission/dto/event/TestcaseEvaluatedEvent.java (1 hunks)
  • src/main/java/org/ezcode/codetest/application/submission/dto/event/TestcaseListInitializedEvent.java (1 hunks)
  • src/main/java/org/ezcode/codetest/application/submission/model/SubmissionContext.java (1 hunks)
  • src/main/java/org/ezcode/codetest/application/submission/service/GitHubPushService.java (1 hunks)
  • src/main/java/org/ezcode/codetest/application/submission/service/JudgementService.java (2 hunks)
  • src/main/java/org/ezcode/codetest/application/submission/service/SubmissionService.java (4 hunks)
  • src/main/java/org/ezcode/codetest/infrastructure/event/config/WebSocketConfig.java (1 hunks)
  • src/main/java/org/ezcode/codetest/infrastructure/event/listener/SubmissionEventListener.java (2 hunks)
  • src/main/java/org/ezcode/codetest/infrastructure/event/publisher/StompMessageService.java (3 hunks)
  • src/main/java/org/ezcode/codetest/presentation/submission/SubmissionController.java (1 hunks)
  • src/main/resources/templates/submit-test.html (1 hunks)
  • src/test/java/org/ezcode/codetest/application/submission/GitHubPushServiceTest.java (2 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: thezz9
PR: ezcode-my/backend#30
File: src/main/java/org/ezcode/codetest/domain/problem/model/dto/SubmissionData.java:42-53
Timestamp: 2025-06-04T13:12:16.729Z
Learning: 사용자 thezz9는 개발 시 기능적 정확성을 먼저 달성한 후 세부 리팩터링을 나중에 하는 접근 방식을 선호한다. 테스트 단계에서는 하드코딩된 값도 허용한다.
Learnt from: thezz9
PR: ezcode-my/backend#114
File: src/main/java/org/ezcode/codetest/infrastructure/github/GitHubApiClient.java:159-165
Timestamp: 2025-06-28T02:03:38.654Z
Learning: User thezz9's service (ezcode) targets Korean users exclusively ("찐 한국인밖에 안 옴"), so Korean language hardcoding in commit messages and UI elements is intentional and appropriate for their use case.
Learnt from: thezz9
PR: ezcode-my/backend#30
File: src/main/java/org/ezcode/codetest/application/submission/service/SubmissionService.java:44-46
Timestamp: 2025-06-04T13:12:17.636Z
Learning: SubmissionService에서 "2 10" 입력값과 "12" 기대출력이 하드코딩되어 있는 것은 테스트 단계의 의도적인 구현이며, 추후 Problem 엔티티의 실제 테스트케이스로 대체 예정입니다.
Learnt from: thezz9
PR: ezcode-my/backend#36
File: src/main/java/org/ezcode/codetest/domain/problem/model/entity/ProblemLanguage.java:3-3
Timestamp: 2025-06-06T07:57:51.226Z
Learning: 사용자 thezz9는 Language 엔티티를 Submission 도메인으로 이동시킨 이유가 "제출하려면 필요해서"라고 설명했으며, Problem 도메인과 Submission 도메인 간의 종속성 위반 문제에 대한 해결 방안을 고민하고 있다.
Learnt from: thezz9
PR: ezcode-my/backend#98
File: src/main/java/org/ezcode/codetest/application/submission/dto/event/SubmissionErrorEvent.java:17-22
Timestamp: 2025-06-25T01:24:30.754Z
Learning: JudgeClient에서 모든 예외를 SubmissionException으로 래핑해서 넘길 계획이므로, SubmissionErrorEvent.resolveCode() 메서드의 캐스팅은 안전할 예정임.
Learnt from: thezz9
PR: ezcode-my/backend#75
File: src/main/java/org/ezcode/codetest/application/submission/aop/CodeReviewLockAspect.java:25-41
Timestamp: 2025-06-19T06:37:57.845Z
Learning: User thezz9 tends to skip validation for scenarios they consider unlikely to occur, but is willing to implement defensive programming practices when suggested for code robustness.
Learnt from: thezz9
PR: ezcode-my/backend#114
File: src/main/java/org/ezcode/codetest/infrastructure/github/GitHubApiClient.java:93-96
Timestamp: 2025-06-28T02:04:24.910Z
Learning: User thezz9 sometimes temporarily uses less secure or inconsistent exception handling (like RuntimeException with raw error bodies) for debugging purposes when error messages are being hidden in the normal application flow, but acknowledges this as technical debt and fixes it once debugging is complete.
src/main/java/org/ezcode/codetest/application/submission/dto/event/SubmissionErrorEvent.java (1)
Learnt from: thezz9
PR: ezcode-my/backend#98
File: src/main/java/org/ezcode/codetest/application/submission/dto/event/SubmissionErrorEvent.java:17-22
Timestamp: 2025-06-25T01:24:30.754Z
Learning: JudgeClient에서 모든 예외를 SubmissionException으로 래핑해서 넘길 계획이므로, SubmissionErrorEvent.resolveCode() 메서드의 캐스팅은 안전할 예정임.
src/main/resources/templates/submit-test.html (1)
Learnt from: thezz9
PR: ezcode-my/backend#73
File: src/main/resources/templates/submit-test.html:135-135
Timestamp: 2025-06-18T11:41:58.457Z
Learning: src/main/resources/templates/submit-test.html 파일은 테스트용 파일로, isCorrect 값의 하드코딩은 의도적이며 사용자가 UI 요소를 통해 정답/오답 상태를 선택할 수 있도록 개선 예정입니다.
src/main/java/org/ezcode/codetest/application/submission/service/SubmissionService.java (3)
Learnt from: thezz9
PR: ezcode-my/backend#36
File: src/main/java/org/ezcode/codetest/domain/submission/dto/SubmissionData.java:47-58
Timestamp: 2025-06-06T07:59:41.806Z
Learning: SubmissionData.withAggregatedStats() 메서드에서 testCaseList는 상위 프로세스(base() 메서드의 problemInfo.testcaseList())에서 이미 null 체크가 처리되어 오므로 추가적인 null 체크가 불필요함
Learnt from: chat26666
PR: ezcode-my/backend#67
File: src/main/java/org/ezcode/codetest/domain/game/service/CharacterEquipService.java:26-34
Timestamp: 2025-06-16T16:07:34.354Z
Learning: 이 프로젝트에서는 UseCase 레벨에서 트랜잭션 경계를 관리하므로, 도메인 서비스 클래스들(예: CharacterEquipService)에는 @Transactional 어노테이션이 필요하지 않습니다. 트랜잭션은 UseCase에서 열리므로 데이터 일관성이 보장됩니다.
Learnt from: chat26666
PR: ezcode-my/backend#67
File: src/main/java/org/ezcode/codetest/application/game/play/GamePlayUseCase.java:117-124
Timestamp: 2025-06-16T17:19:46.167Z
Learning: In GamePlayUseCase.java, the user temporarily returns BattleLog domain object directly for testing/verification purposes with plans to convert to DTO later during development.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (30)
src/main/java/org/ezcode/codetest/application/submission/model/SubmissionContext.java (1)

160-163: 사용자 이메일 접근 메소드 추가가 적절합니다.

WebSocket 메시징의 사용자별 타겟팅을 위한 getUserEmail() 메소드 추가가 적절하게 구현되었습니다. 메소드가 간단명료하고 기존 코드 스타일과 일관성을 유지합니다.

src/main/java/org/ezcode/codetest/application/submission/dto/event/SubmissionErrorEvent.java (1)

17-19: 코드 포맷팅 개선이 적절합니다.

불필요한 공백 제거와 캐스트 표현식 주변 공백 정리로 코드 가독성이 향상되었습니다.

src/main/resources/templates/submit-test.html (1)

258-261: WebSocket 구독 경로를 사용자별 큐로 변경한 것이 적절합니다.

브로드캐스트 토픽에서 사용자별 큐로 변경하여 메시징 보안성이 향상되었습니다. 백엔드의 WebSocket 설정 변경과 일치하며, 다른 사용자의 제출 결과가 노출되지 않도록 개선되었습니다.

src/main/java/org/ezcode/codetest/infrastructure/event/config/WebSocketConfig.java (1)

56-56: Application destination prefix 추가가 적절합니다.

"/app" prefix 추가로 새로운 사용자별 큐 메시징 패턴을 지원할 수 있게 되었습니다. 기존 "/chat" 기능에는 영향을 주지 않으면서 기능을 확장했습니다.

src/main/java/org/ezcode/codetest/presentation/submission/SubmissionController.java (1)

50-58: API 문서의 WebSocket 구독 경로 업데이트가 적절합니다.

WebSocket 구독 경로를 실제 구현에 맞게 /user/queue/submission/{sessionKey}/로 업데이트한 것이 적절합니다. error 채널만 여전히 /topic을 사용하는 것도 에러 메시지의 특성상 합리적인 설계입니다.

src/test/java/org/ezcode/codetest/application/submission/GitHubPushServiceTest.java (2)

129-131: 테스트 코드가 새로운 이벤트 생성 패턴을 올바르게 검증합니다.

GitPushStatusEvent의 팩토리 메서드가 이제 sessionKey 대신 SubmissionContext 전체를 받도록 변경된 것에 맞춰 테스트가 정확히 업데이트되었습니다.


163-165: 실패 케이스 테스트도 일관성 있게 업데이트되었습니다.

성공 케이스와 동일하게 SubmissionContext 객체를 사용하여 이벤트를 생성하는지 검증하고 있어 일관성이 유지됩니다.

src/main/java/org/ezcode/codetest/application/submission/service/GitHubPushService.java (3)

31-31: 이벤트 발행 시 SubmissionContext 전체를 전달하도록 올바르게 수정되었습니다.

GitPushStatusEvent.started()가 이제 sessionKey 대신 ctx 전체를 받아 principalName도 추출할 수 있게 되었습니다.


37-37: 성공 이벤트 발행도 일관성 있게 업데이트되었습니다.

동일한 패턴으로 SubmissionContext를 전달하여 사용자별 메시지 큐잉을 지원합니다.


40-40: 실패 이벤트 발행도 올바르게 수정되었습니다.

모든 이벤트 발행이 일관된 방식으로 SubmissionContext를 사용하고 있습니다.

src/main/java/org/ezcode/codetest/application/submission/service/JudgementService.java (3)

45-45: TestcaseListInitializedEvent 생성이 새로운 팩토리 메서드 패턴으로 올바르게 변경되었습니다.

이제 SubmissionContext에서 sessionKey와 principalName을 모두 추출할 수 있게 되었습니다.


93-95: TestcaseEvaluatedEvent 생성도 일관된 팩토리 메서드 패턴을 사용합니다.

ctx와 payload를 전달하여 이벤트를 생성하는 방식이 다른 이벤트들과 일관성을 유지합니다.


99-99: SubmissionJudgingFinishedEvent 생성도 올바르게 업데이트되었습니다.

from() 메서드를 사용하여 SubmissionContext에서 모든 필요한 정보를 추출하도록 변경되었습니다.

src/main/java/org/ezcode/codetest/application/submission/dto/event/SubmissionJudgingFinishedEvent.java (2)

10-10: principalName 필드가 올바르게 추가되었습니다.

사용자별 메시지 큐잉을 위한 사용자 식별자가 이벤트에 포함되었습니다.


15-21: from() 팩토리 메서드가 잘 구현되었습니다.

SubmissionContext에서 sessionKey, userEmail(principalName), 그리고 최종 결과 페이로드를 올바르게 추출하여 이벤트를 생성합니다. 다른 이벤트 DTO들과 일관된 패턴을 따르고 있습니다.

src/main/java/org/ezcode/codetest/infrastructure/event/listener/SubmissionEventListener.java (4)

32-32: 테스트케이스 초기화 이벤트에 principalName이 올바르게 전달됩니다.

사용자별 큐로 메시지를 보내기 위해 event.principalName()이 추가로 전달되고 있습니다.


38-38: 테스트케이스 업데이트 이벤트도 일관되게 principalName을 전달합니다.

모든 이벤트 핸들러가 동일한 패턴으로 사용자 식별자를 메시지 서비스에 전달하고 있습니다.


44-44: 최종 결과 이벤트 처리도 올바르게 업데이트되었습니다.

TransactionalEventListener에서도 principalName을 포함하여 사용자별 메시지 전송을 지원합니다.


56-56: Git 푸시 상태 이벤트도 일관된 방식으로 처리됩니다.

모든 주요 이벤트 타입에서 principalName을 활용한 사용자별 메시지 전송이 구현되었습니다.

src/main/java/org/ezcode/codetest/application/submission/service/SubmissionService.java (1)

118-124: 메소드 재배치가 적절합니다.

createSubmissionContext 메소드를 클래스 하단으로 이동한 것은 코드 구조를 개선하는 좋은 변경입니다. 기능적 변경 없이 가독성을 향상시켰습니다.

src/main/java/org/ezcode/codetest/application/submission/dto/event/TestcaseEvaluatedEvent.java (2)

10-10: 사용자 식별자 추가가 적절합니다.

principalName 필드 추가로 사용자별 이벤트 처리가 가능해졌습니다.


15-21: SubmissionContext 사용으로 개선되었습니다.

팩토리 메소드가 SubmissionContext를 받아 세션 키와 사용자 이메일을 추출하는 방식으로 변경되어 더 명확하고 일관성 있는 구조가 되었습니다.

src/main/java/org/ezcode/codetest/application/submission/dto/event/TestcaseListInitializedEvent.java (2)

12-12: 사용자 식별을 위한 필드 추가가 적절합니다.

다른 이벤트 클래스들과 일관성을 맞춘 좋은 변경입니다.


17-19: 팩토리 메소드 개선이 우수합니다.

메소드명을 from에서 of로 변경하고 SubmissionContext를 사용하도록 개선하여 다른 이벤트 클래스들과 일관성을 확보했습니다.

src/main/java/org/ezcode/codetest/application/submission/dto/event/GitPushStatusEvent.java (2)

10-10: 사용자 식별자 추가로 개인화된 메시징이 가능해졌습니다.

Git 푸시 상태 이벤트에 principalName 필드가 추가되어 사용자별 알림이 가능해졌습니다.


15-25: 모든 팩토리 메소드가 일관성 있게 개선되었습니다.

started, succeeded, failed 메소드 모두 SubmissionContext를 받도록 통일되어 코드 일관성이 향상되었습니다.

src/main/java/org/ezcode/codetest/infrastructure/event/publisher/StompMessageService.java (4)

29-29: 메시징 방식을 사용자별 큐로 변경한 것이 적절합니다.

브로드캐스트 토픽에서 사용자별 큐로 변경하여 개인화된 메시징이 가능해졌습니다.


63-97: 사용자별 메시징 구현이 우수합니다.

sendInitTestcases, sendTestcaseResultUpdate, sendFinalResult 메소드들이 모두 principalName 파라미터를 받아 convertAndSendToUser를 사용하도록 개선되었습니다.


109-119: Git 상태 메시징도 사용자별로 개선되었습니다.

sendGitStatus 메소드도 사용자별 전송 방식으로 일관성 있게 변경되었습니다.


99-107: sendError는 이미 세션별 큐로 전송됩니다

SUBMISSION_DEST_PREFIX"/queue/submission/%s"를 사용하여 세션 키마다 개별 큐로 전송하므로, 에러 메시지도 브로드캐스트가 아닌 사용자별(point-to-point) 전송이 맞습니다.
별도 수정 없이 현재 설계대로 유지해도 됩니다.

Likely an incorrect or invalid review comment.

✨ Finishing Touches
  • 📝 Generate Docstrings

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

@thezz9 thezz9 merged commit 4587dc5 into dev Jul 1, 2025
2 checks passed
@thezz9 thezz9 deleted the hotfix/submission-ws branch July 1, 2025 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants