Skip to content
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

活動時間カレンダーの実装 #8263

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

Judeeeee
Copy link
Contributor

@Judeeeee Judeeeee commented Jan 3, 2025

issue

概要

以下の目的から、「活動時間」を登録してプロフィール画面で表示する新機能を実装しました。

  • 輪読会の企画やペアプロの依頼をする際に、特定のユーザーが学習する時間(何曜日の何時)を知りたい
  • 今後FBC内でペアプロマッチングの機能を実装予定なので、希望日時入力の補助として主な学習時間のデータを使いたい
  • 学習予定の日時を設定することで、学習を習慣化することを手助けしたい

仕様

  • 新規登録時は、「活動時間」のチェックテーブルが表示されない
  • 現役生、メンター、研修生のみがユーザー登録情報編集ページから活動時間を入力できる
  • 他人のユーザー個別ページを閲覧する際、活動時間を確認できるのは、現役生、メンター、研修生のみ
    • 現役生は卒業したら非表示になる

1️⃣活動時間の入力

ユーザー登録情報編集ページに活動時間のチェックボックスを設置しました。

スクリーンショット 2025-01-12 17 36 25

2️⃣入力を促すアナウンス

活動時間を登録していない場合、ダッシュボードで登録を促します。

スクリーンショット 2025-01-03 20 58 38

3️⃣活動時間の表示

活動時間が登録してあると、プロフィールから確認できます。
スクリーンショット 2025-01-12 17 37 31

変更確認方法

1. このブランチをローカルに取り込む

git fetch origin pull/8263/head:feature/create_learning_time_frames
git switch feature/create_learning_time_frames

2. migrationの実行とシードデータの投入

bin/rails db:migrate
bin/rails db:seed

3. 活動時間カレンダーの表示確認

以下1~5を順に実施すると、余計な手戻りがなくてスムーズです🙆‍♀️

1. 新規登録時に「活動時間」のチェックテーブルが表示されないこと

2. 活動時間がプロフィールページに反映されること

ログインユーザーを現役生(kimura)、メンター(mentor)、研修生(kensyu)に変えて以下を実施してください。

  • 1. kimura or mentor or kensyuでログインする
  • 2. ダッシュボードの未入力の項目に、「活動時間を設定してください。」のリンクが表示されることを確認する
  • 3. 上記を押下し、ユーザー登録情報編集ページへ遷移する
  • 4. 「活動時間」のチェックをし、ユーザー情報を更新する
  • 5. ログインユーザーのプロフィールページに、「活動時間」が反映されていることを確認する
  • 6. ダッシュボードの未入力の項目から、「活動時間を設定してください。」のリンクが削除されていることを確認する

3. プロフィールページに「活動時間」が反映されていること

  • 2で設定したユーザーのプロフィールが、他のログインユーザーから見ても反映されているか確認する

4. ユーザー登録情報編集ページで「活動時間」が非表示なこと

卒業生、アドバイザーは活動時間が入力できません。

5. 現役生は卒業したら非表示になる。

  • 1. komagataでログインし、1. kimuraのプロフィールページで「活動時間」が登録されていることを確認する
  • 2. ステータス変更で、卒業にするボタンを押下する
  • 3. 「活動時間」が表示されないことを確認する

@Judeeeee Judeeeee self-assigned this Jan 3, 2025
@Judeeeee Judeeeee force-pushed the feature/create_learning_time_frames branch 2 times, most recently from c74d36a to baa6fb9 Compare January 3, 2025 13:02
@Judeeeee Judeeeee changed the title [WIP]活動時間カレンダーの実装 活動時間カレンダーの実装 Jan 3, 2025
@Judeeeee Judeeeee marked this pull request as ready for review January 3, 2025 13:17
@Judeeeee
Copy link
Contributor Author

Judeeeee commented Jan 3, 2025

@machida

お疲れ様です!
上記コメント1️⃣と3️⃣について、デザインをお願いしたいです🙇‍♀️
お手数ですがよろしくお願いいたします…!

@machida
Copy link
Member

machida commented Jan 6, 2025

@Judeeeee
おまたせしました!!デザインを入れましたー

@Judeeeee
Copy link
Contributor Author

Judeeeee commented Jan 6, 2025

@machida
ありがとうございます!確認します🙆

@Judeeeee
Copy link
Contributor Author

@machida
デザインありがとうございました!
私の環境で確認したところ、問題ありませんでした🙆

