Skip to content

Comments

[feat] #147 페스티벌 입장 시 자동으로 포인트 충전하는 기능 구현#148

Merged
2hyunjinn merged 2 commits intomainfrom
feat/#147
Jul 10, 2025
Merged

[feat] #147 페스티벌 입장 시 자동으로 포인트 충전하는 기능 구현#148
2hyunjinn merged 2 commits intomainfrom
feat/#147

Conversation

@2hyunjinn
Copy link
Member

@2hyunjinn 2hyunjinn commented Jul 10, 2025

📌 PR 제목

[feat] #147 페스티벌 입장 시 자동으로 포인트 충전하는 기능 구현

📌 PR 내용

  • 페스티벌 입장 시 자동으로 포인트 충전하는 기능 구현

🛠 작업 내용

  • 페스티벌 입장 시 자동으로 10포인트를 충전할 수 있도록 구현하였습니다.

🔍 관련 이슈

Closes #147

📸 스크린샷 (Optional)

image

📚 레퍼런스 (Optional)

N/A

Summary by CodeRabbit

  • New Features

    • Newly created participants now automatically receive 10 points upon creation.
  • Tests

    • Added a test to verify that participants are granted 10 points when created.

@2hyunjinn 2hyunjinn self-assigned this Jul 10, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jul 10, 2025

Walkthrough

A call to recharge 10 points for a participant was added immediately after participant creation in the ParticipantFacade. A new test was introduced to verify that the point recharge occurs as expected during participant creation. No changes were made to method signatures or control flow outside this scope.

Changes

File(s) Change Summary
src/main/java/org/festimate/team/api/facade/ParticipantFacade.java Added point recharge logic (10 points) after participant creation in createParticipant.
src/test/java/org/festimate/team/api/facade/ParticipantFacadeTest.java Added test to verify point recharge on participant creation.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ParticipantFacade
    participant PointService
    participant MatchingService

    User->>ParticipantFacade: createParticipant()
    ParticipantFacade->>ParticipantFacade: create participant
    ParticipantFacade->>PointService: rechargePoint(participant, 10)
    ParticipantFacade->>MatchingService: matchPendingParticipants()
    ParticipantFacade-->>User: return participantId
Loading

Assessment against linked issues

