Skip to content

20260526 #83 today stats 누적 통계 필드 3개 클라이언트 연동#84

Merged
EM-H20 merged 10 commits into
mainfrom
20260526_#83_today_stats_누적_통계_필드_3개_클라이언트_연동
May 27, 2026

Hidden character warning

The head ref may contain hidden characters: "20260526_#83_today_stats_\ub204\uc801_\ud1b5\uacc4_\ud544\ub4dc_3\uac1c_\ud074\ub77c\uc774\uc5b8\ud2b8_\uc5f0\ub3d9"
Merged

20260526 #83 today stats 누적 통계 필드 3개 클라이언트 연동#84
EM-H20 merged 10 commits into
mainfrom
20260526_#83_today_stats_누적_통계_필드_3개_클라이언트_연동

Conversation

@EM-H20
Copy link
Copy Markdown
Contributor

@EM-H20 EM-H20 commented May 27, 2026

✨ 변경 사항


✅ 테스트


  • 수동 테스트 완료
  • 테스트 코드 완료

Summary by CodeRabbit

Release Notes

  • New Features

    • 누적 공부 시간, 누적 세션 수 및 월간 공부 시간 통계 정보 추가
    • 타이머 화면의 통계 표시를 주간에서 월간으로 변경
  • Documentation

    • API 응답 명세 및 오류 처리 정보 정확화
    • 통계 기능 프론트엔드 구현 설계 문서 추가
  • Tests

    • 통계 계산 로직 관련 테스트 확대

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

Warning

Review limit reached

@EM-H20, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 21 minutes and 47 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4e57152b-dbfb-41c6-ab6d-8f2ee82706a6

📥 Commits

Reviewing files that changed from the base of the PR and between 45ddad2 and bd1e1c5.

📒 Files selected for processing (5)
  • docs/api-docs.json
  • lib/features/timer/presentation/providers/today_stats_provider.dart
  • test/features/timer/data/datasources/timer_session_remote_datasource_test.dart
  • test/features/timer/data/repositories/timer_session_repository_impl_test.dart
  • test/features/timer/presentation/providers/today_stats_provider_test.dart

Walkthrough

서버에서 추가한 누적 통계 필드 3개(lifetimeMinutes, lifetimeSessionCount, monthlyMinutes)를 Flutter 클라이언트의 DTO/엔티티에 추가하고, today_stats_provider의 게스트 모드 로직을 확장하여 로컬 세션에서 6필드를 모두 계산한 후, study_stats_provider의 파생 함수들을 단순화하는 통합 작업입니다.

Changes

누적 통계 필드 클라이언트 통합