@Judeeeee
Copy link
Contributor Author

@hagiya0121

お疲れ様です!
こちらのレビューをお願いできないでしょうか?🙏
ご都合が悪ければ遠慮なくおっしゃっていただけると幸いです🙇
ご検討の程、よろしくお願いいたします〜

@hagiya0121
Copy link
Contributor

@Judeeeee
了解です!三日以内には終わると思います🙏

@Judeeeee
Copy link
Contributor Author

@hagiya0121
早速の返信助かります🙏
承知しました!ありがとうございます🙇
引き続きよろしくお願いいたします〜!

@hagiya0121 hagiya0121 self-requested a review January 13, 2025 05:24
@@ -0,0 +1,11 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

このコメントは不要だと思います。テストの方のfixtureにも書いてありました。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hagiya0121
コメントありがとうございます!
5330637でコメントを削除しました🙆‍♀️

Judeeeee added a commit that referenced this pull request Jan 13, 2025
Copy link
Contributor

@hagiya0121 hagiya0121 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Judeeeee
動作に問題はありませんでした。
気になったところをコメントしたので確認お願いします🙏

Comment on lines 3 to 8
<% 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.inspect %>
activity_time: <%= hour %>
<% end %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • week_daysをハッシュにしてるのはなぜでしょうか?ハッシュのキーか値のどちらかを配列にしても同じことができそうですが🤔day_prefixで分かりやすいフィクスチャ名を付けるためでしょうか?
  • day_name.inspectとしていますがinspectはいらないと思いました。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

day_prefixで分かりやすいフィクスチャ名を付けるためでしょうか?

はい、おっしゃる通りです〜
他のfixtureファイルに倣ってfixture名を作成する意図でした。
(厳密には他ファイルで名詞+数字の形なので、このdiscussion後に修正します。)

私が期待しているfixtureのイメージは以下です。

sun1:
  id: 1
  week_day: 
  activity_time: 5

話は変わって、カレンダーを表示させる際に上記week_dayで定義されている日付を使わずにビュー側で日付の配列をeachで回しているからweek_day自体が不要では?という問いに対しては、今後の実装を考慮した結果になります。
現段階では使用していないのですが、今後ペアプロマッチング機能実装を予定しており必要なことが想定されているため、現在のカラム構成になっています。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inspectの削除はこちらで行いました〜

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

なるほど理解しました🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(厳密には他ファイルで名詞+数字の形なので、このdiscussion後に修正します。)

こちら、daac3afで対応しました〜

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

このファイルは何のために追加されたのでしょうか?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@machida
お疲れ様です!
この画像ファイルはデザイン入れる際に誤ってcommitしてしまったものですかね?👀

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

誤ってcommitしてしまったものとのことだったので、32ee275で削除しました!

Comment on lines 52 to 62
def update_learning_time_frames
learning_time_frame_ids = params[:user][:learning_time_frame_ids]
learning_time_frames_users = @user.learning_time_frames_users
learning_time_frames_users.delete_all

return if learning_time_frame_ids.blank?

learning_time_frame_ids.each do |learning_time_frame_id|
learning_time_frames_users.create!(user_id: @user.id, learning_time_frame_id:)
end
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

中間テーブルの更新は、このメゾッドを使わなくてもuser_attribute{ learning_time_frame_ids: [] }を追加するだけでいいと思います。
注意点としてこの方法だとチェックボックスを全て外した際にlearning_time_frame_idsnilになってしまって更新されないので、対策したほうがいいです。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

こちらのcommitで修正しました🙆‍♀️
全てチェックを外した状態で更新させるために、hidden_field_tagを用いてデフォルト値を送る形にしました。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

= hidden_field_tag 'user[learning_time_frame_ids][]', '', id: nil
引数のid: nillは省略していいと思います

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

41149cbで削除しました👌

@@ -33,7 +33,8 @@ def set_required_fields
discord_account_name: current_user.discord_profile.account_name,
github_account: current_user.github_account,
blog_url: current_user.blog_url,
graduated: current_user.graduated?
graduated: current_user.graduated?,
learning_time_frames: current_user.graduated? || current_user.learning_time_frames.present?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

レコードの存在を確認するだけならpresent?よりもexists?の方がいいと思います。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

こちらで修正しました🙆
他ファイルでも同様の箇所があったため、合わせて修正しました。

