Skip to content

Feat: [BADA-354] SOS 한달에 한 번 사용 여부 검증#376

Merged
choyunju merged 1 commit intodevelopfrom
feature/BADA-354-reset-sos-available
Aug 4, 2025
Merged

Feat: [BADA-354] SOS 한달에 한 번 사용 여부 검증#376
choyunju merged 1 commit intodevelopfrom
feature/BADA-354-reset-sos-available

Conversation

@choyunju
Copy link
Copy Markdown
Contributor

@choyunju choyunju commented Aug 4, 2025

#️⃣연관된 이슈

close: #374

🚀 작업 내용

  • 사용자가 SOS 요청 시 해당 년도, 월에 이미 사용을 했고 응답자가 존재한다면 SOS 요청을 제한합니다.

🔍 리뷰 요청 사항

@choyunju choyunju added this to the 🚨 SOS milestone Aug 4, 2025
@choyunju choyunju self-assigned this Aug 4, 2025
@choyunju choyunju added the ✨ Feature 기능 개발 label Aug 4, 2025
@github-actions
Copy link
Copy Markdown

github-actions bot commented Aug 4, 2025

Failed to generate code suggestions for PR

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Aug 4, 2025

Walkthrough

이번 변경에서는 SOS 요청 관련 기능에 월별 중복 요청 방지 로직이 추가되었다. SosException enum에 이미 해당 월에 SOS를 신청한 경우를 나타내는 ALREADY_REQUEST_SOS 항목이 추가되었고, SosRepository에는 특정 사용자의 최신 SOS 요청을 조회하는 findFirstByRequesterIdOrderByCreatedAtDesc 메소드가 새로 정의되었다. SosService의 requestSos 메소드에는 사용자가 이번 달에 이미 응답된 SOS를 신청한 이력이 있을 경우 예외를 발생시키는 검증 로직이 삽입되었다.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 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 6082fb5 and c84efe8.

📒 Files selected for processing (3)
  • src/main/java/com/TwoSeaU/BaData/domain/sos/exception/SosException.java (1 hunks)
  • src/main/java/com/TwoSeaU/BaData/domain/sos/repository/SosRepository.java (1 hunks)
  • src/main/java/com/TwoSeaU/BaData/domain/sos/service/SosService.java (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: choyunju
PR: Ureca-Final-Project-Team2/be_badata#132
File: src/main/java/com/TwoSeaU/BaData/domain/user/dto/response/GetFollowsResponse.java:25-25
Timestamp: 2025-07-17T13:03:43.601Z
Learning: choyunju prefers intuitive field naming in DTOs - even if the API response could use generic names like "username", they prefer to use descriptive field names like "nickname" that clearly indicate the actual data being returned for better code clarity and maintainability.
Learnt from: choyunju
PR: Ureca-Final-Project-Team2/be_badata#267
File: src/main/java/com/TwoSeaU/BaData/domain/user/controller/UserController.java:151-154
Timestamp: 2025-07-28T01:13:39.883Z
Learning: choyunju는 프론트엔드에서 토글 형식으로 구현된 Boolean 파라미터의 경우, null 값이 들어올 수 없다고 판단하여 별도의 null 검증 로직을 추가하지 않는 것을 선호한다. 프론트엔드와 백엔드 간의 계약이 명확할 때 중복 검증을 피하는 설계 접근법을 취한다.
🔇 Additional comments (4)
src/main/java/com/TwoSeaU/BaData/domain/sos/repository/SosRepository.java (1)

19-19: LGTM! 잘 구현된 레포지토리 메소드입니다.

Spring Data JPA 네이밍 컨벤션을 올바르게 따르고 있으며, Optional<Sos>를 반환하여 null 안전성을 보장합니다. createdAt 기준 내림차순 정렬로 가장 최근 SOS 요청을 조회하는 로직이 명확합니다.

src/main/java/com/TwoSeaU/BaData/domain/sos/exception/SosException.java (1)

18-19: 적절한 예외 처리 구현입니다.

기존 패턴을 일관되게 따르고 있으며, 에러 코드 순번(5006)과 HTTP 상태 코드(BAD_REQUEST)가 적절합니다. 한국어 메시지도 사용자가 이해하기 쉽게 작성되었습니다.

src/main/java/com/TwoSeaU/BaData/domain/sos/service/SosService.java (2)

3-4: 적절한 import 추가입니다.

월별 비교를 위한 YearMonth와 Optional 처리를 위한 import가 올바르게 추가되었습니다.


37-45: 월별 SOS 중복 요청 방지 로직이 올바르게 구현되었습니다.

구현된 검증 로직이 PR 목표와 정확히 일치합니다:

  1. 해당 월에 이미 SOS를 신청했는지 확인
  2. 기존 SOS에 응답자가 있는지 확인
  3. 두 조건이 모두 만족될 때만 요청을 차단

이는 응답자가 없는 경우 재요청을 허용하는 합리적인 정책입니다. YearMonth 비교를 통한 월별 검증도 정확하게 구현되었습니다.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/BADA-354-reset-sos-available

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

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate unit tests to generate unit tests for 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.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Aug 4, 2025

Overall Project 15.02% -0.24%
Files changed 0%

File Coverage
SosService.java 0% -28.18%

@choyunju choyunju merged commit 238c6a2 into develop Aug 4, 2025
2 checks passed
@choyunju choyunju deleted the feature/BADA-354-reset-sos-available branch August 4, 2025 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ Feature 기능 개발

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BADA-354] [FEAT] SOS 매월 가능 여부 초기화

2 participants