Skip to content

Feat: [BADA-374] SOS 응답자의 코인 히스토리 내역 추가#394

Merged
marineAqu merged 1 commit intodevelopfrom
feature/BADA-374-save-sos-coin-history
Aug 6, 2025
Merged

Feat: [BADA-374] SOS 응답자의 코인 히스토리 내역 추가#394
marineAqu merged 1 commit intodevelopfrom
feature/BADA-374-save-sos-coin-history

Conversation

@choyunju
Copy link
Copy Markdown
Contributor

@choyunju choyunju commented Aug 6, 2025

#️⃣연관된 이슈

close: #393

🚀 작업 내용

  • SOS 응답자의 코인 히스토리 내역 추가

🔍 리뷰 요청 사항

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

github-actions bot commented Aug 6, 2025

Failed to generate code suggestions for PR

@github-actions
Copy link
Copy Markdown

github-actions bot commented Aug 6, 2025

Overall Project 19.1% -0.1%
Files changed 0%

File Coverage
SosService.java 0% -10.66%

@marineAqu marineAqu merged commit c4ec443 into develop Aug 6, 2025
2 checks passed
@marineAqu marineAqu deleted the feature/BADA-374-save-sos-coin-history branch August 6, 2025 01:59
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Aug 6, 2025

Walkthrough

SosService 클래스에 CoinHistoryRepository가 새로운 의존성으로 추가되었습니다. respondSos 메서드 내에서 SOS 응답이 성공했을 때(isSuccess가 true), 응답 사용자에게 10코인의 보상을 나타내는 새로운 CoinHistory 레코드를 생성 및 저장하는 로직이 추가되었습니다. 이때 코인 출처는 CoinSource.SOS로 기록되며, 사용자의 현재 코인 잔액도 함께 저장됩니다. 기존의 SSE 이벤트 브로드캐스트 및 응답 반환 로직에는 변화가 없습니다.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7분

Note

⚡️ Unit Test Generation is now available in beta!

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

✨ 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-374-save-sos-coin-history

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.

Copy link
Copy Markdown

@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: 0

🧹 Nitpick comments (1)
src/main/java/com/TwoSeaU/BaData/domain/sos/service/SosService.java (1)

70-70: 하드코딩된 보상 코인을 상수로 추출하는 것을 고려해보세요.

유지보수성 향상을 위해 보상 코인 값을 클래스 상수로 정의하는 것이 좋겠습니다.

다음과 같이 리팩토링할 수 있습니다:

+ private static final Integer SOS_REWARD_COIN = 10;
  private final String sosMessage = "누군가 SOS를 요청하였습니다.";

그리고 해당 라인을:

- final Integer rewardCoin = 10;
+ final Integer rewardCoin = SOS_REWARD_COIN;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7d028ff and bc850a2.

📒 Files selected for processing (1)
  • src/main/java/com/TwoSeaU/BaData/domain/sos/service/SosService.java (3 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: dionisos198
PR: Ureca-Final-Project-Team2/be_badata#291
File: src/main/java/com/TwoSeaU/BaData/domain/user/entity/User.java:92-94
Timestamp: 2025-07-29T01:57:02.534Z
Learning: User 엔티티의 addCoin 메서드는 리뷰 작성 시 한 사람에게만 적용되는 단일 사용자 환경에서 사용되므로 멀티스레드 동시성 처리가 필요하지 않다.
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 검증 로직을 추가하지 않는 것을 선호한다. 프론트엔드와 백엔드 간의 계약이 명확할 때 중복 검증을 피하는 설계 접근법을 취한다.
📚 Learning: user 엔티티의 addcoin 메서드는 리뷰 작성 시 한 사람에게만 적용되는 단일 사용자 환경에서 사용되므로 멀티스레드 동시성 처리가 필요하지 않다....
Learnt from: dionisos198
PR: Ureca-Final-Project-Team2/be_badata#291
File: src/main/java/com/TwoSeaU/BaData/domain/user/entity/User.java:92-94
Timestamp: 2025-07-29T01:57:02.534Z
Learning: User 엔티티의 addCoin 메서드는 리뷰 작성 시 한 사람에게만 적용되는 단일 사용자 환경에서 사용되므로 멀티스레드 동시성 처리가 필요하지 않다.

Applied to files:

  • src/main/java/com/TwoSeaU/BaData/domain/sos/service/SosService.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-test
🔇 Additional comments (3)
src/main/java/com/TwoSeaU/BaData/domain/sos/service/SosService.java (3)

14-18: 새로운 임포트가 올바르게 추가되었습니다.

코인 히스토리 기능을 위한 필요한 클래스들이 적절히 임포트되었습니다.


34-34: 의존성 주입 필드가 올바르게 추가되었습니다.

기존 패턴과 일치하게 private final로 선언되어 생성자 주입이 적절히 처리됩니다.


71-71: 코인 히스토리 기록 시 사용자 잔액이 올바르게 업데이트됩니다

  • Sos.respond() 내부에서 this.responder.addCoin(rewardCoin)을 호출해 실제로 사용자 코인을 증가시킵니다.
  • SosService.respondSos()에는 클래스 상단에 @Transactional이 적용되어 있어, addCoin으로 변경된 코인 값이 트랜잭션 커밋 시점에 DB에 반영됩니다.
  • 따라서 coinHistoryRepository.save(CoinHistory.of(user, CoinSource.SOS, rewardCoin, user.getCoin()))에 전달되는 user.getCoin()은 이미 증가된 잔액입니다.

해당 부분은 의도대로 동작하므로 추가 수정이 필요 없습니다.

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-374] [FEAT] SOS 응답자 코인 획득 시 코인 히스토리 저장 로직 추가

3 participants