Conversation
Walkthrough学習連続記録機能を追加。User に学習時間付きレポート取得メソッドを追加し、StudyStreak モデルで現在/最長ストリークを算出、ViewComponent と SASS で表示、コントローラーはビューで使用する Changes
Sequence DiagramsequenceDiagram
participant Browser as ブラウザ
participant Controller as Controller (Home/Users)
participant UserModel as User (reports_with_learning_times)
participant StudyStreak as StudyStreak (モデル)
participant Component as StudyStreak::StudyStreakTrackerComponent
participant UI as 表示 (HTML/CSS)
Browser->>Controller: ダッシュボード/プロフィール要求
Controller->>UserModel: reports_with_learning_times
UserModel-->>Controller: レポート一覧(学習時間付き)
Controller->>StudyStreak: StudyStreak.new(reports, include_wip: false)
StudyStreak->>StudyStreak: 日付抽出→連続日チャンク化→current/longest 計算
StudyStreak-->>Controller: StudyStreak オブジェクト
Controller->>Component: render(study_streak: `@study_streak`)
Component->>Component: current?/longest? 判定・format_period 呼び出し
Component-->>UI: HTML(ストリーク数・期間)
UI-->>Browser: レンダリング
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
|
@machida デザイン対象のHTMLファイルが デザインを確認する際に日報データを作成する必要があるのですが、コンソールで作成できるよう手順をプルリクエスト本文の変更確認手順に記載しました。 |
|
@jun-kond |
1c55f5b to
d3e1f80
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (5)
app/javascript/stylesheets/application/blocks/user/_user-study-streak-tracker.sass (1)
34-34: 色の値をCSS変数に置き換えてください。
#f7941dがハードコードされていますが、同じファイル内の他の箇所(Line 50)ではvar(--muted-text)のようにCSS変数を使用しています。テーマの一貫性と保守性を向上させるため、この色もCSS変数として定義することを推奨します。次のように修正できます:
.streak-item__number font-weight: 700 - color: #f7941d + color: var(--streak-number-color) +media-breakpoint-up(md) +text-block(2.5rem 1) +media-breakpoint-down(sm) +text-block(2rem 1)そして、対応するCSS変数を定義ファイルに追加してください。
test/supports/report_helper.rb (1)
48-58: 時間生成と永続化オプションを見直してください
- Time.zone.parse の文字列パースより Time.zone.local + on.to_date を使う方が堅牢で高速です。
- 「学習時間なし(no_learn)の日報をDBに存在させたい」ケースに備え、no_learn 時も任意で保存できるオプションがあると便利です(現状は保存されないため再現できません)。
以下のような修正を提案します:
-def create_report_data_with_learning_times(user:, on:, wip: false, no_learn: false, durations: [[9, 12]]) - report = Report.new(user:, title: "test #{on}", emotion: 2, description: 'desc', reported_on: on, wip:, no_learn:) - unless no_learn - durations.each do |(s, e)| - report.learning_times << LearningTime.new(report:, started_at: Time.zone.parse("#{on} #{format('%02d:00:00', s)}"), - finished_at: Time.zone.parse("#{on} #{format('%02d:00:00', e)}")) - end - report.save! - end - report -end +def create_report_data_with_learning_times(user:, on:, wip: false, no_learn: false, durations: [[9, 12]], persist_when_no_learn: false) + on_date = on.to_date + report = Report.new(user:, title: "test #{on_date}", emotion: 2, description: 'desc', reported_on: on_date, wip:, no_learn:) + if no_learn + report.save! if persist_when_no_learn + else + durations.each do |(s, e)| + report.learning_times << LearningTime.new( + report:, + started_at: Time.zone.local(on_date.year, on_date.month, on_date.day, s, 0, 0), + finished_at: Time.zone.local(on_date.year, on_date.month, on_date.day, e, 0, 0) + ) + end + report.save! + end + report +endapp/models/user_study_streak.rb (1)
21-24: distinct を追加して重複日付の混入を防止引数の reports が distinct でない場合、同日の重複が chunk_while の連続日評価を乱す可能性があります。ここで distinct を噛ませておくと安全です(既に distinct 済みでも冪等)。
def report_dates(reports) - reports = reports.not_wip unless include_wip - reports.order(reported_on: :asc).pluck(:reported_on) + reports = reports.not_wip unless include_wip + reports.distinct.order(reported_on: :asc).pluck(:reported_on) endtest/models/user_study_streak_test.rb (1)
65-85: テスト名の英語を簡潔に可読性のため、以下へリネームを提案します。
-test 'study streak should include wip report days when include wip option be true report' do +test 'includes WIP days when include_wip is true' doapp/components/study_streak/user_study_streak_tracker_component.rb (1)
42-53: ローカル変数の割り当てを簡略化できます45-46行目の
start_dateとend_dateへの割り当ては不要です。start_onとend_onを直接使用できます。次のように簡略化できます:
def format_period(days:, start_on:, end_on:) return '' if days.to_i.zero? || start_on.nil? || end_on.nil? - start_date = start_on - end_date = end_on current_year = Time.zone.today.year - if start_date.year == end_date.year && start_date.year == current_year - "#{start_date.strftime('%m/%d')} 〜 #{end_date.strftime('%m/%d')}" + if start_on.year == end_on.year && start_on.year == current_year + "#{start_on.strftime('%m/%d')} 〜 #{end_on.strftime('%m/%d')}" else - "#{start_date.strftime('%Y/%m/%d')} 〜 #{end_date.strftime('%Y/%m/%d')}" + "#{start_on.strftime('%Y/%m/%d')} 〜 #{end_on.strftime('%Y/%m/%d')}" end end
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (14)
app/components/study_streak/user_study_streak_tracker_component.html.slim(1 hunks)app/components/study_streak/user_study_streak_tracker_component.rb(1 hunks)app/controllers/home_controller.rb(1 hunks)app/controllers/users_controller.rb(1 hunks)app/javascript/stylesheets/application.sass(1 hunks)app/javascript/stylesheets/application/blocks/user/_user-study-streak-tracker.sass(1 hunks)app/models/user.rb(1 hunks)app/models/user_study_streak.rb(1 hunks)app/views/home/index.html.slim(1 hunks)app/views/users/show.html.slim(2 hunks)test/components/study_streak/user_study_streak_tracker_component_test.rb(1 hunks)test/models/user_study_streak_test.rb(1 hunks)test/models/user_test.rb(1 hunks)test/supports/report_helper.rb(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.rb
⚙️ CodeRabbit configuration file
**/*.rb: # refactoring
- まずFat Controllerを避け、次にFat Modelを避ける。
- Serviceクラスの乱用を避ける。
- controller concernを作ろうとしたらPORO(Plain Old Ruby Object)やActiveRecordモデルでの実装で代替できないか検討する。
Rails Patterns
- ViewHelperにメソッドを実装する時にはまずDecoratorパターンを使うことを検討する。(active_decorator gemを導入しているのでそれを使う)
- 複雑なActiveRecordクエリがあり、再利用できそうな場合はQueryObjectパターンを検討する。(rails-patterns gemを導入しているのでそれのQuery機能を使う)
- Viewにpartialを作る場合はViewComponentを使うことを検討する。
- 複数のActiveRecordモデルを操作する1つの責務がある時や外部APIとやりとりする処理がある場合にはInteractorオブジェクトパターンを検討する。(interactor gemを導入しているのでそれを使う)
- 複数のInteractorを実行するような処理がある場合Organizerオブジェクトパターンを検討する。(interactor gemを導入しており、その中にOrganizerの機能があるので使う)
Files:
app/models/user.rbapp/controllers/home_controller.rbtest/supports/report_helper.rbapp/models/user_study_streak.rbapp/controllers/users_controller.rbtest/models/user_test.rbapp/components/study_streak/user_study_streak_tracker_component.rbtest/components/study_streak/user_study_streak_tracker_component_test.rbtest/models/user_study_streak_test.rb
test/**/*
⚙️ CodeRabbit configuration file
test/**/*: # Test
- TestCase名は英語で書く。
- どうしても避けられない時以外にsystem testでsleepは使わない。
Unit Test
model, helper, decorator, view_componentについてはメソッドを追加した場合は必ず対応したUnit TestのTestCaseを1つは書く。
Files:
test/supports/report_helper.rbtest/models/user_test.rbtest/components/study_streak/user_study_streak_tracker_component_test.rbtest/models/user_study_streak_test.rb
🧬 Code graph analysis (5)
app/controllers/home_controller.rb (1)
app/models/user.rb (1)
reports_with_learning_times(929-931)
app/controllers/users_controller.rb (1)
app/models/user.rb (1)
reports_with_learning_times(929-931)
test/models/user_test.rb (1)
app/models/user.rb (1)
reports_with_learning_times(929-931)
test/components/study_streak/user_study_streak_tracker_component_test.rb (3)
test/models/user_study_streak_test.rb (1)
include(6-85)test/supports/report_helper.rb (1)
create_report_data_with_learning_times(48-58)app/models/user.rb (1)
reports_with_learning_times(929-931)
test/models/user_study_streak_test.rb (2)
test/supports/report_helper.rb (1)
create_report_data_with_learning_times(48-58)app/models/user.rb (1)
reports_with_learning_times(929-931)
🔇 Additional comments (10)
app/javascript/stylesheets/application.sass (1)
124-124: LGTM!新しいスタイルシートのインポートが適切に追加されています。他のユーザーブロックのインポートと同じセクションに配置されており、一貫性があります。
app/views/home/index.html.slim (1)
41-42: LGTM!学習時間が存在する場合のみコンポーネントを描画する条件分岐が適切です。ViewComponentパターンに従っており、コーディングガイドラインに準拠しています。
app/models/user.rb (1)
929-931: LGTM!学習時間を持つ日報を効率的に取得するメソッドが適切に実装されています。
joinsを使用することでN+1クエリを回避し、distinctで重複を排除し、reported_onで昇順にソートしています。app/controllers/users_controller.rb (1)
48-49: 空のレポートコレクションに対する動作を確認してください。
HomeControllerと同様に、reports_with_learning_timesが空の結果を返した場合でもUserStudyStreakが適切に処理できることを確認してください。HomeControllerで提案したスクリプトを実行して、
UserStudyStreakの実装を確認してください。app/components/study_streak/user_study_streak_tracker_component.html.slim (1)
1-31: LGTM!学習連続記録を表示するコンポーネントテンプレートが適切に実装されています。以下の点が優れています:
- 意味的に明確なHTML構造
- SASSファイルで定義されたCSSクラスとの整合性
- 期間情報の条件付き表示(Lines 17-19, 29-31)
- わかりやすい日本語ラベル
ViewComponentパターンに従っており、コーディングガイドラインに準拠しています。
test/models/user_test.rb (1)
60-73: LGTM!
#reports_with_learning_timesメソッドのテストが包括的に実装されています。以下のシナリオを適切にカバーしています:
- 初期状態(空のコレクション)
- 学習時間を持つ日報の取得
no_learn: trueの日報の除外テスト名が英語であることもコーディングガイドラインに準拠しています。
app/controllers/home_controller.rb (1)
13-13:UserStudyStreakは空のレポートを正しく処理します
空のreports_with_learning_timesを渡した場合でも内部で空配列や nil を扱うため、追加の検証や null チェックは不要です。app/views/users/show.html.slim (2)
67-68: 描画条件は妥当ですが、@study_streak のセットを確認してくださいUsersController#show(およびダッシュボード側)で必ず @study_streak をセットしていることをご確認ください。ガードはあるため未設定時でも例外にはなりませんが、将来の変更で意図せず参照されるリスクを減らせます。
101-120: 管理者向けカードの移動 OK表示条件と構造は問題ありません。career_path が nil の場合の表示についてだけ、翻訳キーの存在/フォールバックをご確認ください(translation missing が出ないこと)。
app/components/study_streak/user_study_streak_tracker_component.rb (1)
3-38: ViewComponentのパターンに沿った適切な実装ですコンポーネントの構造は明確で、各メソッドが単一の責務を持っています。
study_streakオブジェクトへの委譲と、防御的な.to_iによる変換も適切です。
d3e1f80 to
ce55112
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
app/components/study_streak/user_study_streak_tracker_component.rb(1 hunks)test/components/study_streak/user_study_streak_tracker_component_test.rb(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- app/components/study_streak/user_study_streak_tracker_component.rb
🧰 Additional context used
📓 Path-based instructions (2)
**/*.rb
⚙️ CodeRabbit configuration file
**/*.rb: # refactoring
- まずFat Controllerを避け、次にFat Modelを避ける。
- Serviceクラスの乱用を避ける。
- controller concernを作ろうとしたらPORO(Plain Old Ruby Object)やActiveRecordモデルでの実装で代替できないか検討する。
Rails Patterns
- ViewHelperにメソッドを実装する時にはまずDecoratorパターンを使うことを検討する。(active_decorator gemを導入しているのでそれを使う)
- 複雑なActiveRecordクエリがあり、再利用できそうな場合はQueryObjectパターンを検討する。(rails-patterns gemを導入しているのでそれのQuery機能を使う)
- Viewにpartialを作る場合はViewComponentを使うことを検討する。
- 複数のActiveRecordモデルを操作する1つの責務がある時や外部APIとやりとりする処理がある場合にはInteractorオブジェクトパターンを検討する。(interactor gemを導入しているのでそれを使う)
- 複数のInteractorを実行するような処理がある場合Organizerオブジェクトパターンを検討する。(interactor gemを導入しており、その中にOrganizerの機能があるので使う)
Files:
test/components/study_streak/user_study_streak_tracker_component_test.rb
test/**/*
⚙️ CodeRabbit configuration file
test/**/*: # Test
- TestCase名は英語で書く。
- どうしても避けられない時以外にsystem testでsleepは使わない。
Unit Test
model, helper, decorator, view_componentについてはメソッドを追加した場合は必ず対応したUnit TestのTestCaseを1つは書く。
Files:
test/components/study_streak/user_study_streak_tracker_component_test.rb
🧬 Code graph analysis (1)
test/components/study_streak/user_study_streak_tracker_component_test.rb (3)
test/models/user_study_streak_test.rb (1)
include(6-85)test/supports/report_helper.rb (1)
create_report_data_with_learning_times(48-58)app/models/user.rb (1)
reports_with_learning_times(929-931)
⏰ 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). (1)
- GitHub Check: build_and_test
🔇 Additional comments (1)
test/components/study_streak/user_study_streak_tracker_component_test.rb (1)
24-26: teardown の追加、LGTM!以前のレビューで指摘された
travel_toのクリーンアップが適切に実装されています。テスト間の時刻リークを防ぐことができます。
test/components/study_streak/user_study_streak_tracker_component_test.rb
Show resolved
Hide resolved
ce55112 to
629c96b
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
app/components/study_streak/user_study_streak_tracker_component.rb (1)
45-46: 冗長な変数代入を削除可能
start_onとend_onをローカル変数start_dateとend_dateに代入していますが、パラメータを直接使用できます。以下の diff を適用して簡潔にできます:
def format_period(days:, start_on:, end_on:) return '' if days.to_i.zero? || start_on.nil? || end_on.nil? - start_date = start_on - end_date = end_on current_year = Time.zone.today.year - if start_date.year == end_date.year && start_date.year == current_year - "#{start_date.strftime('%m/%d')} 〜 #{end_date.strftime('%m/%d')}" + if start_on.year == end_on.year && start_on.year == current_year + "#{start_on.strftime('%m/%d')} 〜 #{end_on.strftime('%m/%d')}" else - "#{start_date.strftime('%Y/%m/%d')} 〜 #{end_date.strftime('%Y/%m/%d')}" + "#{start_on.strftime('%Y/%m/%d')} 〜 #{end_on.strftime('%Y/%m/%d')}" end end
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
app/components/study_streak/user_study_streak_tracker_component.rb(1 hunks)test/components/study_streak/user_study_streak_tracker_component_test.rb(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- test/components/study_streak/user_study_streak_tracker_component_test.rb
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rb
⚙️ CodeRabbit configuration file
**/*.rb: # refactoring
- まずFat Controllerを避け、次にFat Modelを避ける。
- Serviceクラスの乱用を避ける。
- controller concernを作ろうとしたらPORO(Plain Old Ruby Object)やActiveRecordモデルでの実装で代替できないか検討する。
Rails Patterns
- ViewHelperにメソッドを実装する時にはまずDecoratorパターンを使うことを検討する。(active_decorator gemを導入しているのでそれを使う)
- 複雑なActiveRecordクエリがあり、再利用できそうな場合はQueryObjectパターンを検討する。(rails-patterns gemを導入しているのでそれのQuery機能を使う)
- Viewにpartialを作る場合はViewComponentを使うことを検討する。
- 複数のActiveRecordモデルを操作する1つの責務がある時や外部APIとやりとりする処理がある場合にはInteractorオブジェクトパターンを検討する。(interactor gemを導入しているのでそれを使う)
- 複数のInteractorを実行するような処理がある場合Organizerオブジェクトパターンを検討する。(interactor gemを導入しており、その中にOrganizerの機能があるので使う)
Files:
app/components/study_streak/user_study_streak_tracker_component.rb
⏰ 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). (1)
- GitHub Check: build_and_test
🔇 Additional comments (1)
app/components/study_streak/user_study_streak_tracker_component.rb (1)
3-53: LGTM! ViewComponent の実装は適切ですこのコンポーネントの設計は以下の点で良好です:
- コーディングガイドラインに従い、partial の代わりに ViewComponent を使用している
- 表示ロジックをコンポーネントに集約し、責務が明確
format_periodメソッドで期間フォーマットのロジックを一箇所にまとめている.to_iを使用した防御的なコーディングにより、nil 値を安全に扱っている- タイムゾーンを考慮して
Time.zone.todayを使用している連続学習記録の表示機能として、適切に実装されています。
629c96b to
244a441
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (14)
app/components/study_streak/user_study_streak_tracker_component.html.slim(1 hunks)app/components/study_streak/user_study_streak_tracker_component.rb(1 hunks)app/controllers/home_controller.rb(1 hunks)app/controllers/users_controller.rb(1 hunks)app/javascript/stylesheets/application.sass(1 hunks)app/javascript/stylesheets/application/blocks/user/_user-study-streak-tracker.sass(1 hunks)app/models/user.rb(1 hunks)app/models/user_study_streak.rb(1 hunks)app/views/home/index.html.slim(1 hunks)app/views/users/show.html.slim(2 hunks)test/components/study_streak/user_study_streak_tracker_component_test.rb(1 hunks)test/models/user_study_streak_test.rb(1 hunks)test/models/user_test.rb(1 hunks)test/supports/report_helper.rb(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (9)
- test/supports/report_helper.rb
- app/models/user_study_streak.rb
- app/javascript/stylesheets/application/blocks/user/_user-study-streak-tracker.sass
- test/models/user_study_streak_test.rb
- test/components/study_streak/user_study_streak_tracker_component_test.rb
- app/controllers/home_controller.rb
- app/javascript/stylesheets/application.sass
- app/controllers/users_controller.rb
- app/components/study_streak/user_study_streak_tracker_component.html.slim
🧰 Additional context used
📓 Path-based instructions (2)
**/*.rb
⚙️ CodeRabbit configuration file
**/*.rb: # refactoring
- まずFat Controllerを避け、次にFat Modelを避ける。
- Serviceクラスの乱用を避ける。
- controller concernを作ろうとしたらPORO(Plain Old Ruby Object)やActiveRecordモデルでの実装で代替できないか検討する。
Rails Patterns
- ViewHelperにメソッドを実装する時にはまずDecoratorパターンを使うことを検討する。(active_decorator gemを導入しているのでそれを使う)
- 複雑なActiveRecordクエリがあり、再利用できそうな場合はQueryObjectパターンを検討する。(rails-patterns gemを導入しているのでそれのQuery機能を使う)
- Viewにpartialを作る場合はViewComponentを使うことを検討する。
- 複数のActiveRecordモデルを操作する1つの責務がある時や外部APIとやりとりする処理がある場合にはInteractorオブジェクトパターンを検討する。(interactor gemを導入しているのでそれを使う)
- 複数のInteractorを実行するような処理がある場合Organizerオブジェクトパターンを検討する。(interactor gemを導入しており、その中にOrganizerの機能があるので使う)
Files:
test/models/user_test.rbapp/models/user.rbapp/components/study_streak/user_study_streak_tracker_component.rb
test/**/*
⚙️ CodeRabbit configuration file
test/**/*: # Test
- TestCase名は英語で書く。
- どうしても避けられない時以外にsystem testでsleepは使わない。
Unit Test
model, helper, decorator, view_componentについてはメソッドを追加した場合は必ず対応したUnit TestのTestCaseを1つは書く。
Files:
test/models/user_test.rb
🧬 Code graph analysis (2)
test/models/user_test.rb (1)
app/models/user.rb (1)
reports_with_learning_times(929-931)
app/components/study_streak/user_study_streak_tracker_component.rb (1)
app/javascript/dateFormatter.js (1)
year(9-9)
⏰ 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). (1)
- GitHub Check: build_and_test
244a441 to
e798f39
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
app/components/study_streak/user_study_streak_tracker_component.rb (1)
45-47: 年比較のバグは解消済みで OKstart_on.year と Time.zone.today.year の比較に修正されており、意図通りです。
🧹 Nitpick comments (3)
test/supports/report_helper.rb (1)
48-58: no_learn:true 時も常に保存し、時刻生成を safer にしましょう
- no_learn:true の場合に未保存の Report を返すのは挙動が揺れてテストの落とし穴になりがちです。常に保存を推奨。
- 時刻は文字列 parse より Time.zone.local の方が DST に強く、意図が明確です。
- def create_report_data_with_learning_times(user:, on:, wip: false, no_learn: false, durations: [[9, 12]]) - report = Report.new(user:, title: "test #{on}", emotion: 2, description: 'desc', reported_on: on, wip:, no_learn:) - unless no_learn - durations.each do |(s, e)| - report.learning_times << LearningTime.new(report:, started_at: Time.zone.parse("#{on} #{format('%02d:00:00', s)}"), - finished_at: Time.zone.parse("#{on} #{format('%02d:00:00', e)}")) - end - report.save! - end - report - end + def create_report_data_with_learning_times(user:, on:, wip: false, no_learn: false, durations: [[9, 12]]) + report = Report.new(user:, title: "test #{on}", emotion: 2, description: 'desc', reported_on: on, wip:, no_learn:) + unless no_learn + durations.each do |(s, e)| + # s < e を前提。必要なら guard を追加。 + started = Time.zone.local(on.year, on.month, on.day, s, 0, 0) + finished = Time.zone.local(on.year, on.month, on.day, e, 0, 0) + report.learning_times.build(started_at: started, finished_at: finished) + end + end + report.save! + report + endapp/views/users/show.html.slim (1)
101-120: 「卒業後の進路」カードの重複表示がないか再確認同様のカードが他の分岐や部分テンプレートでも表示されていないか確認してください。重複なら片方へ統一を。
app/controllers/home_controller.rb (1)
13-13: 必要時のみ @study_streak を生成して無駄を削減表示条件に合わせて生成を条件分岐すると軽量です。
- @study_streak = UserStudyStreak.new(current_user.reports_with_learning_times, include_wip: false) + if current_user.total_learning_time.positive? + @study_streak = UserStudyStreak.new(current_user.reports_with_learning_times, include_wip: false) + end
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
app/components/study_streak/user_study_streak_tracker_component.html.slim(1 hunks)app/components/study_streak/user_study_streak_tracker_component.rb(1 hunks)app/controllers/home_controller.rb(1 hunks)app/javascript/stylesheets/application.sass(1 hunks)app/javascript/stylesheets/application/blocks/user/_user-study-streak-tracker.sass(1 hunks)app/views/home/index.html.slim(1 hunks)app/views/users/show.html.slim(2 hunks)test/components/study_streak/user_study_streak_tracker_component_test.rb(1 hunks)test/models/user_study_streak_test.rb(1 hunks)test/models/user_test.rb(1 hunks)test/supports/report_helper.rb(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- app/javascript/stylesheets/application.sass
🚧 Files skipped from review as they are similar to previous changes (2)
- app/javascript/stylesheets/application/blocks/user/_user-study-streak-tracker.sass
- test/models/user_test.rb
🧰 Additional context used
📓 Path-based instructions (2)
**/*.rb
⚙️ CodeRabbit configuration file
**/*.rb: # refactoring
- まずFat Controllerを避け、次にFat Modelを避ける。
- Serviceクラスの乱用を避ける。
- controller concernを作ろうとしたらPORO(Plain Old Ruby Object)やActiveRecordモデルでの実装で代替できないか検討する。
Rails Patterns
- ViewHelperにメソッドを実装する時にはまずDecoratorパターンを使うことを検討する。(active_decorator gemを導入しているのでそれを使う)
- 複雑なActiveRecordクエリがあり、再利用できそうな場合はQueryObjectパターンを検討する。(rails-patterns gemを導入しているのでそれのQuery機能を使う)
- Viewにpartialを作る場合はViewComponentを使うことを検討する。
- 複数のActiveRecordモデルを操作する1つの責務がある時や外部APIとやりとりする処理がある場合にはInteractorオブジェクトパターンを検討する。(interactor gemを導入しているのでそれを使う)
- 複数のInteractorを実行するような処理がある場合Organizerオブジェクトパターンを検討する。(interactor gemを導入しており、その中にOrganizerの機能があるので使う)
Files:
app/controllers/home_controller.rbapp/components/study_streak/user_study_streak_tracker_component.rbtest/components/study_streak/user_study_streak_tracker_component_test.rbtest/models/user_study_streak_test.rbtest/supports/report_helper.rb
test/**/*
⚙️ CodeRabbit configuration file
test/**/*: # Test
- TestCase名は英語で書く。
- どうしても避けられない時以外にsystem testでsleepは使わない。
Unit Test
model, helper, decorator, view_componentについてはメソッドを追加した場合は必ず対応したUnit TestのTestCaseを1つは書く。
Files:
test/components/study_streak/user_study_streak_tracker_component_test.rbtest/models/user_study_streak_test.rbtest/supports/report_helper.rb
🧬 Code graph analysis (4)
app/controllers/home_controller.rb (1)
app/models/user.rb (1)
reports_with_learning_times(929-931)
app/components/study_streak/user_study_streak_tracker_component.rb (1)
app/javascript/dateFormatter.js (1)
year(9-9)
test/components/study_streak/user_study_streak_tracker_component_test.rb (3)
test/models/user_study_streak_test.rb (1)
include(6-85)test/supports/report_helper.rb (1)
create_report_data_with_learning_times(48-58)app/models/user.rb (1)
reports_with_learning_times(929-931)
test/models/user_study_streak_test.rb (2)
test/supports/report_helper.rb (1)
create_report_data_with_learning_times(48-58)app/models/user.rb (1)
reports_with_learning_times(929-931)
⏰ 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). (1)
- GitHub Check: build_and_test
🔇 Additional comments (5)
app/views/home/index.html.slim (1)
41-42: 表示条件と Controller の初期化が整合しており問題なしtotal_learning_time > 0 の条件下での表示で妥当です。
app/views/users/show.html.slim (1)
67-68: @study_streak は show アクションで必ず初期化されているため、ビューでの presence ガードは不要です。app/components/study_streak/user_study_streak_tracker_component.html.slim (1)
1-31: LGTM! テンプレート構造が適切ですViewComponent のテンプレートとして適切な実装です。条件付きレンダリング(lines 17-19, 29-31)により、連続記録が0日の場合に期間を表示しないようにしており、良い設計です。
test/models/user_study_streak_test.rb (1)
1-85: LGTM! 包括的なテストカバレッジですUserStudyStreak モデルのテストとして優れた実装です:
- 連続記録の期間計算、最長記録の判定(同率時は最新を選択)、学習日なしのケース、WIP日報の扱いなど、重要なシナリオが網羅されています
- ReportHelper を活用したテストデータ作成により、テストの可読性と保守性が高まっています
- private メソッド
streak_periodsへのsend()によるアクセスは、テストコンテキストでは許容される手法ですtest/components/study_streak/user_study_streak_tracker_component_test.rb (1)
1-93: LGTM! ViewComponent の表示ロジックが十分にテストされていますStudyStreak::UserStudyStreakTrackerComponent のテストとして優れた実装です:
- レンダリング結果の検証(現在の記録、最長記録、ゼロ状態)が適切に行われています
- CSS クラス構造の検証により、スタイリングの安定性が担保されています
- 日付フォーマットのテスト(当年・過去年・年跨ぎ)により、表示ロジックの正確性が確認されています
- teardown での
travel_backにより、テスト間の時刻リークが防止されています
6abe43f to
21a4b8d
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
app/components/study_streak/user_study_streak_tracker_component.html.slim(1 hunks)app/components/study_streak/user_study_streak_tracker_component.rb(1 hunks)app/controllers/home_controller.rb(1 hunks)app/javascript/stylesheets/application/blocks/user/_user-study-streak-tracker.sass(1 hunks)app/views/home/index.html.slim(1 hunks)app/views/users/show.html.slim(2 hunks)test/components/study_streak/user_study_streak_tracker_component_test.rb(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- app/components/study_streak/user_study_streak_tracker_component.html.slim
🚧 Files skipped from review as they are similar to previous changes (1)
- app/views/home/index.html.slim
🧰 Additional context used
📓 Path-based instructions (2)
**/*.rb
⚙️ CodeRabbit configuration file
**/*.rb: # refactoring
- まずFat Controllerを避け、次にFat Modelを避ける。
- Serviceクラスの乱用を避ける。
- controller concernを作ろうとしたらPORO(Plain Old Ruby Object)やActiveRecordモデルでの実装で代替できないか検討する。
Rails Patterns
- ViewHelperにメソッドを実装する時にはまずDecoratorパターンを使うことを検討する。(active_decorator gemを導入しているのでそれを使う)
- 複雑なActiveRecordクエリがあり、再利用できそうな場合はQueryObjectパターンを検討する。(rails-patterns gemを導入しているのでそれのQuery機能を使う)
- Viewにpartialを作る場合はViewComponentを使うことを検討する。
- 複数のActiveRecordモデルを操作する1つの責務がある時や外部APIとやりとりする処理がある場合にはInteractorオブジェクトパターンを検討する。(interactor gemを導入しているのでそれを使う)
- 複数のInteractorを実行するような処理がある場合Organizerオブジェクトパターンを検討する。(interactor gemを導入しており、その中にOrganizerの機能があるので使う)
Files:
app/controllers/home_controller.rbapp/components/study_streak/user_study_streak_tracker_component.rbtest/components/study_streak/user_study_streak_tracker_component_test.rb
test/**/*
⚙️ CodeRabbit configuration file
test/**/*: # Test
- TestCase名は英語で書く。
- どうしても避けられない時以外にsystem testでsleepは使わない。
Unit Test
model, helper, decorator, view_componentについてはメソッドを追加した場合は必ず対応したUnit TestのTestCaseを1つは書く。
Files:
test/components/study_streak/user_study_streak_tracker_component_test.rb
🧬 Code graph analysis (2)
app/controllers/home_controller.rb (1)
app/models/user.rb (1)
reports_with_learning_times(929-931)
test/components/study_streak/user_study_streak_tracker_component_test.rb (3)
test/models/user_study_streak_test.rb (1)
include(6-85)test/supports/report_helper.rb (1)
create_report_data_with_learning_times(48-58)app/models/user.rb (1)
reports_with_learning_times(929-931)
⏰ 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). (1)
- GitHub Check: build_and_test
app/javascript/stylesheets/application/blocks/user/_user-study-streak-tracker.sass
Show resolved
Hide resolved
|
@smallmonkeykey |
|
@jun-kondo |
|
@smallmonkeykey
了解しましたー。何卒よろしくお願いいたします🙇♂️ |
|
@jun-kondo 一点、動作確認の際に気になったのですが、日報を作成したときに画像のエラーが出るようでした。 |
|
@komagata |
- 日報を学習時間で関連付けて取得 - 昇順でソートされたユニークな結果を返す
- UserStudyStreakインスタンスを作成し@study_streakに設定 - reports_with_learning_timesメソッドを使用
- 学習時間データを含む日報を作成するヘルパーメソッドを追加しテストで使用する
- user-study-streak-tracker用のSassファイルを新規作成し、スタイルを定義 - application.sassにインポートを追加
9cdc059 to
19cc1ba
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
app/controllers/home_controller.rb (1)
38-54:@study_streak初期化は表示条件に合わせてガードしたい(無駄クエリ/負荷)Line 53 は常に
current_user.reports_with_learning_times(JOIN + DISTINCT + ORDER)を発行するので、ダッシュボード側でストリークを表示しないユーザー(例: メンター/管理者/学習時間0)でもコストが発生します。表示条件がビュー側にある前提なら、コントローラ側も同条件で包む(または遅延初期化)方が安全です。def display_dashboard ... - @study_streak = StudyStreak.new(current_user.reports_with_learning_times, include_wip: false) + if current_user.student_or_trainee? && current_user.total_learning_time.positive? + @study_streak = StudyStreak.new(current_user.reports_with_learning_times, include_wip: false) + end end
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
app/components/study_streak/study_streak_tracker_component.html.slim(1 hunks)app/components/study_streak/study_streak_tracker_component.rb(1 hunks)app/controllers/home_controller.rb(1 hunks)app/controllers/users_controller.rb(1 hunks)app/javascript/stylesheets/application.sass(1 hunks)app/javascript/stylesheets/application/blocks/user/_user-study-streak-tracker.sass(1 hunks)app/models/study_streak.rb(1 hunks)app/models/user.rb(1 hunks)app/views/home/index.html.slim(1 hunks)app/views/users/show.html.slim(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
- app/models/user.rb
- app/javascript/stylesheets/application.sass
- app/components/study_streak/study_streak_tracker_component.html.slim
- app/controllers/users_controller.rb
- app/components/study_streak/study_streak_tracker_component.rb
- app/javascript/stylesheets/application/blocks/user/_user-study-streak-tracker.sass
- app/models/study_streak.rb
- app/views/home/index.html.slim
🧰 Additional context used
📓 Path-based instructions (3)
app/**/*.{rb,js,ts,jsx,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Rails app code should be organized in
app/directory with subdirectories:models/,controllers/,views/,jobs/,helpers/, and frontend code underjavascript/(Shakapacker)
Files:
app/controllers/home_controller.rb
**/*.rb
📄 CodeRabbit inference engine (AGENTS.md)
Ruby code should use 2-space indentation, snake_case for method names, and CamelCase for class names, enforced by RuboCop (
.rubocop.yml)
Files:
app/controllers/home_controller.rb
⚙️ CodeRabbit configuration file
**/*.rb: # refactoring
- まずFat Controllerを避け、次にFat Modelを避ける。
- Serviceクラスの乱用を避ける。
- controller concernを作ろうとしたらPORO(Plain Old Ruby Object)やActiveRecordモデルでの実装で代替できないか検討する。
Rails Patterns
- ViewHelperにメソッドを実装する時にはまずDecoratorパターンを使うことを検討する。(active_decorator gemを導入しているのでそれを使う)
- 複雑なActiveRecordクエリがあり、再利用できそうな場合はQueryObjectパターンを検討する。(rails-patterns gemを導入しているのでそれのQuery機能を使う)
- Viewにpartialを作る場合はViewComponentを使うことを検討する。
- 複数のActiveRecordモデルを操作する1つの責務がある時や外部APIとやりとりする処理がある場合にはInteractorオブジェクトパターンを検討する。(interactor gemを導入しているのでそれを使う)
- 複数のInteractorを実行するような処理がある場合Organizerオブジェクトパターンを検討する。(interactor gemを導入しており、その中にOrganizerの機能があるので使う)
Files:
app/controllers/home_controller.rb
**/*.slim
📄 CodeRabbit inference engine (AGENTS.md)
Slim templates should be linted according to
config/slim_lint.yml
Files:
app/views/users/show.html.slim
🧠 Learnings (4)
📚 Learning: 2025-08-31T03:39:07.792Z
Learnt from: mousu-a
Repo: fjordllc/bootcamp PR: 8566
File: app/views/pair_works/_body.html.slim:85-85
Timestamp: 2025-08-31T03:39:07.792Z
Learning: app/views/pair_works/_body.html.slimテンプレートには2つの独立したif pair_work.solved?条件分岐があり、user変数は最初の分岐でのみ設定されるため、2番目の分岐での参照には注意が必要。
Applied to files:
app/views/users/show.html.slim
📚 Learning: 2025-08-28T00:34:28.541Z
Learnt from: mousu-a
Repo: fjordllc/bootcamp PR: 8566
File: app/views/application/_global_nav.slim:48-54
Timestamp: 2025-08-28T00:34:28.541Z
Learning: app/views/application/_global_nav.slim のQ&A/ペアワークバッジの環境分岐は、ペアワーク機能の本番リリース後に削除される一時的な実装である。その際、メンター・管理者のみに表示する制限仕様も撤廃される予定のため、現在の実装にはアクセス権限ガードを追加する必要がない。
Applied to files:
app/views/users/show.html.slim
📚 Learning: 2025-08-31T12:08:33.904Z
Learnt from: thmz337
Repo: fjordllc/bootcamp PR: 9103
File: app/views/generations/_user.html.slim:6-14
Timestamp: 2025-08-31T12:08:33.904Z
Learning: app/views/generations/_user.html.slimの非アクティブメッセージ表示では、退会・休会・非アクティブの3つの条件が独立して評価され、複数のメッセージが同時に表示される仕様になっている。これは意図的な設計である。
Applied to files:
app/views/users/show.html.slim
📚 Learning: 2025-09-01T22:31:57.345Z
Learnt from: matuaya
Repo: fjordllc/bootcamp PR: 9108
File: app/models/after_user_retirement.rb:0-0
Timestamp: 2025-09-01T22:31:57.345Z
Learning: fjordllc/bootcampプロジェクトにおいて、`Newspaper.publish(:retirement_create, { user: user })`はUnfinishedDataDestroyer(未チェックProduct・WIP Report削除、career_pathリセット)とTimesChannelDestroyer(Discord分報チャンネル削除)による重要なデータクリーンアップ処理を実行するため、退会のトリガーが何であろうと(admin、hibernation、user)必ず実行する必要がある。
Applied to files:
app/views/users/show.html.slim
🧬 Code graph analysis (1)
app/controllers/home_controller.rb (1)
app/models/user.rb (1)
reports_with_learning_times(956-958)
🔇 Additional comments (1)
app/views/users/show.html.slim (1)
67-68: 削除推奨:@study_streakは正しく@userベースで初期化されており、懸念は根拠がありませんUsersController#showでは
reports = @user.reports_with_learning_timesとして明示的に@userのレポートから初期化され、その直後に@study_streak = StudyStreak.new(reports, include_wip: false)として設定されています。加えて、StudyStreak::StudyStreakTrackerComponentは.to_i.positive?や.blank?による防御的なチェックを備えており、nil値に対して安全に処理されます。変数のスコープと初期化の流れは正確で、別ユーザーのデータが混入するリスクはありません。Likely an incorrect or invalid review comment.
- 現在の年では「mm/dd 〜 mm/dd」のフォーマットを、開始と終了が異なる年や過去の年では「yyyy/mm/dd 〜 yyyy/mm/dd」を適用 - 日付のフォーマットはlocaleファイルのものを使用 - 関連する単体テストを追加および修正
19cc1ba to
03aa758
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (1)
app/views/users/show.html.slim (1)
101-107:career_pathが nil/空のときに MissingTranslation になり得ます(ガード or default を追加してください)過去コメントと同様、
t("activerecord.enums.user.career_path.#{@user.career_path}")は@user.career_pathが未設定だとコケやすいです。default:かpresent?ガードを入れるのが安全です。- | (#{t("activerecord.enums.user.career_path.#{@user.career_path}")}) + - career_path_key = @user.career_path.presence && "activerecord.enums.user.career_path.#{@user.career_path}" + | (#{career_path_key ? t(career_path_key) : '未設定'})
🧹 Nitpick comments (2)
test/models/study_streak_test.rb (1)
31-41:send(:streak_periods)依存は将来のリファクタで壊れやすいので、可能なら公開API経由に寄せたいです内部実装変更に引きずられやすいので、もし
StudyStreak側に期間一覧を返す読み取り専用の public メソッドを用意できるなら、そこ経由での検証にすると安定します(将来的な話でOK)。test/components/study_streak/study_streak_tracker_component_test.rb (1)
72-95:travel_toの入れ子が増えると読みづらくなるので、ブロック形式に寄せるのも手です現状でも
teardownがあるので壊れませんが、読みやすさ重視ならこの形も検討できます。- test 'date format follows "yyyy/mm/dd 〜 yyyy/mm/dd" pattern for a past year' do - travel_to Time.zone.local(2025, 1, 1) - render_inline(StudyStreak::StudyStreakTrackerComponent.new(study_streak: @study_streak)) - assert_selector '.streak-item__period', text: '2024/08/20 〜 2024/08/22' - end + test 'date format follows "yyyy/mm/dd 〜 yyyy/mm/dd" pattern for a past year' do + travel_to Time.zone.local(2025, 1, 1) do + render_inline(StudyStreak::StudyStreakTrackerComponent.new(study_streak: @study_streak)) + assert_selector '.streak-item__period', text: '2024/08/20 〜 2024/08/22' + end + end
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
app/components/study_streak/study_streak_tracker_component.html.slim(1 hunks)app/components/study_streak/study_streak_tracker_component.rb(1 hunks)app/controllers/home_controller.rb(1 hunks)app/controllers/users_controller.rb(1 hunks)app/javascript/stylesheets/application/blocks/user/_user-study-streak-tracker.sass(1 hunks)app/models/study_streak.rb(1 hunks)app/views/home/index.html.slim(1 hunks)app/views/users/show.html.slim(2 hunks)test/components/study_streak/study_streak_tracker_component_test.rb(1 hunks)test/models/study_streak_test.rb(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
- app/controllers/home_controller.rb
- app/views/home/index.html.slim
- app/models/study_streak.rb
- app/controllers/users_controller.rb
- app/javascript/stylesheets/application/blocks/user/_user-study-streak-tracker.sass
🧰 Additional context used
📓 Path-based instructions (6)
app/**/*.{rb,js,ts,jsx,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Rails app code should be organized in
app/directory with subdirectories:models/,controllers/,views/,jobs/,helpers/, and frontend code underjavascript/(Shakapacker)
Files:
app/components/study_streak/study_streak_tracker_component.rb
**/*.rb
📄 CodeRabbit inference engine (AGENTS.md)
Ruby code should use 2-space indentation, snake_case for method names, and CamelCase for class names, enforced by RuboCop (
.rubocop.yml)
Files:
app/components/study_streak/study_streak_tracker_component.rbtest/models/study_streak_test.rbtest/components/study_streak/study_streak_tracker_component_test.rb
⚙️ CodeRabbit configuration file
**/*.rb: # refactoring
- まずFat Controllerを避け、次にFat Modelを避ける。
- Serviceクラスの乱用を避ける。
- controller concernを作ろうとしたらPORO(Plain Old Ruby Object)やActiveRecordモデルでの実装で代替できないか検討する。
Rails Patterns
- ViewHelperにメソッドを実装する時にはまずDecoratorパターンを使うことを検討する。(active_decorator gemを導入しているのでそれを使う)
- 複雑なActiveRecordクエリがあり、再利用できそうな場合はQueryObjectパターンを検討する。(rails-patterns gemを導入しているのでそれのQuery機能を使う)
- Viewにpartialを作る場合はViewComponentを使うことを検討する。
- 複数のActiveRecordモデルを操作する1つの責務がある時や外部APIとやりとりする処理がある場合にはInteractorオブジェクトパターンを検討する。(interactor gemを導入しているのでそれを使う)
- 複数のInteractorを実行するような処理がある場合Organizerオブジェクトパターンを検討する。(interactor gemを導入しており、その中にOrganizerの機能があるので使う)
Files:
app/components/study_streak/study_streak_tracker_component.rbtest/models/study_streak_test.rbtest/components/study_streak/study_streak_tracker_component_test.rb
**/*.slim
📄 CodeRabbit inference engine (AGENTS.md)
Slim templates should be linted according to
config/slim_lint.yml
Files:
app/views/users/show.html.slimapp/components/study_streak/study_streak_tracker_component.html.slim
test/**/*_test.rb
📄 CodeRabbit inference engine (AGENTS.md)
test/**/*_test.rb: Test suite should use Minitest with structure:system/,models/,controllers/, and fixtures intest/fixtures/; test files should be named*_test.rb
Use Minitest + Capybara for system tests; place unit and integration tests under matchingtest/*directories
Files:
test/models/study_streak_test.rbtest/components/study_streak/study_streak_tracker_component_test.rb
test/**
📄 CodeRabbit inference engine (AGENTS.md)
Keep tests deterministic and use fixtures stored in
test/fixtures/for test data
Files:
test/models/study_streak_test.rbtest/components/study_streak/study_streak_tracker_component_test.rb
test/**/*
⚙️ CodeRabbit configuration file
test/**/*: # Test
- TestCase名は英語で書く。
- どうしても避けられない時以外にsystem testでsleepは使わない。
Unit Test
model, helper, decorator, view_componentについてはメソッドを追加した場合は必ず対応したUnit TestのTestCaseを1つは書く。
Files:
test/models/study_streak_test.rbtest/components/study_streak/study_streak_tracker_component_test.rb
🧠 Learnings (13)
📚 Learning: 2025-06-29T03:44:15.179Z
Learnt from: hirokiej
Repo: fjordllc/bootcamp PR: 8740
File: app/helpers/reports_helper.rb:56-64
Timestamp: 2025-06-29T03:44:15.179Z
Learning: このプロジェクト(fjordllc/bootcamp)では、ja.ymlファイルで一部の単語や文章のみI18n対応されているが、多くのテキストは日本語でハードコーディングされており、完全な国際化対応は行われていない。新しい機能でもI18n対応は不要と判断される。
Applied to files:
app/components/study_streak/study_streak_tracker_component.rb
📚 Learning: 2025-09-04T01:39:22.261Z
Learnt from: Miya096jp
Repo: fjordllc/bootcamp PR: 9102
File: app/controllers/mentor/buzzes_controller.rb:0-0
Timestamp: 2025-09-04T01:39:22.261Z
Learning: fjordllc/bootcamp プロジェクトでは、更新処理の成功時の通知メッセージについて、I18n を使用せずに日本語文字列を直接記述する方針で一貫性を保っている。
Applied to files:
app/components/study_streak/study_streak_tracker_component.rb
📚 Learning: 2025-07-23T20:42:19.974Z
Learnt from: jun-kondo
Repo: fjordllc/bootcamp PR: 0
File: :0-0
Timestamp: 2025-07-23T20:42:19.974Z
Learning: fjordllc/bootcampプロジェクトでは、hタグ(見出し)の文言は日本語でハードコーディングする方針が確立されており、I18n対応は行わない。例:app/views/welcome/logo.html.slimでh2、h3タグが日本語でハードコーディングされている。
Applied to files:
app/components/study_streak/study_streak_tracker_component.rb
📚 Learning: 2025-11-13T09:20:36.030Z
Learnt from: ryufuta
Repo: fjordllc/bootcamp PR: 9115
File: db/migrate/20250902024949_add_unique_index_to_correct_answers.rb:1-5
Timestamp: 2025-11-13T09:20:36.030Z
Learning: fjordllc/bootcamp プロジェクトでは、データの整合性を保つためのデータ修正には data-migrate gem を使用し、db/data/ ディレクトリ配下にデータマイグレーションファイルを作成する運用を採用している。スキーマ変更(db/migrate/)とデータ変更(db/data/)を分離することで、より安全で管理しやすい構成を実現している。
Applied to files:
app/components/study_streak/study_streak_tracker_component.rb
📚 Learning: 2025-07-07T05:28:03.676Z
Learnt from: su-su-su-su
Repo: fjordllc/bootcamp PR: 0
File: :0-0
Timestamp: 2025-07-07T05:28:03.676Z
Learning: fjordllc/bootcampプロジェクトでは、fixtureファイル内のERB構文で改行制御文字(-)は使用せず、標準的な<% %>と<%= %>のみを使用する方針が統一されている。<% -%>や<%- %>を使用するとSyntaxErrorが発生する。
Applied to files:
app/components/study_streak/study_streak_tracker_component.rbtest/components/study_streak/study_streak_tracker_component_test.rb
📚 Learning: 2025-08-28T00:34:28.541Z
Learnt from: mousu-a
Repo: fjordllc/bootcamp PR: 8566
File: app/views/application/_global_nav.slim:48-54
Timestamp: 2025-08-28T00:34:28.541Z
Learning: app/views/application/_global_nav.slim のQ&A/ペアワークバッジの環境分岐は、ペアワーク機能の本番リリース後に削除される一時的な実装である。その際、メンター・管理者のみに表示する制限仕様も撤廃される予定のため、現在の実装にはアクセス権限ガードを追加する必要がない。
Applied to files:
app/views/users/show.html.slim
📚 Learning: 2025-08-31T12:08:33.904Z
Learnt from: thmz337
Repo: fjordllc/bootcamp PR: 9103
File: app/views/generations/_user.html.slim:6-14
Timestamp: 2025-08-31T12:08:33.904Z
Learning: app/views/generations/_user.html.slimの非アクティブメッセージ表示では、退会・休会・非アクティブの3つの条件が独立して評価され、複数のメッセージが同時に表示される仕様になっている。これは意図的な設計である。
Applied to files:
app/views/users/show.html.slim
📚 Learning: 2025-08-31T03:39:07.792Z
Learnt from: mousu-a
Repo: fjordllc/bootcamp PR: 8566
File: app/views/pair_works/_body.html.slim:85-85
Timestamp: 2025-08-31T03:39:07.792Z
Learning: app/views/pair_works/_body.html.slimテンプレートには2つの独立したif pair_work.solved?条件分岐があり、user変数は最初の分岐でのみ設定されるため、2番目の分岐での参照には注意が必要。
Applied to files:
app/views/users/show.html.slim
📚 Learning: 2025-07-23T21:11:21.826Z
Learnt from: jun-kondo
Repo: fjordllc/bootcamp PR: 0
File: :0-0
Timestamp: 2025-07-23T21:11:21.826Z
Learning: fjordllc/bootcampプロジェクトの`app/models/inquiry_notifier.rb`において、`NOTIFICATION_SENDER_NAME`で指定される管理者ユーザーは必ず存在することがシステムの前提条件として保証されているため、senderがnilになることは想定されておらず、エラーハンドリングは不要である。
Applied to files:
app/views/users/show.html.slim
📚 Learning: 2025-09-01T22:31:57.345Z
Learnt from: matuaya
Repo: fjordllc/bootcamp PR: 9108
File: app/models/after_user_retirement.rb:0-0
Timestamp: 2025-09-01T22:31:57.345Z
Learning: fjordllc/bootcampプロジェクトにおいて、`Newspaper.publish(:retirement_create, { user: user })`はUnfinishedDataDestroyer(未チェックProduct・WIP Report削除、career_pathリセット)とTimesChannelDestroyer(Discord分報チャンネル削除)による重要なデータクリーンアップ処理を実行するため、退会のトリガーが何であろうと(admin、hibernation、user)必ず実行する必要がある。
Applied to files:
app/views/users/show.html.slim
📚 Learning: 2025-11-26T08:23:30.927Z
Learnt from: CR
Repo: fjordllc/bootcamp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T08:23:30.927Z
Learning: Applies to test/**/*_test.rb : Test suite should use Minitest with structure: `system/`, `models/`, `controllers/`, and fixtures in `test/fixtures/`; test files should be named `*_test.rb`
Applied to files:
test/models/study_streak_test.rbtest/components/study_streak/study_streak_tracker_component_test.rb
📚 Learning: 2025-11-26T08:23:30.927Z
Learnt from: CR
Repo: fjordllc/bootcamp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T08:23:30.927Z
Learning: Applies to test/**/*_test.rb : Use Minitest + Capybara for system tests; place unit and integration tests under matching `test/*` directories
Applied to files:
test/models/study_streak_test.rbtest/components/study_streak/study_streak_tracker_component_test.rb
📚 Learning: 2025-11-26T08:23:30.927Z
Learnt from: CR
Repo: fjordllc/bootcamp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T08:23:30.927Z
Learning: Applies to test/** : Keep tests deterministic and use fixtures stored in `test/fixtures/` for test data
Applied to files:
test/components/study_streak/study_streak_tracker_component_test.rb
🧬 Code graph analysis (3)
app/components/study_streak/study_streak_tracker_component.rb (1)
app/models/study_streak.rb (1)
initialize(6-19)
test/models/study_streak_test.rb (2)
test/supports/report_helper.rb (1)
create_report_data_with_learning_times(86-96)app/models/user.rb (1)
reports_with_learning_times(956-958)
test/components/study_streak/study_streak_tracker_component_test.rb (2)
test/supports/report_helper.rb (1)
create_report_data_with_learning_times(86-96)app/models/user.rb (1)
reports_with_learning_times(956-958)
⏰ 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). (1)
- GitHub Check: build_and_test
🔇 Additional comments (6)
app/components/study_streak/study_streak_tracker_component.html.slim (1)
1-31: テンプレート構造は分かりやすく、条件付き表示も適切です
current_streak?/longest_streak?で期間要素を出し分けていて、0日のときに余計な表示が出ない構造になっていて良いです。文言の日本語ハードコードも本プロジェクト方針に沿っています(learningsより)。test/models/study_streak_test.rb (1)
9-29: テストデータの掃除と生成が明確で、決定的になっています
reported_onを固定してdelete_all→生成 の流れが読みやすく、意図が伝わります。test/components/study_streak/study_streak_tracker_component_test.rb (1)
9-29: time travel の後始末がteardownで担保されていて安心ですapp/components/study_streak/study_streak_tracker_component.rb (2)
8-38: コンポーネントの公開APIが薄くまとまっていて良いですView からの参照メソッドが明示されていて、
to_iで表示を安定させている点も良いです。
42-51::sm/:shortの I18n フォーマット定義はconfig/locales/ja.ymlに存在するため問題ありません
date.formats.sm('%m/%d')、date.formats.short('%Y/%m/%d')、time.formats.short('%Y/%m/%d %H:%M')が ja.yml で定義されており、アプリケーションのデフォルトロケールが:jaに設定されているため、このコードは例外を発生させることはありません。app/views/users/show.html.slim (1)
67-68: コントローラ側で確認したところ、UsersController#showの第49行で@study_streakは条件に関わらず常に初期化されているため、ビューでの使用は安全です。このレビュー指摘は不要です。
|
@komagata |
| teardown do | ||
| travel_back | ||
| end |
There was a problem hiding this comment.
teardownは最後の処理なので、setupの次に書くか、ファイルの最後に書くのがわかりやすいとおもいます。(他のテストもほとんどそうなっているとおもいます)
There was a problem hiding this comment.
すみません。setupのブロックが長くなっていて分かり辛いのですが、このテストファイルではsetupの次にteardownを書いています。
他のファイル(例えばtest/system/announcements/notification_test.rb)でも同様にsetupの次に書かれていて、そのような書き方に揃えたつもりなのですが...
| teardown do | ||
| travel_back | ||
| end |

Issue
概要
生徒、もしくは研修生のプロフィールページとダッシュボードに連続学習記録の表示を追加しました。
ユーザーの日報のデータを使い、学習日とそうでない日を判別します。
学習日かどうかの判定の対象は日報の日付であり、作成日や更新日ではありません。
学習日の判別のルール
学習日である
学習日ではない
補足
変更確認方法
hatsunoの日報データを作成rails コンソールで日報データを作成
1日あたり二時間の学習時間を記録した日報データを今日の日付から1週間分作成します。
hatsunoのプロフィールページ(http://localhost:3000/users/655153192) に移動し、「学習連続記録」の表示が出ているか確認hatsunoのダッシュボード(http://localhost:3000) に移動し、「学習連続記録」の表示が出ているか確認Screenshot
変更前
変更後
Summary by CodeRabbit
新機能
スタイル
テスト
✏️ Tip: You can customize this high-level summary in your review settings.