Layer / File(s) Summary
API 문서 및 서버 응답 스키마 정의
docs/api-docs.json, docs/superpowers/plans/*, docs/superpowers/specs/*
OpenAPI 문서에서 GET /api/timer-sessions/today-stats 응답이 lifetimeMinutes, lifetimeSessionCount, monthlyMinutes 3개 필드를 포함하도록 스키마와 예시를 확장하고, 구현 계획 및 설계 명세 문서를 추가합니다.
DTO 모델 필드 추가 및 JSON 매핑
lib/features/timer/data/models/today_stats_response_model.*
TodayStatsResponseModel에 3개 새 필드를 required int로 추가하고, Freezed 생성 코드(getter, copyWith, equality, hash) 및 JSON 직렬화 코드(fromJson, toJson)를 자동 업데이트합니다.
엔티티 모델 필드 추가 및 팩토리 업데이트
lib/features/timer/domain/entities/today_stats.*
TodayStats 엔티티에 3개 새 필드를 required int로 추가하고 TodayStats.empty()에서 새 필드들을 0으로 초기화하도록 변경하며, Freezed 생성 코드를 확장합니다.
today_stats_provider 게스트 모드 로직 확장
lib/features/timer/presentation/providers/today_stats_provider.*
게스트 모드에서 로컬 세션 전체를 이용해 monthStart 기준의 monthlyMinutes, 전체 세션 합계의 lifetimeMinutes, 전체 세션 개수의 lifetimeSessionCount를 추가로 계산하여 6필드를 모두 담은 TodayStats를 반환합니다.
study_stats_provider 함수 단순화 및 위임
lib/features/timer/presentation/providers/study_stats_provider.*
5개 함수(todayStudyMinutes, monthlyStudyMinutes, totalStudyMinutes, totalSessionCount, currentStreak)를 모두 todayStatsNotifierProvider.valueOrNull의 해당 필드로 위임하는 한 줄 구현으로 변경하고 weeklyStudyMinutes를 제거합니다.
Timer 화면 통계 표시 변경
lib/features/timer/presentation/screens/timer_screen.dart
Timer 화면의 "오늘의 통계" 영역에서 주간 학습 분 표시를 월간 학습 분으로 변경하기 위해 weeklyStudyMinutesProvider 대신 monthlyStudyMinutesProvider를 watch하고 UI 라벨을 "이번 주"에서 "이번 달"로 변경합니다.
DTO/엔티티 테스트 확장
test/features/timer/data/models/*, test/features/timer/domain/entities/today_stats_test.dart
TodayStatsResponseModel과 TodayStats 테스트에서 3개 새 필드를 포함하여 JSON 매핑, toEntity() 변환, 빈 상태 초기화를 6필드 기준으로 검증합니다.
저장소 및 데이터 소스 테스트 업데이트
test/features/timer/data/datasources/*, test/features/timer/data/repositories/*
TimerSessionRepository와 TimerSessionRemoteDataSource 테스트에서 getTodayStats() 응답이 3개 새 필드를 포함하도록 fixture를 확장합니다.
Provider 로직 테스트 추가
test/features/timer/presentation/providers/*
today_stats_provider_test에서 인증/게스트 모드 모두에서 6필드 계산을 검증하고, 새로 추가된 study_stats_provider_test에서 5개 파생 함수의 위임 동작을 검증합니다.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 PR의 주요 변경 사항을 명확히 반영합니다. 백엔드에서 추가한 누적 통계 필드 3개(lifetimeMinutes, lifetimeSessionCount, monthlyMinutes)의 클라이언트 연동이 전체 변경의 핵심이며, 제목이 이를 정확히 요약하고 있습니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 20260526_#83_today_stats_누적_통계_필드_3개_클라이언트_연동

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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

🧹 Nitpick comments (1)
test/features/timer/presentation/providers/today_stats_provider_test.dart (1)

41-44: ⚡ Quick win

인증 모드 검증은 6필드 전체를 확인하는 편이 안전합니다.

현재는 일부 필드만 검증해서, 신규 누적 필드 중 lifetimeSessionCount/monthlyMinutes 회귀를 놓칠 수 있습니다.

제안 diff
     expect(stats.totalMinutes, 180);
+    expect(stats.sessionCount, 3);
     expect(stats.streak, 7);
     expect(stats.lifetimeMinutes, 12450);
+    expect(stats.lifetimeSessionCount, 287);
+    expect(stats.monthlyMinutes, 1820);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/features/timer/presentation/providers/today_stats_provider_test.dart`
around lines 41 - 44, The test currently only asserts stats.totalMinutes,
stats.streak, and stats.lifetimeMinutes; add assertions for the remaining fields
to fully validate the "today stats" shape and catch regressions (specifically
add expectations for stats.lifetimeSessionCount and stats.monthlyMinutes and any
other missing fields returned by TodayStats, e.g., stats.monthlySessionCount) so
the test covers all six fields produced by the provider.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/api-docs.json`:
- Around line 1466-1482: The 401 and 500 response entries for GET
/api/fuel/transactions incorrectly reference FuelTransactionListResponse; update
those response objects to reference the ErrorResponse schema instead. Locate the
response objects that use "$ref":
"`#/components/schemas/FuelTransactionListResponse`" under the 401 and 500 keys
and replace them with "$ref": "`#/components/schemas/ErrorResponse`" so the error
contract is documented correctly.
- Around line 384-390: The 401 response for GET /api/timer-sessions currently
references the success DTO TimerSessionListResponse; update that schema
reference to ErrorResponse so authentication failures use the correct error
contract (replace "$ref": "`#/components/schemas/TimerSessionListResponse`" with
"$ref": "`#/components/schemas/ErrorResponse`" in the 401 response block for GET
/api/timer-sessions).

In `@lib/features/timer/presentation/providers/today_stats_provider.dart`:
- Around line 47-53: TodayStats.streak is being set to a binary value using
todaySessions.isEmpty ? 0 : 1 which loses the actual consecutive-day count
(breaking guest streaks); replace that ternary with the real streak value
produced by currentStreakProvider (or the existing computed streak variable) so
TodayStats receives the full integer streak instead of 0/1—i.e., locate the
TodayStats constructor call and change streak: todaySessions.isEmpty ? 0 : 1 to
streak: <use the currentStreakProvider result or the computed streak variable>.

In
`@test/features/timer/data/datasources/timer_session_remote_datasource_test.dart`:
- Around line 91-95: The test for api.getTodayStats() is missing assertions for
the newly added response fields lifetimeSessionCount and monthlyMinutes; update
the assertion block in timer_session_remote_datasource_test.dart (the test that
calls api.getTodayStats() and assigns to res) to include
expect(res.lifetimeSessionCount, <expectedValue>) and expect(res.monthlyMinutes,
<expectedValue>) using the correct expected numbers from the JSON test fixture
used by the test, so the expanded schema is fully validated alongside
totalMinutes, streak and lifetimeMinutes.

In
`@test/features/timer/data/repositories/timer_session_repository_impl_test.dart`:
- Around line 183-186: The test currently asserts stats.totalMinutes,
stats.streak and stats.lifetimeMinutes but misses verifying the two new
cumulative fields, causing mapping errors to go unnoticed; update the same test
(the block where the local variable stats is asserted) to also assert
stats.lifetimeSessionCount and stats.monthlyMinutes with their expected values
so the new fields are validated alongside lifetimeMinutes.

---

Nitpick comments:
In `@test/features/timer/presentation/providers/today_stats_provider_test.dart`:
- Around line 41-44: The test currently only asserts stats.totalMinutes,
stats.streak, and stats.lifetimeMinutes; add assertions for the remaining fields
to fully validate the "today stats" shape and catch regressions (specifically
add expectations for stats.lifetimeSessionCount and stats.monthlyMinutes and any
other missing fields returned by TodayStats, e.g., stats.monthlySessionCount) so
the test covers all six fields produced by the provider.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 98274398-4c4c-4002-af0d-d0a5cbd9ed6a

📥 Commits

Reviewing files that changed from the base of the PR and between 8540ad3 and 45ddad2.

📒 Files selected for processing (19)
  • docs/api-docs.json
  • docs/superpowers/plans/2026-05-27-today-stats-cumulative-fields-frontend.md
  • docs/superpowers/specs/2026-05-27-today-stats-cumulative-fields-frontend-design.md
  • lib/features/timer/data/models/today_stats_response_model.dart
  • lib/features/timer/data/models/today_stats_response_model.freezed.dart
  • lib/features/timer/data/models/today_stats_response_model.g.dart
  • lib/features/timer/domain/entities/today_stats.dart
  • lib/features/timer/domain/entities/today_stats.freezed.dart
  • lib/features/timer/presentation/providers/study_stats_provider.dart
  • lib/features/timer/presentation/providers/study_stats_provider.g.dart
  • lib/features/timer/presentation/providers/today_stats_provider.dart
  • lib/features/timer/presentation/providers/today_stats_provider.g.dart
  • lib/features/timer/presentation/screens/timer_screen.dart
  • test/features/timer/data/datasources/timer_session_remote_datasource_test.dart
  • test/features/timer/data/models/today_stats_response_model_test.dart
  • test/features/timer/data/repositories/timer_session_repository_impl_test.dart
  • test/features/timer/domain/entities/today_stats_test.dart
  • test/features/timer/presentation/providers/study_stats_provider_test.dart
  • test/features/timer/presentation/providers/today_stats_provider_test.dart

Comment thread docs/api-docs.json
Comment thread docs/api-docs.json
Comment thread lib/features/timer/presentation/providers/today_stats_provider.dart
…tion 보강 #83

- today_stats_provider 게스트 분기 streak 0/1 고정 회귀 → 로컬 세션 날짜 fold 로 다일 연속 계산 복원
- docs/api-docs.json 의 에러 상태(401/500) 응답 스키마가 성공 DTO 를 참조하던 4곳을 ErrorResponse 로 교정:
  * GET /api/timer-sessions 401 (TimerSessionListResponse -> ErrorResponse)
  * POST /api/timer-sessions 500 (TimerSessionCreateResponse -> ErrorResponse)
  * GET /api/timer-sessions/today-stats 401 (TodayStatsResponse -> ErrorResponse)
  * GET /api/fuel/transactions 401/500 (FuelTransactionListResponse -> ErrorResponse)
- timer_session_remote_datasource_test / repository_impl_test: lifetimeSessionCount, monthlyMinutes assertion 보강
- 게스트 다일 streak 회귀 가드 테스트 추가 (3일 연속 -> streak=3)
@EM-H20 EM-H20 merged commit 9bc0df9 into main May 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant