-
Notifications
You must be signed in to change notification settings - Fork 72
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
base: main
Are you sure you want to change the base?
「近日開催のイベント」で、当日の開催時間を過ぎたイベントは非表示にする #8280
Conversation
dd91341
to
47c792a
Compare
47c792a
to
ed505b9
Compare
@Judeeeee |
@sugiwe |
@Judeeeee |
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.
@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 |
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.
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されない」のどちらかを確認するテストだけで十分だと思います👌
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.
@Judeeeee
こちらありがとうございます🙏
どのテストに何を入れるのか、正直よくわかっていない部分も大きかったので、改めて検討して修正させていただきます🙏
@@ -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 |
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.
ここのモデルテストも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 } |
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.
レビューのために質問させてください🙏
scheduled_on_without_ended
をEvent
クラスとRegularEvent
クラスの両方で定義している意図って何でしょうか?👀
それぞれのイベント(特別イベント・定期イベント)の違いで混乱しており、補足があればご教示いただけると幸いです🙇
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.
@Judeeeee
意味合いとしては同じ「今日開催でまだ終わっていないイベント」で命名もscheduled_on_without_ended
で共通なのですが、中身のロジックが異なるものとして定義する必要があるのは、特別イベントと定期イベントで「開催日」の扱いがかなり異なっているという事情があります🙏
まず、自分が作業する前の段階から存在していたscheduled_on
スコープがありまして、これも同名であるにも関わらずEvent
クラスとRegularEvent
クラスの両方で異なる内容で定義してあるという前提がございます。
# app/models/event.rb 内
# 特別イベントは開催が1回だけなので、「今日開催予定かどうか」の絞り込みがシンプル(DBの絞り込みだけで処理)
scope :scheduled_on, ->(date) { where(start_at: date.midnight...(date + 1.day).midnight) }
# app/models/regular_event.rb 内
# 定期イベントは毎週など複数開催のため開催日の設定がやや複雑になっている(holdingで取得後にfilterを使いRubyで判定)
scope :scheduled_on, ->(date) { holding.filter { |event| event.scheduled_on?(date) } }
このように同名でも中身の異なるscheduled_on
スコープを拡張するような形で今回のスコープを定義したという背景があるのですが、要はEvent
とRegularEvent
で開催日の管理方法が異なるため共通化することは難しく、意味合いとしてはどちらも「今日開催でまだ終わっていないイベント」になるのですが、それぞれ別の方法で定義している、ということになります。
うまく説明できたかどうかわからないのですが、いかがでしょうか。
ご不明点あれば何なりとお聞きください!
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.
丁寧な説明ありがとうございます🙏
- 特別イベントと定期イベントで「開催日」の扱いがかなり異なっている
- 既存の
scheduled_on
スコープがEvent
とRegularEvent
でそれぞれ定義されている
ことから共通化が難しかったのですね👀
理解できたため追加の質問はないですー🙇
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.
@sugiwe
お疲れ様です!
コメントありがとうございました🙏
丁寧な説明助かりました!✨
引き続きシステムテストの検討だけ対応お願いいたします🙇
@@ -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 } |
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.
丁寧な説明ありがとうございます🙏
- 特別イベントと定期イベントで「開催日」の扱いがかなり異なっている
- 既存の
scheduled_on
スコープがEvent
とRegularEvent
でそれぞれ定義されている
ことから共通化が難しかったのですね👀
理解できたため追加の質問はないですー🙇
Issue
概要
変更確認方法
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
rails c
で rails console を立ち上げるforeman start -f Procfile.dev
でローカルサーバーを立ち上げる※どちらのイベントも、
end_at: Time.current + 5.minute
により5分後に終了する状態となっております。もしご確認ステップの3〜5の間で5分以上経ってしまった場合は初めからイベントが表示されていない状態になりますので、お手数ですが改めてイベントを作成してください(end_at: Time.current + 10.minute
にするなど終了時刻を調整することで時間に余裕を持たせることができます)Screenshot
変更前
※各スクリーンショットで、画面右上に表示されている時間についても併せてご覧ください
イベント作成直後(イベント終了前)
イベント作成から5分以上経過後(イベント終了後)
変更後
イベント作成直後(イベント終了前)
イベント作成から5分以上経過後(イベント終了後)
参考までに、イベント一覧画面の方では勿論イベントの情報は確認できます