[Feat/runimo stat] 러니모 통계 데이터 갱신 로직 추가, 알 종류 GRASSLAND 제거#57
Conversation
WalkthroughThis update introduces a new service, Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant RecordCreateUsecaseImpl
participant UserStatService
participant RunimoService
participant RunimoRepository
participant Runimo
User->>RecordCreateUsecaseImpl: submit RecordCreateCommand
RecordCreateUsecaseImpl->>UserStatService: updateUserStats(userId, distance)
RecordCreateUsecaseImpl->>RunimoService: updateRunimoStat(mainRunimoId, distance)
RunimoService->>RunimoRepository: findById(mainRunimoId)
RunimoRepository-->>RunimoService: return Runimo
RunimoService->>Runimo: updateStat(distance)
RecordCreateUsecaseImpl->>RecordRepository: save(record)
Poem
Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/main/java/org/runimo/runimo/runimo/service/RunimoService.java (2)
18-24: Consider adding parameter validation and loggingThe method is functionally correct, but consider these enhancements:
- Add validation to ensure
distanceInMetersis not negative- Add logging to track when these statistics are updated and by how much
@Transactional public void updateRunimoStat(Long runimoId, Long distanceInMeters) { + if (distanceInMeters < 0) { + throw new IllegalArgumentException("Distance cannot be negative"); + } + Runimo runimo = runimoRepository.findById(runimoId) .orElseThrow(() -> RunimoException.of(RunimoHttpResponseCode.RUNIMO_NOT_FOUND)); runimo.updateStat(distanceInMeters); + // Consider adding logging: log.info("Updated stats for Runimo {}: added {} meters", runimoId, distanceInMeters); }
19-19: Consider using primitive type for distance parameterSince
distanceInMetersis unlikely to be null in normal operations, consider using the primitivelongtype instead ofLongto avoid potential null pointer exceptions and improve performance slightly.- public void updateRunimoStat(Long runimoId, Long distanceInMeters) { + public void updateRunimoStat(Long runimoId, long distanceInMeters) {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/main/java/org/runimo/runimo/item/domain/EggType.java(1 hunks)src/main/java/org/runimo/runimo/records/service/usecases/RecordCreateUsecaseImpl.java(2 hunks)src/main/java/org/runimo/runimo/runimo/domain/Runimo.java(1 hunks)src/main/java/org/runimo/runimo/runimo/service/RunimoService.java(1 hunks)src/test/java/org/runimo/runimo/runimo/controller/RunimoControllerTest.java(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/main/java/org/runimo/runimo/records/service/usecases/RecordCreateUsecaseImpl.java (1)
src/main/java/org/runimo/runimo/runimo/service/usecase/RunimoUsecaseImpl.java (1)
Transactional(23-62)
🔇 Additional comments (5)
src/main/java/org/runimo/runimo/item/domain/EggType.java (1)
11-12: Clean removal of GRASSLAND egg typeThe GRASSLAND egg type has been properly removed by commenting it out and adding a semicolon to maintain valid enum syntax. This aligns with the PR objective to remove this egg type following frontend requirements.
src/test/java/org/runimo/runimo/runimo/controller/RunimoControllerTest.java (1)
95-95: Test expectation correctly updatedThe test expectation has been properly adjusted to expect 2 runimo groups instead of 3, which is consistent with the removal of the GRASSLAND egg type from the EggType enum.
src/main/java/org/runimo/runimo/runimo/domain/Runimo.java (1)
44-47: Concise implementation for updating Runimo statisticsThe new
updateStatmethod provides a clean way to increment the run count and accumulate distance metrics for a Runimo entity. This implementation correctly supports the PR objective to update Runimo statistical data when running records are saved.src/main/java/org/runimo/runimo/records/service/usecases/RecordCreateUsecaseImpl.java (1)
8-8: Properly integrated Runimo statistics updateThe Runimo statistics update has been correctly integrated into the record creation flow. The code now updates both user statistics and Runimo statistics when a new running record is created, which ensures the Runimo data displayed on the main screen reflects the latest running records as stated in the PR objectives.
Also applies to: 22-22, 30-30
src/main/java/org/runimo/runimo/runimo/service/RunimoService.java (1)
1-26: Well-structured service implementation - looks good!The RunimoService is well-designed with appropriate transaction management and error handling. The implementation correctly updates Runimo statistics when a new running record is saved, which aligns with the PR objectives.
[작업 내용]
: 메인화면에 러니모 데이터 보여주는 걸로 변경하는 작업은 다훈님이 이미 해두신 것 같더라구요! 고생하셨습니다
: 프론트 요청에 따라 EggType enum 클래스에서 GRASSLAND 항목을 주석처리했습니다.
Summary by CodeRabbit