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

「近日開催のイベント」で、当日の開催時間を過ぎたイベントは非表示にする #8280

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

Conversation

sugiwe
Copy link
Contributor

@sugiwe sugiwe commented Jan 16, 2025

Issue

概要

変更確認方法

feature/do-not-display-finished-events-in-upcoming-events-group

  1. {feature/do-not-display-finished-events-in-upcoming-events-group}をローカルに取り込む
    • git fetch origin pull/8280/head:feature/do-not-display-finished-events-in-upcoming-events-group
    • git switch feature/do-not-display-finished-events-in-upcoming-events-group
  2. rails cで rails console を立ち上げる
  3. 以下のコマンドを使い、テスト用のイベント2つを作成する
# 変数userの作成
user = User.find(253826460)

# 1つ目:特別イベント
 Event.create!(
  title: "5分後に「近日開催」の一覧から消える特別イベント",
  description: "終了後にダッシュボード等の「近日開催のイベント」の一覧から消えるかを確認するための特別イベントです",
  location: "Lokkaオフィス",
  capacity: 10,
  start_at: Time.current,
  end_at: Time.current + 5.minute,
  open_start_at: Time.current - 3.hour,
  open_end_at: Time.current - 10.minute,
  user: user
)

# 2つ目:定期イベント
regular_event = RegularEvent.new(
  title: "5分後に「近日開催」の一覧から消える定期イベント",
  description: "終了後にダッシュボード等の「近日開催のイベント」の一覧から消えるかを確認するための定期イベントです",
  finished: false,
  hold_national_holiday: false,
  start_at: Time.current,
  end_at: Time.current + 5.minute,
  user: user
)
regular_event.regular_event_repeat_rules.build(
  frequency: 0,
  day_of_the_week: Time.current.wday,
)
regular_event.user_ids << user
regular_event.save!
  1. foreman start -f Procfile.devでローカルサーバーを立ち上げる
  2. ダッシュボード左上の「近日開催のイベント」に、上で作成した2つのイベントが表示されていることを確認
  3. 5分後(=イベント終了後)、「近日開催のイベント」の一覧から上記2つのイベント表示が消えていることを確認
    ※どちらのイベントも、end_at: Time.current + 5.minuteにより5分後に終了する状態となっております。もしご確認ステップの3〜5の間で5分以上経ってしまった場合は初めからイベントが表示されていない状態になりますので、お手数ですが改めてイベントを作成してください(end_at: Time.current + 10.minuteにするなど終了時刻を調整することで時間に余裕を持たせることができます)

Screenshot

変更前

※各スクリーンショットで、画面右上に表示されている時間についても併せてご覧ください

イベント作成直後(イベント終了前)

  • 元から入っていたテスト用のイベントと今回追加したテスト用のイベントが表示されています
before1

イベント作成から5分以上経過後(イベント終了後)

  • 全てのイベントがそのまま表示されています
before2

変更後

イベント作成直後(イベント終了前)

  • 元から入っていたテスト用のイベントは9:00開催で終了しているので、この段階で既に非表示になっています
after1

イベント作成から5分以上経過後(イベント終了後)

  • 今回追加したイベントも5分が経過して終了となったので、非表示になっています
after2

参考までに、イベント一覧画面の方では勿論イベントの情報は確認できます

after3 after4

@sugiwe sugiwe self-assigned this Jan 16, 2025
@sugiwe sugiwe force-pushed the feature/do-not-display-finished-events-in-upcoming-events-group branch from dd91341 to 47c792a Compare January 19, 2025 06:13
@sugiwe sugiwe force-pushed the feature/do-not-display-finished-events-in-upcoming-events-group branch from 47c792a to ed505b9 Compare January 19, 2025 07:30
@sugiwe sugiwe requested a review from Judeeeee January 23, 2025 08:22
@sugiwe
Copy link
Contributor Author

sugiwe commented Jan 23, 2025

@Judeeeee
お疲れ様です☕️
お手隙の際にこちらのレビューをお願いできますでしょうか🙏
現在、他PRの修正と別のレビュー対応で少なくとも1週間以上かかりそうな状況ですので全然急いでおりませんし、もしご都合が合わないようであれば遠慮なくおっしゃってください、どうぞよろしくお願いいたします!

@sugiwe sugiwe marked this pull request as ready for review January 23, 2025 08:22
@Judeeeee
Copy link
Contributor

@sugiwe
お疲れ様です!承知しました!
2週間目処でレビューする形でも問題なければ是非担当させてくださいー🙏

@sugiwe
Copy link
Contributor Author

sugiwe commented Jan 25, 2025

@Judeeeee
お疲れ様です、お返事ありがとうございます!
2週間目処で問題ございません、どうぞよろしくお願いいたします🙏

Copy link
Contributor

@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.

@sugiwe
お疲れ様ですー!
ブラウザ上での動作確認は問題ありませんでした🙆
気になった箇所にコメントをしたので、ご確認くださいー🙏

@@ -135,4 +135,20 @@ class EventTest < ActiveSupport::TestCase
assert 994_018_171, ids
assert 205_042_674, ids
end

test 'Events in progress today should be displayed' do
Copy link
Contributor

Choose a reason for hiding this comment

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

modelテストなので、メソッドのみをテストした方がよさそうです🙆

test '.scheduled_on_without_ended' do
  # テストを記述する
end

のような形になりそうですかね👀

  • Events in progress today should be displayed
  • Events that have already ended today should not be displayed

は、システムテストで確認した方がまとまりがよいかと思います〜

システムテストが非常に重いため増やしたくない意図からmodelテストに書かれたかもしれないのですが、他のテストもメソッドをテストする書き方をしているので整合性の面でもシステムテストで書いた方が良い気がします🧐(折角fixtureでイベントも作成しているので)

また、実際にシステムテストを書く際の補足ですが、私が過去にこのように指摘されたことがあるので、「表示されるorされない」のどちらかを確認するテストだけで十分だと思います👌

@@ -154,4 +154,20 @@ class RegularEventTest < ActiveSupport::TestCase
assert_equal 157, participated_regular_events.count
end
end

test 'Regular event in progress today should be displayed' do
Copy link
Contributor

@Judeeeee Judeeeee Jan 31, 2025

Choose a reason for hiding this comment

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

ここのモデルテストもevent_testのコメントと同様です🙆

@@ -44,6 +44,8 @@ class Event < ApplicationRecord
scope :wip, -> { where(wip: true) }
scope :related_to, ->(user) { user.job_seeker ? all : where.not(job_hunting: true) }
scope :scheduled_on, ->(date) { where(start_at: date.midnight...(date + 1.day).midnight) }
scope :not_ended, -> { where('end_at > ?', Time.current) }
scope :scheduled_on_without_ended, ->(date) { scheduled_on(date).not_ended }
Copy link
Contributor

Choose a reason for hiding this comment

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

レビューのために質問させてください🙏

scheduled_on_without_endedEventクラスとRegularEventクラスの両方で定義している意図って何でしょうか?👀
それぞれのイベント(特別イベント・定期イベント)の違いで混乱しており、補足があればご教示いただけると幸いです🙇

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.

2 participants