-
Notifications
You must be signed in to change notification settings - Fork 75
ダッシュボードに今が学習予定時間の人を表示する #8711
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
Merged
komagata
merged 16 commits into
main
from
feature/display_members_scheduled_to_study_now_on_dashboard
Nov 19, 2025
+165
−8
Merged
ダッシュボードに今が学習予定時間の人を表示する #8711
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
609e6ca
user_icon コンポーネントを作成
sharoa119 da875a1
user_icon_listコンポーネントを作成
sharoa119 1afca2f
ダッシュボードに学習時間該当ユーザーのアイコンを表示する機能を実装
sharoa119 84e470f
学習時間該当ユーザーのアイコンに関するテストを追加
sharoa119 aa23aee
user_icon_list にデザインを適用、user_icon を partial に変更、テストファイル名もリネームに合わせて変更
machida 3225480
コード整理とリファクタリング:定数化・スコープ追加・不要コード削除など
sharoa119 cc8eb03
ダッシュボードで全ユーザーに「現在学習中」アイコンが表示されるように修正
sharoa119 865bd8f
coderabbitai指摘対応: ユーザーアイコンリストのスクロール/レイアウト修正
sharoa119 fb9509e
TimeRangeHelperに対するテストを追加
sharoa119 35f583b
TimeRangeHelperで曜日をI18nから取得するように変更
sharoa119 0827fec
ユーザーアイコン表示での N+1 を解消
sharoa119 b1af698
LearningTimeFrameの曜日表示をI18n対応 & ダッシュボードカラム表示を修正
sharoa119 7737c90
指摘箇所を修正
sharoa119 9949f04
テスト用 LearningTimeFrames fixture を修正
sharoa119 b354863
main に合わせて schema.rb を更新(sad_streak → negative_streak の反映)
sharoa119 ec2a137
マイグレーション再実行に伴い schema.rb を更新
sharoa119 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
app/components/users/current_user_icon_list_component.html.slim
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| .current-user-icon-list | ||
| .l-container | ||
| .current-user-icon-list__inner | ||
| h2.current-user-icon-list__title | ||
| span.current-user-icon-list__title-label | ||
| | 現在学習中 | ||
| br | ||
| span.current-user-icon-list__title-time | ||
| = time_range(Time.zone.now) | ||
| ul.current-user-icon-list__items | ||
| - @users.each do |user| | ||
| li.current-user-icon-list__item | ||
| = render 'users/icon', | ||
| user: user, | ||
| link_class: 'current-users__item-link', | ||
| image_class: 'current-users__item-icon' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class Users::CurrentUserIconListComponent < ViewComponent::Base | ||
| include TimeRangeHelper | ||
|
|
||
| def initialize(users:) | ||
| @users = users | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module TimeRangeHelper | ||
| def time_range(time) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. テストコードがあったほうがいいかもです💡
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. コメントありがとうございます! |
||
| start_hour = time.change(min: 0, sec: 0) | ||
| end_hour = start_hour + 1.hour | ||
|
|
||
| "(#{I18n.t('date.abbr_day_names')[time.wday]}) #{start_hour.strftime('%H:%M')} 〜 #{end_hour.strftime('%H:%M')}" | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
app/javascript/stylesheets/application/blocks/dashboard/_current-user-icon-list.sass
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| .current-user-icon-list | ||
| margin-bottom: 1rem | ||
| background-color: #eaeaf1 | ||
| padding-block: .5rem | ||
| // fallback for older UA | ||
| padding-top: .5rem | ||
| padding-bottom: .5rem | ||
|
|
||
| .current-user-icon-list__inner | ||
| display: flex | ||
| align-items: center | ||
| gap: .5rem | ||
|
|
||
| .current-user-icon-list__items | ||
| display: flex | ||
| align-items: center | ||
| gap: .25rem | ||
| flex: 1 1 auto | ||
| min-width: 0 | ||
| flex-wrap: nowrap | ||
| overflow-x: auto | ||
| scrollbar-gutter: stable both-edges | ||
|
|
||
| .current-user-icon-list__item | ||
| flex: 0 0 2.5rem | ||
| +media-breakpoint-up(md) | ||
| flex: 0 0 3rem | ||
| +media-breakpoint-down(sm) | ||
| flex: 0 0 2rem | ||
|
|
||
| .current-user-icon-list__title-label | ||
| +text-block(.875rem 1.4) | ||
| font-weight: 700 | ||
| white-space: nowrap | ||
|
|
||
| .current-user-icon-list__title-time | ||
| +text-block(.75rem 1.4) | ||
| white-space: nowrap |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
test/components/users/current_user_icon_list_component_test.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require 'test_helper' | ||
|
|
||
| class CurrentUserIconListComponentTest < ViewComponent::TestCase | ||
| fixtures :users, :learning_time_frames | ||
|
|
||
| test 'shows user icons if multiple users have active learning time now' do | ||
| travel_to Time.zone.local(2025, 5, 28, 12, 0, 0) do | ||
| kimura = users(:kimura) | ||
| kensyu = users(:kensyu) | ||
|
|
||
| LearningTimeFramesUser.create!(user: kimura, learning_time_frame_id: 85) | ||
| LearningTimeFramesUser.create!(user: kensyu, learning_time_frame_id: 85) | ||
|
|
||
| users = User.students_and_trainees.joins(:learning_time_frames).merge(LearningTimeFrame.active_now) | ||
| assert_includes users, kimura | ||
| assert_includes users, kensyu | ||
| end | ||
| end | ||
|
|
||
| test 'excludes current user from the list even when they have active learning time' do | ||
| travel_to Time.zone.local(2025, 5, 28, 12, 0, 0) do | ||
| kimura = users(:kimura) | ||
| kensyu = users(:kensyu) | ||
| current_user = users(:hatsuno) | ||
|
|
||
| LearningTimeFramesUser.create!(user: kimura, learning_time_frame_id: 85) | ||
| LearningTimeFramesUser.create!(user: kensyu, learning_time_frame_id: 85) | ||
| LearningTimeFramesUser.create!(user: current_user, learning_time_frame_id: 85) | ||
|
|
||
| users_for_time_slot = User.students_and_trainees | ||
| .joins(:learning_time_frames) | ||
| .merge(LearningTimeFrame.active_now) | ||
| .where.not(id: current_user.id) | ||
|
|
||
| assert_includes users_for_time_slot, kimura | ||
| assert_includes users_for_time_slot, kensyu | ||
| assert_not_includes users_for_time_slot, current_user | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| <% week_days = { '日' => 'sun', '月' => 'mon', '火' => 'tue', '水' => 'wed', '木' => 'thu', '金' => 'fri', '土' => 'sat' } %> | ||
| <% week_days.each_with_index do |(day_name, day_prefix), day_index| %> | ||
| <% (0..23).each_with_index do |hour, hour_index| %> | ||
| <%= "#{day_prefix}#{hour}:" %> | ||
| id: <%= day_index * 24 + hour_index + 1 %> | ||
| week_day: <%= day_name %> | ||
| activity_time: <%= hour %> | ||
| <% end %> | ||
| <% (0..23).each_with_index do |hour, hour_index| %> | ||
| <%= "#{day_prefix}#{hour}:" %> | ||
| id: <%= day_index * 24 + hour_index + 1 %> | ||
| week_day: <%= day_name %> | ||
| activity_time: <%= hour %> | ||
| <% end %> | ||
| <% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require 'test_helper' | ||
|
|
||
| class TimeRangeHelperTest < ActionView::TestCase | ||
| test 'formats weekday and time correctly' do | ||
| time = Time.zone.local(2025, 8, 29, 14, 30) | ||
| assert_equal '(金) 14:00 〜 15:00', time_range(time) | ||
| end | ||
|
|
||
| test 'formats exactly on the hour' do | ||
| time = Time.zone.local(2025, 8, 29, 10, 0) | ||
| assert_equal '(金) 10:00 〜 11:00', time_range(time) | ||
| end | ||
|
|
||
| test 'formats time crossing midnight' do | ||
| time = Time.zone.local(2025, 8, 31, 23, 59) | ||
| assert_equal '(日) 23:00 〜 00:00', time_range(time) | ||
| end | ||
| end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
他の場所はすべてinclude行とdefの間に1行開けているので合わせたほうがいいかもとおもいました。
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.
ご指摘ありがとうございます!
確かにですね!修正いたしました!