@@ -31,10 +31,10 @@
p
| このページは他のユーザーから見た、あなたのプロフィールページです。
| ( #{link_to '登録情報変更', edit_current_user_path} )
.container.is-xl
.container(class="#{!@user.graduated? && @user.learning_time_frames.present? ? 'is-xxl' : 'is-xl'}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!@user.graduated? && @user.learning_time_frames.present?が繰り返し使われているのが気になります。ヘルパーメゾッドにした方がいいと思います。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

こちらでヘルパーメソッドにしました!

@@ -247,4 +247,48 @@ class CurrentUserTest < ApplicationSystemTestCase
assert_no_text 'Rubyの経験あり'
assert_text 'JavaScriptの経験あり'
end

test 'visible learning time framestable for non advisors and grad users' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

テスト名がframestableとなっています。frames tableではないでしょうか。
他にもframetableになっている箇所がありました。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

こちらで修正しました!

Comment on lines +252 to +271
visit_with_auth '/current_user/edit', 'kimura'
assert_selector 'h1.auth-form__title', text: '登録情報変更'
assert_selector 'label.a-form-label', text: '主な活動予定時間'

visit_with_auth '/current_user/edit', 'mentormentaro'
assert_selector 'h1.auth-form__title', text: '登録情報変更'
assert_selector 'label.a-form-label', text: '主な活動予定時間'

visit_with_auth '/current_user/edit', 'kensyu'
assert_selector 'h1.auth-form__title', text: '登録情報変更'
assert_selector 'label.a-form-label', text: '主な活動予定時間'

visit_with_auth '/current_user/edit', 'advijirou'
assert_selector 'h1.auth-form__title', text: '登録情報変更'
assert_no_selector 'label.a-form-label', text: '主な活動予定時間'

visit_with_auth '/current_user/edit', 'sotugyou'
assert_selector 'h1.auth-form__title', text: '登録情報変更'
assert_no_selector 'label.a-form-label', text: '主な活動予定時間'
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

主な活動予定時間が表示される人とされない人でテストを分けてもいいんじゃないかなと思いました。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

システムテストは極めて重いので、あまり追加したくないという背景があります。
そのため、「存在する」ことのみを確認するシステムテストとしました🙆

assert_selector 'h1.page-main-header__title', text: 'プロフィール'
assert_selector 'h2.card-header__title', text: '主な活動予定時間'

within('tbody#learning_time_frame') do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

なぜwithinでスコープを限定しているのでしょうか?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

なぜwithinでスコープを限定しているのでしょうか?

これはデザインを当てていただいた後の修正で、試行錯誤した跡が残ってしまっているだけです💦
セレクタ自体が一意になっており、スコープを絞る必要がないので削除しました。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

セレクタ自体が一意になっており、スコープを絞る必要がないので削除しました。

削除されていないようです🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

すみません、83f1198で削除しました💦

@Judeeeee Judeeeee force-pushed the feature/create_learning_time_frames branch from c752144 to 736ee0f Compare January 30, 2025 05:26
Copy link
Contributor Author

@Judeeeee Judeeeee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hagiya0121

丁寧なレビューありがとうございました!勉強になります🙏
いただいたコメントに返信しているので、ご確認ください🙇‍♀️
引き続きよろしくお願いいたします〜

@Judeeeee Judeeeee requested a review from hagiya0121 January 30, 2025 06:25
Copy link
Contributor

@hagiya0121 hagiya0121 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Judeeeee
確認しました!
気になったところをコメントしたので確認お願いします🙏

Copy link
Contributor Author

@Judeeeee Judeeeee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hagiya0121
早速の確認ありがとうございます!助かります🙏
いただいたコメントに返信しているので、確認お願いいたします〜

Copy link
Contributor

@hagiya0121 hagiya0121 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Judeeeee
確認OKです🙏 Approveします!

@Judeeeee
Copy link
Contributor Author

@hagiya0121
承知しました!
長い間お付き合いいただきありがとうございました🙏
とても勉強になったので、hagiyaさんにレビューお願いしてよかったです✨

@Judeeeee
Copy link
Contributor Author

@komagata
お疲れ様です〜
こちらメンバーからApproveいただいたので、レビューをお願いいたします🙇

@Judeeeee Judeeeee requested a review from komagata January 31, 2025 12:13
Copy link
Member

@komagata komagata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conflictの修正をお願いします。

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.

4 participants