Skip to content

[Fix/reward response] - 보상 응답 수정#94

Merged
ekgns33 merged 6 commits intomainfrom
fix/reward-response
May 19, 2025
Merged

[Fix/reward response] - 보상 응답 수정#94
ekgns33 merged 6 commits intomainfrom
fix/reward-response

Conversation

@ekgns33
Copy link
Contributor

@ekgns33 ekgns33 commented May 18, 2025

작업 내역

  • 보상 응답에 알 이미지 URL 추가

    • 알을 지급한 경우 해당 알의 url
    • 알을 지급하지 않은 경우 "EMPTY"
  • 기존에 전체 애정포인트를 반환하던 잘못된 로직을 획득한 애정포인트를 반환하도록 변경

Summary by CodeRabbit

  • New Features

    • Added an image URL field to reward responses, allowing users to see the associated egg image when claiming a reward.
  • Bug Fixes

    • Improved accuracy and validation of love point rewards in response payloads.
  • Tests

    • Enhanced reward acceptance tests to verify the presence of the egg image URL and exact love point amount.
    • Added new tests to ensure love points are granted correctly based on running distance.

@coderabbitai
Copy link

coderabbitai bot commented May 18, 2025

Walkthrough

The changes introduce a new image URL field to the RewardResponse record and implement a static factory method for its creation. The reward service is updated to use this factory method. The love point grant service is simplified, and new, more specific test assertions and a dedicated test class for love point granting logic are added.

Changes

File(s) Change Summary
.../rewards/service/RewardService.java Updated to use RewardResponse.of() factory method for constructing reward responses, delegating details to the new method.
.../rewards/service/dto/RewardResponse.java Added eggImgUrl field and a static factory method of(Egg, Long) for constructing response objects.
.../rewards/service/lovepoint/LoveGrantService.java Removed unused import and simplified logic to return love point amount directly without storing intermediate object.
.../rewards/api/RewardAcceptanceTest.java Enhanced test assertions to check for exact love point amount and non-null egg image URL in the response.
.../rewards/service/lovepoint/LoveGrantServiceTest.java Added new test class to verify love point granting logic for different running distances using mocks and assertions.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant RewardService
    participant RewardResponse
    participant Egg
    participant LoveGrantService

    Client->>RewardService: claimReward(command)
    RewardService->>LoveGrantService: grantLoveToUserWithDistance(record)
    LoveGrantService-->>RewardService: lovePointAmount
    RewardService->>RewardResponse: of(grantedEgg, grantedLoveAmount)
    RewardResponse->>Egg: getItemCode(), getTypeName(), getImgUrl()
    RewardResponse-->>RewardService: RewardResponse instance
    RewardService-->>Client: RewardResponse
Loading

Poem

In the garden of code where rewards bloom anew,
An egg brings its image, a love point or two.
Tests now are sharper, with checks bold and bright,
Granting points for each kilometer’s flight.
With factory methods, the changes align—
The code hops ahead, and all works just fine! 🥚✨

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Free
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 37f05da and 802260f.

📒 Files selected for processing (5)
  • src/main/java/org/runimo/runimo/rewards/service/RewardService.java (1 hunks)
  • src/main/java/org/runimo/runimo/rewards/service/dto/RewardResponse.java (1 hunks)
  • src/main/java/org/runimo/runimo/rewards/service/lovepoint/LoveGrantService.java (1 hunks)
  • src/test/java/org/runimo/runimo/rewards/api/RewardAcceptanceTest.java (1 hunks)
  • src/test/java/org/runimo/runimo/rewards/service/lovepoint/LoveGrantServiceTest.java (1 hunks)

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

🪧 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? Join our Discord community 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 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.

@ekgns33 ekgns33 self-assigned this May 18, 2025
@ekgns33 ekgns33 added the bug Something isn't working label May 18, 2025
@ekgns33 ekgns33 requested review from Copilot and jeeheaG and removed request for Copilot May 18, 2025 08:27
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the reward response by including the egg image URL and corrects the logic to return only the newly earned love points rather than the aggregate total.

  • Add an eggImgUrl field and of factory method to RewardResponse
  • Update LoveGrantService to return the calculated loveAmount instead of LovePoint.getAmount()
  • Adjust service and acceptance tests to assert the exact love point value and the presence of the egg image URL

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/test/java/org/runimo/runimo/rewards/service/lovepoint/LoveGrantServiceTest.java Unit tests for love-point awarding logic
src/test/java/org/runimo/runimo/rewards/api/RewardAcceptanceTest.java Acceptance test now asserts exact love_point_amount and egg_img_url
src/main/java/org/runimo/runimo/rewards/service/lovepoint/LoveGrantService.java Return the calculated loveAmount directly
src/main/java/org/runimo/runimo/rewards/service/dto/RewardResponse.java Added eggImgUrl and static factory method
src/main/java/org/runimo/runimo/rewards/service/RewardService.java Switched to using RewardResponse.of(...) for building responses

.statusCode(HttpStatus.OK.value())
.body("payload.love_point_amount", notNullValue())
.body("payload.love_point_amount", greaterThan(0));
.body("payload.love_point_amount", greaterThan(0))
Copy link

Copilot AI May 18, 2025

Choose a reason for hiding this comment

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

[nitpick] The assertion that payload.love_point_amount is greater than 0 is redundant when you assert it equals 5 immediately after. Consider removing the redundant check to keep the test concise.

Suggested change
.body("payload.love_point_amount", greaterThan(0))

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@jeeheaG jeeheaG left a comment

Choose a reason for hiding this comment

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

수고하셨습니다!

@ekgns33 ekgns33 merged commit 08af1e0 into main May 19, 2025
3 checks passed
@ekgns33 ekgns33 deleted the fix/reward-response branch May 19, 2025 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants