Skip to content

Conversation

@thezz9
Copy link
Collaborator

@thezz9 thezz9 commented Jul 7, 2025

Summary by CodeRabbit

  • 신규 기능

    • 코드 제출 후 "리뷰 요청 (AI)" 버튼을 통해 AI 코드 리뷰를 받을 수 있는 기능이 추가되었습니다.
    • AI 리뷰 결과가 별도의 박스에 마크다운 형식으로 표시됩니다.
  • 버그 수정

    • 코드 제출 시 불필요한 6초 대기 시간이 제거되어 응답 속도가 개선되었습니다.
  • 개선 사항

    • AI 리뷰의 출력 형식 및 검증 로직이 더욱 엄격하게 개선되어 올바른 형식과 내용이 보장됩니다.
    • AI 모델이 최신 버전(gpt-4o)으로 업그레이드되었습니다.
    • 시스템 메시지와 안내 문구가 보다 명확하게 개선되었습니다.
    • Redis 스트림 소비자 이름이 호스트명 기반 또는 고유 식별자로 동적 생성되어 운영 안정성이 향상되었습니다.

@thezz9 thezz9 self-assigned this Jul 7, 2025
@thezz9 thezz9 added the enhancement New feature or request label Jul 7, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jul 7, 2025

"""

Walkthrough

Redis 스트림 컨슈머의 이름이 호스트명 기반으로 변경되고, 관련 메서드가 UnknownHostException을 던지도록 수정되었습니다. Redis 메시지 소비자에서 6초 대기 코드가 제거되었습니다. OpenAI 프롬프트 및 응답 검증 로직이 포맷과 키워드에 따라 세분화되었습니다. 코드 제출 HTML에 AI 리뷰 요청 기능이 추가되었습니다.

Changes

파일/경로 요약 변경 내용 요약
.../event/config/RedisStreamConfig.java 스트림 컨슈머 이름을 호스트명 기반으로 동적 생성. 메서드가 UnknownHostException을 던지도록 변경. 관련 import 추가.
.../event/listener/RedisJudgeQueueConsumer.java 메시지 처리 시 6초 대기(Thread.sleep) 코드 제거. 나머지 로직은 동일.
.../openai/OpenAIMessageBuilder.java OpenAI 모델명을 "gpt-4o"로 변경. 프롬프트 포맷 및 지침 세분화, 시간 복잡도/총평/개선방안 등 섹션 포맷 및 조건 강화.
.../openai/OpenAIResponseValidator.java 응답 포맷 검증 로직 강화: 정답/오답 여부에 따라 bold 마크다운 키워드 필수, 시간 복잡도 키워드 금지 조건 추가.
.../templates/test-submit.html "리뷰 요청 (AI)" 버튼 및 리뷰 박스 추가. 코드 제출 결과에 따라 리뷰 버튼 활성화. AI 리뷰 요청 및 표시 기능, 관련 CSS/JS 추가.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Browser
    participant Server
    participant OpenAI

    User->>Browser: 코드 제출
    Browser->>Server: 코드 제출 요청
    Server-->>Browser: 채점 결과 반환
    Browser->>User: 결과 표시, 리뷰 버튼 활성화

    User->>Browser: "리뷰 요청 (AI)" 클릭
    Browser->>Server: 리뷰 요청 (문제ID, 언어, 코드, 정오답 여부)
    Server->>OpenAI: 프롬프트 생성 및 요청
    OpenAI-->>Server: AI 리뷰 응답
    Server-->>Browser: AI 리뷰 반환
    Browser->>User: 리뷰 박스에 결과 표시
Loading

Possibly related PRs

Suggested labels

documentation

Suggested reviewers

  • NCookies
  • minjee2758
  • pokerbearkr
  • Kimminu7
  • chat26666

Poem

🐰
코드 제출에 AI 리뷰가 추가됐네,
버튼을 누르면 토끼가 춤을 추네.
호스트명으로 컨슈머 이름도 바뀌고,
기다림 없이 빠르게 메시지도 받고!
프롬프트도 똑똑해져서,
리뷰 포맷 딱딱 맞춰주네.
오늘도 개발자와 토끼는 함께 달리네!

"""


📜 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 6ec8faa and 7a57922.

