Product系3クラス分newspaperをActiveSupport::Notificationsに移行#8965
Conversation
|
""" Walkthroughプロダクト作成時のイベント通知方法を、独自のNewspaperシステムからRails標準のActiveSupport::Notificationsへ移行しました。関連するウォッチャー・ノティファイアークラスのメソッドシグネチャを更新し、初期化処理での購読設定もActiveSupport::Notifications用に変更しています。 Changes
Sequence Diagram(s)sequenceDiagram
participant Controller as ProductsController
participant ASNotifications as ActiveSupport::Notifications
participant Watcher as ProductAuthorWatcher
participant NotifierColleague as ProductNotifierForColleague
participant NotifierPractice as ProductNotifierForPracticeWatcher
Controller->>ASNotifications: instrument('product.create', product)
ASNotifications->>Watcher: call(_name, _started, _finished, _unique_id, payload)
ASNotifications->>NotifierColleague: call(_name, _started, _finished, _unique_id, payload)
ASNotifications->>NotifierPractice: call(_name, _started, _finished, _unique_id, payload)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 RuboCop (1.76.1)app/controllers/products_controller.rbrubocop-minitest extension supports plugin, specify app/models/product_author_watcher.rbrubocop-minitest extension supports plugin, specify config/initializers/active_support_notifications.rbrubocop-minitest extension supports plugin, specify
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (7)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (5)
🧰 Additional context used📓 Path-based instructions (2)**/*.rb⚙️ CodeRabbit Configuration File
Files:
test/**/*⚙️ CodeRabbit Configuration File
Files:
🧠 Learnings (2)📓 Common learningstest/models/product_notifier_for_practice_watcher_test.rb (7)Learnt from: masyuko0222 Learnt from: e-yanagita-gs Learnt from: thmz337 Learnt from: e-yanagita-gs Learnt from: jun-kondo Learnt from: reckyy Learnt from: jun-kondo 🪛 ast-grep (0.38.6)test/models/product_notifier_for_practice_watcher_test.rb[warning] 27-33: Found the use of an hardcoded passphrase for RSA. The passphrase can be easily discovered, and therefore should not be stored in source-code. It is recommended to remove the passphrase from source-code, and use system environment variables or a restricted configuration file. (hardcoded-secret-rsa-passphrase-ruby) ⏰ 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)
🔇 Additional comments (2)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
736b9d8 to
34492ae
Compare
|
@Miya096jp さん |
|
お疲れ様です! |
| def call(_name, _started, _finished, _unique_id, payload) | ||
| product = payload[:product] | ||
| Watch.create!(user: product.user, watchable: product) | ||
| Watch.find_or_create_by!(user: product.user, watchable: product) |
There was a problem hiding this comment.
カスタムクエリで安全性が高まっていいなと思いました👍
| Time.current, | ||
| 'unique_id', | ||
| payload | ||
| ) |
There was a problem hiding this comment.
使わない引数でも、nilを使わずにラベリングすると可読性が高くなりますね!💡
34492ae to
8fec381
Compare
|
@Miya096jp さん ディスクリプションの「提出物」をkensyuにしたつもりでしたが、そうじゃなかったみたいでしたすみません💦 |
8fec381 to
5037d78
Compare
|
@Miya096jp さん @komagata さん |
Issue
概要
下記の3クラスの実装をnewspaperからActiveSupport::Notificationsに置き換えました。
変更確認方法
chore/replace-newspaper-with-notifications-in-product-notifierをローカルに取り込むforeman start -f Procfile.devでサーバーを立ち上げます。以下の3つのクラスは全て「提出物」に関するものです。
それぞれ、「提出物を作るユーザー」、「研修生の同僚(アドバイザーなど)」、「提出物をウォッチするユーザー(担当しているメンターなど)」が対象です。
そのため、「研修生」、「その研修生のアドバイザー」、「提出物の担当者(メンター)」でログインすることで動作確認をします。
3-1、3-2、3-3と順に動作確認をお願いします。
3-1.
ProductNotifierForPracticeWatcherの動作確認提出された提出物の担当者になった際に、その提出物の「ウォッチャー」(更新通知を受け取る人)として、自動的に登録する機能です。
以下の手順で、このウォッチャーの機能が正しく機能されているか確認します。
kensyu-end-within-1-weekの提出物にアクセスする。
任意のコメントを残し担当者になります。
以下の3-3まで進み、komagataでログインした際に右上の通知欄にその提出物に関するコメントがあることを確認。
3-2.
ProductNotifierForColleagueの動作確認研修生が提出物を提出した際の、研修生の同僚(アドバイザー)に付与される「ウォッチャー」機能です。
senpaiでログイン3-3.
ProductAuthorWatcherの動作確認提出物を作成した際に、その提出物の作成者自身を、その提出物の「ウォッチャー」(更新通知を受け取る人)として、自動的に登録する機能です。
( 3-1の4を確認。)
※変更前(mainブランチなど)の挙動と、変更後の挙動が同じであることをご確認ください。
Screenshot
※内部的なリファクタリングであり、見た目の変更はないためスクリーンショットはありません。
Summary by CodeRabbit
Summary by CodeRabbit
新機能
バグ修正
テスト