Objective Addressed Explanation
Implement automatic 10-point recharge when entering festival (#147)

Suggested labels

feat

Poem

A festival begins, the crowd is bright,
With every entrance, points take flight!
Ten shiny coins, a welcome cheer,
For every participant drawing near.
The code now gives a joyful start—
Points for all, a happy heart!
🐰✨

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

@2hyunjinn 2hyunjinn added the feat Extra attention is needed label Jul 10, 2025
@github-actions
Copy link

Test Results

47 tests   47 ✅  1s ⏱️
10 suites   0 💤
10 files     0 ❌

Results for commit e86affa.

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

🧹 Nitpick comments (5)
src/main/java/org/festimate/team/api/facade/ParticipantFacade.java (3)

45-45: Consider extracting the point amount to a configuration constant.

The hardcoded value of 10 points works for the current requirement, but extracting it to a constant or configuration property would improve maintainability and flexibility.

Consider this refactor to make the point amount configurable:

+    private static final int FESTIVAL_ENTRY_POINTS = 10;
+
     @Transactional
     public EntryResponse createParticipant(Long userId, Long festivalId, ProfileRequest request) {
         // ... existing code ...
         Participant participant = participantService.createParticipant(user, festival, request);
-        pointService.rechargePoint(participant, 10);
+        pointService.rechargePoint(participant, FESTIVAL_ENTRY_POINTS);
         matchingService.matchPendingParticipants(participant);

Alternatively, you could make it configurable via @Value("${festival.entry.points:10}") if different festivals should have different point amounts.


45-45: Consider extracting the hardcoded point value to a configurable constant.

The automatic point recharge functionality is well-placed within the transaction and execution flow. However, the hardcoded value 10 reduces maintainability and flexibility.

Consider extracting this to a constant or configuration property:

+    private static final int ENTRY_BONUS_POINTS = 10;
+
     @Transactional
     public EntryResponse createParticipant(Long userId, Long festivalId, ProfileRequest request) {
         // ... existing code ...
-        pointService.rechargePoint(participant, 10);
+        pointService.rechargePoint(participant, ENTRY_BONUS_POINTS);
         // ... rest of method ...
     }

Alternatively, consider making this configurable via application properties for different festival types or promotional periods.


45-45: Good implementation with considerations for robustness.

The automatic point recharge feature is correctly placed after participant creation and before matching. However, consider the following improvements:

  1. Error handling: If pointService.rechargePoint fails, the entire transaction will rollback. Ensure this is the intended behavior.
  2. Configuration: The hard-coded 10 points might benefit from being configurable (e.g., via application properties or festival-specific settings).

Consider making the point amount configurable:

-        pointService.rechargePoint(participant, 10);
+        pointService.rechargePoint(participant, getInitialPointAmount());

And add a method or configuration property for the initial point amount.

src/test/java/org/festimate/team/api/facade/ParticipantFacadeTest.java (2)

84-100: Well-structured test for the new point recharge feature.

The test properly verifies both the point recharge and matching service calls, with appropriate mocking and assertions. The Korean display name is consistent with the existing test style.

Consider updating the existing test for consistency.

The existing createParticipant_success test (lines 72-82) doesn't verify the point recharge functionality. For consistency and completeness, consider updating it to also verify the point service call:

     @Test
     @DisplayName("참가자 생성 성공")
     void createParticipant_success() {
         when(userService.getUserByIdOrThrow(1L)).thenReturn(user);
         when(festivalService.getFestivalByIdOrThrow(1L)).thenReturn(festival);
         when(participantService.createParticipant(any(), any(), any())).thenReturn(participant);

         var response = participantFacade.createParticipant(1L, 1L, null);

         assertThat(response.participantId()).isNotNull();
+        verify(pointService).rechargePoint(participant, 10);
         verify(matchingService).matchPendingParticipants(participant);
     }

This would ensure all participant creation tests verify the complete behavior.


84-100: Well-structured test with room for enhancement.

The test correctly verifies the point recharge functionality and maintains good test practices. Consider the following improvements:

  1. Test efficiency: Since this test largely duplicates createParticipant_success, consider consolidating them or making this test more focused on the point-specific behavior.
  2. Error scenario testing: Add tests for point recharge failure scenarios to ensure proper error handling.

Consider adding an error scenario test:

@Test
@DisplayName("참가자 생성 시 포인트 충전 실패하면 롤백된다")
void createParticipant_pointRecharge_fail() {
    when(userService.getUserByIdOrThrow(1L)).thenReturn(user);
    when(festivalService.getFestivalByIdOrThrow(1L)).thenReturn(festival);
    when(participantService.getParticipant(user, festival)).thenReturn(null);
    when(participantService.createParticipant(any(), any(), any())).thenReturn(participant);
    doThrow(new RuntimeException("Point service unavailable"))
        .when(pointService).rechargePoint(participant, 10);

    assertThatThrownBy(() -> participantFacade.createParticipant(1L, 1L, null))
        .isInstanceOf(RuntimeException.class);
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e4b0c4d and e86affa.

📒 Files selected for processing (2)
  • src/main/java/org/festimate/team/api/facade/ParticipantFacade.java (1 hunks)
  • src/test/java/org/festimate/team/api/facade/ParticipantFacadeTest.java (1 hunks)
⏰ 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). (2)
  • GitHub Check: test
  • GitHub Check: Build Test
🔇 Additional comments (1)
src/test/java/org/festimate/team/api/facade/ParticipantFacadeTest.java (1)

84-100: Excellent test coverage for the new point recharge feature.

This test method effectively verifies the new automatic point charging functionality while maintaining coverage of existing behavior. The implementation demonstrates good testing practices:

  • Proper mock setup ensuring no existing participant conflicts
  • Verification of both the new functionality (pointService.rechargePoint) and existing behavior (matchingService.matchPendingParticipants)
  • Clear, descriptive Korean display name that matches the business requirement
  • Consistent with existing test patterns in the class

@2hyunjinn 2hyunjinn merged commit 016ee9d into main Jul 10, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat Extra attention is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] 페스티벌 입장 시 자동으로 포인트 충전하는 기능 구현

1 participant