📒 Files selected for processing (1)
  • src/main/java/org/ezcode/codetest/infrastructure/event/config/RedisStreamConfig.java (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/org/ezcode/codetest/infrastructure/event/config/RedisStreamConfig.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
✨ 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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

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

549-549: 불필요한 빈 줄 제거

파일 끝에 불필요한 빈 줄이 있습니다.

-
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ab438c8 and 6ec8faa.

📒 Files selected for processing (5)
  • src/main/java/org/ezcode/codetest/infrastructure/event/config/RedisStreamConfig.java (3 hunks)
  • src/main/java/org/ezcode/codetest/infrastructure/event/listener/RedisJudgeQueueConsumer.java (0 hunks)
  • src/main/java/org/ezcode/codetest/infrastructure/openai/OpenAIMessageBuilder.java (2 hunks)
  • src/main/java/org/ezcode/codetest/infrastructure/openai/OpenAIResponseValidator.java (1 hunks)
  • src/main/resources/templates/test-submit.html (5 hunks)
💤 Files with no reviewable changes (1)
  • src/main/java/org/ezcode/codetest/infrastructure/event/listener/RedisJudgeQueueConsumer.java
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
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.957Z
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.
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.693Z
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#75
File: src/main/java/org/ezcode/codetest/application/submission/service/SubmissionService.java:142-147
Timestamp: 2025-06-19T07:00:53.895Z
Learning: SubmissionService.getCodeReview() 메서드에서 토큰 차감을 리뷰 요청 전에 수행하는 이유: OpenAI 서버 장애보다 유저 토큰 부족 상황이 더 빈번하므로, 확률이 높은 실패 케이스를 먼저 체크하여 불필요한 처리를 방지함. OpenAI 서버 장애 시에는 OpenAIClient에서 트랜잭션 롤백으로 토큰 복원이 처리됨.
Learnt from: thezz9
PR: ezcode-my/backend#132
File: src/main/java/org/ezcode/codetest/infrastructure/github/GitHubContentBuilder.java:72-72
Timestamp: 2025-07-02T09:39:31.475Z
Learning: User thezz9 prefers to proceed with breaking changes to path structures when it improves the organization, rather than maintaining backward compatibility or implementing migration strategies.
src/main/resources/templates/test-submit.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/infrastructure/openai/OpenAIMessageBuilder.java (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 요소를 통해 정답/오답 상태를 선택할 수 있도록 개선 예정입니다.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (11)
src/main/java/org/ezcode/codetest/infrastructure/event/config/RedisStreamConfig.java (2)

3-4: 필요한 import 추가 완료

호스트명 기반 컨슈머 이름 생성을 위한 import가 적절히 추가되었습니다.


81-81: 예외 처리 선언 적절함

InetAddress.getLocalHost()UnknownHostException을 던질 수 있으므로 메서드 시그니처에 예외 선언을 추가한 것이 올바릅니다.

src/main/java/org/ezcode/codetest/infrastructure/openai/OpenAIResponseValidator.java (2)

11-21: 오답 검증 로직 구현 잘 되었습니다

isCorrect가 false일 때 필수 섹션 존재 확인과 금지 섹션 배제 로직이 명확하게 구현되어 있습니다. 비즈니스 로직에 맞게 올바르게 작성되었습니다.


23-25: 정답 검증 로직 구현 적절합니다

정답일 때 필요한 세 가지 섹션(시간 복잡도, 코드 총평, 개선 방안)을 모두 확인하는 로직이 간결하고 명확합니다.

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

124-141: CSS 스타일링 구현 적절합니다

비활성화된 버튼과 리뷰 박스의 스타일링이 기존 다크 테마와 일관성 있게 구현되었습니다. 특히 리뷰 박스의 강조 텍스트에 브랜드 컬러(#00d084)를 사용한 것이 좋습니다.


309-309: AI 리뷰 버튼 통합 잘 되었습니다

기존 제출 버튼과 나란히 배치되어 있고, 초기 비활성화 상태가 적절합니다. 사용자 경험이 직관적입니다.


521-547: 리뷰 요청 함수 구현 훌륭합니다

에러 핸들링, 마크다운 파싱, 그리고 응답 표시 로직이 잘 구현되어 있습니다. 특히 마크다운 전처리 부분(줄바꿈 처리, 리스트 형식 정리)이 세심하게 작성되었습니다.

src/main/java/org/ezcode/codetest/infrastructure/openai/OpenAIMessageBuilder.java (4)

12-12: 모델명 수정 적절합니다

"o4-mini"에서 "gpt-4o"로 변경된 것은 올바른 OpenAI 모델명으로의 수정으로 보입니다. 이전 모델명은 유효하지 않은 것 같습니다.


17-19: 프롬프트 제약 조건 명확하게 추가됨

형식 준수 경고와 오답 시 시간 복잡도 항목 금지 규칙이 명확하게 명시되어 있습니다. 이는 OpenAIResponseValidator의 검증 로직과 일치합니다.


68-81: 정답 프롬프트 형식 개선되었습니다

시간 복잡도 설명이 더 구체적이고 명확해졌으며, 각 섹션의 형식 규칙이 상세하게 정의되어 있습니다. 특히 "N과 M을 같다고 가정하고 n으로 표기" 부분이 유용합니다.


84-100: 오답 프롬프트 형식 잘 구성됨

오답 시 시간 복잡도 관련 내용을 명시적으로 금지하는 지시사항이 효과적으로 추가되었습니다. 새로운 섹션 구조도 적절합니다.

Comment on lines +17 to +18
boolean containsForbidden = content.contains("**시간 복잡도**:") ||
content.toLowerCase().contains("**시간복잡도:**");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

금지 콘텐츠 검증 로직 개선 필요

toLowerCase() 처리 후 볼드 마크다운 패턴 **시간복잡도:**을 검사하는 것은 실제 응답에서 나타날 수 있는 다양한 형태를 놓칠 수 있습니다.

다음과 같이 개선하는 것을 권장합니다:

-            boolean containsForbidden = content.contains("**시간 복잡도**:") ||
-                content.toLowerCase().contains("**시간복잡도:**");
+            boolean containsForbidden = content.contains("**시간 복잡도**:") ||
+                content.toLowerCase().contains("시간복잡도") ||
+                content.toLowerCase().contains("시간 복잡도");
🤖 Prompt for AI Agents
In
src/main/java/org/ezcode/codetest/infrastructure/openai/OpenAIResponseValidator.java
around lines 17 to 18, the current check for forbidden content uses
toLowerCase() combined with a fixed bold markdown pattern, which may miss
variations in the actual response. To fix this, replace the exact string match
with a case-insensitive regular expression that matches the phrase "시간 복잡도" or
"시간복잡도" with or without bold markdown, allowing for flexible spacing and
formatting variations.

@thezz9 thezz9 merged commit 8d7329c into dev Jul 7, 2025
2 checks passed
@thezz9 thezz9 deleted the style/code-review branch July 7, 2025 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants