Skip to content

Conversation

@sunohkim
Copy link
Collaborator

@sunohkim sunohkim commented Feb 20, 2025

[BE] 질문 데이터를 조회&삭제하는 과정에서 발생하는 문제 해결

#️⃣ 연관된 이슈

#205

📝 작업 내용

  • 질문 데이터를 조회할 때 해결된 질문까지 함께 가져오는 문제 해결
  • 수업 시작, 종료 시 질문 데이터를 삭제하는 기능 추가
    • 수업 시작 시 이전 수업에 남아 있던 모든 질문 삭제
    • 수업 종료 시 해결된 모든 질문 삭제

💬 리뷰 요구사항(선택)

Summary by CodeRabbit

  • New Features
    • Courses now automatically clear associated questions when starting and closing, ensuring a fresh state.
    • Student views display only pending questions, filtering out completed ones for clearer results.

- 수업이 종료될 경우 해결된 질문 일괄 삭제
- 수업이 시작될 경우 이전 수업의 질문 전체 삭제
@sunohkim sunohkim added 🐞 Fix 버그 수정 (기능 오류 및 예외 처리 등) 🌱 BE 백엔드 관련 labels Feb 20, 2025
@sunohkim sunohkim requested a review from uri010 February 20, 2025 08:17
@sunohkim sunohkim self-assigned this Feb 20, 2025
@coderabbitai
Copy link

coderabbitai bot commented Feb 20, 2025

Walkthrough

This pull request updates the course and question management logic within the application. In the course service, it adds calls to delete all or complete questions when a course starts or closes. The question repository is modified by replacing a method to retrieve questions for a student with one that fetches only incomplete ones, and it now provides a method to delete complete questions. The student question service has been updated to use the new repository query. These changes adjust the control flow for handling course lifecycle events and managing associated questions.

Changes

File(s) Change Summary
back-end/reacton/.../ProfessorCourseService.java Added deletion logic in startCourse (deleteAllByCourse) and closeCourse (deleteCompleteByCourse) to remove course-associated questions.
back-end/reacton/.../QuestionRepository.java
back-end/reacton/.../StudentQuestionService.java
Removed findByStudentIdAndCourse and added findNotCompleteByStudentIdAndCourse with a condition for incomplete questions; introduced deleteCompleteByCourse; updated service to use the new query method.

Sequence Diagram(s)

sequenceDiagram
    participant PC as ProfessorCourseService
    participant QR as QuestionRepository
    Note over PC, QR: Course lifecycle events
    PC->>QR: deleteAllByCourse(course) [startCourse]
    PC->>QR: deleteCompleteByCourse(course) [closeCourse]
Loading
sequenceDiagram
    participant SQ as StudentQuestionService
    participant QR as QuestionRepository
    Note over SQ, QR: Retrieving incomplete student questions
    SQ->>QR: findNotCompleteByStudentIdAndCourse(studentId, course)
Loading

Possibly related PRs

Poem

I’m a rabbit coding through the night,
Hopping on changes, feeling light.
Clearing questions one by one,
Like munching carrots in the sun.
With each clean hop and joyful beat,
I celebrate code that’s crisp and neat! 🐰


📜 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 e22c506 and 6ac4241.

📒 Files selected for processing (3)
  • back-end/reacton/src/main/java/com/softeer/reacton/domain/course/ProfessorCourseService.java (2 hunks)
  • back-end/reacton/src/main/java/com/softeer/reacton/domain/question/QuestionRepository.java (1 hunks)
  • back-end/reacton/src/main/java/com/softeer/reacton/domain/question/StudentQuestionService.java (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
back-end/reacton/src/main/java/com/softeer/reacton/domain/course/ProfessorCourseService.java (1)
Learnt from: sunohkim
PR: softeer5th/Team3-PowerPenguin#94
File: back-end/reacton/src/main/java/com/softeer/reacton/domain/course/ProfessorCourseService.java:189-202
Timestamp: 2025-02-11T06:18:05.772Z
Learning: The team values clean code and well-structured refactoring, particularly when it involves breaking down complex stream operations into smaller, more focused methods for better maintainability and performance.
🔇 Additional comments (5)
back-end/reacton/src/main/java/com/softeer/reacton/domain/question/QuestionRepository.java (2)

13-15: LGTM! Well-structured query method.

The JPQL query is clear and follows best practices with explicit conditions.


23-27: LGTM! Efficient bulk deletion implementation.

The method is properly annotated with @Modifying and @transactional for bulk operations.

back-end/reacton/src/main/java/com/softeer/reacton/domain/question/StudentQuestionService.java (1)

98-108: LGTM! Clean implementation of the incomplete questions filter.

The method efficiently uses the new repository query while maintaining the existing response structure.

back-end/reacton/src/main/java/com/softeer/reacton/domain/course/ProfessorCourseService.java (2)

162-162: LGTM! Clean question data management at course start.

The implementation correctly deletes all questions when starting a new course session.


173-173: LGTM! Proper cleanup of resolved questions at course end.

The implementation correctly deletes completed questions while maintaining the course closure notification flow.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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
Collaborator

@uri010 uri010 left a comment

Choose a reason for hiding this comment

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

Approve!!

@sunohkim sunohkim merged commit 97d6b7a into dev Feb 20, 2025
2 checks passed
@sunohkim sunohkim deleted the fix/be/question branch February 20, 2025 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🌱 BE 백엔드 관련 🐞 Fix 버그 수정 (기능 오류 및 예외 처리 등)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants