-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat/mypage simple stat] #71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThis change refactors the way running record statistics are aggregated and presented in the application. The repository and service layers now retrieve raw record statistics with timestamps and distances, then aggregate these into daily summaries within the service. The Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Controller
participant RecordQueryUsecaseImpl
participant RecordFinder
participant RecordRepository
participant DB
Client->>Controller: Request weekly/monthly stats
Controller->>RecordQueryUsecaseImpl: getUserWeekly/MonthlyRecordStat(query)
RecordQueryUsecaseImpl->>RecordFinder: findDailyStatByUserIdBetween(userId, from, to)
RecordFinder->>RecordRepository: findRecordStatByUserIdAndBetween(userId, from, to)
RecordRepository->>DB: Query raw record stats
DB-->>RecordRepository: List<RecordStatDto>
RecordRepository-->>RecordFinder: List<RecordStatDto>
RecordFinder->>RecordFinder: mapToDailyStatList(List<RecordStatDto>)
RecordFinder-->>RecordQueryUsecaseImpl: List<DailyStat>
RecordQueryUsecaseImpl->>SimpleStat: from(List<DailyStat>)
SimpleStat-->>RecordQueryUsecaseImpl: SimpleStat
RecordQueryUsecaseImpl-->>Controller: Response (SimpleStat + List<DailyStat>)
Controller-->>Client: JSON response (simple_stat, daily_stats)
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Note 🎁 Summarized by CodeRabbit FreeYour 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
/gemini-review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gemini AI Code Reviewer Comments
| @@ -33,14 +33,15 @@ Slice<RunningRecord> findFirstRunOfWeek( | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The query now fetches startedAt, endAt, and totalDistance.amount which are then processed in the application layer. Consider the performance implications of fetching all this data and processing it in Java code, especially for users with a large number of records. Ensure that database indexes are properly configured for the userId and startedAt fields to optimize query performance. Also, ensure that the data being fetched is not excessively large. If the number of records is very large, consider pagination or other techniques to reduce the amount of data being transferred.
| @JsonIgnore | ||
| private Long runningCount; | ||
| private Long distanceInMeters; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The addData method modifies the state of the DailyStat object. Ensure that this behavior is intended and thread-safe if this object is used in a multi-threaded environment.
jeeheaG
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다!
작업내역
*Breaking Change
RecordRepository의 기간 통계 쿼리를 변경했습니다. 기존에는 SQL의GROUPBY를 활용했습니다. 추가적인 요구사항에 따라 JPQL로 작성하려다보니 DB종속적인 함수를 사용해야했습니다. 따라서 애플리케이션에서 조립하는 방식으로 변경했습니다.select (r.startedAt, r.endAt, r.distance) from Record where user_id = :userId와 같이 필요한 기록 데이터만 쿼리하여 매핑했습니다. 매핑함수는RecordFinder.class에 정의되어있으며O(n) - 1 loop로 매핑하도록 작성했습니다.Summary by CodeRabbit
distance_in_meters).