Skip to content

3クラス分のnewspaperをActiveSupport::notificationsに置換#8973

Merged
komagata merged 4 commits intomainfrom
chore/replace-newspaper-with-notifications
Aug 2, 2025
Merged

3クラス分のnewspaperをActiveSupport::notificationsに置換#8973
komagata merged 4 commits intomainfrom
chore/replace-newspaper-with-notifications

Conversation

@Miya096jp
Copy link
Copy Markdown
Contributor

@Miya096jp Miya096jp commented Jul 21, 2025

Issue

概要

下記の3クラスの実装をnewspaperからActiveSupport::Notificationsに置換

SignUpNotifier
RegularEventUpdateNotifier
TimesChannelCreator

動作確認に新規ユーザーの登録が必要なので、
次のテスト用クレジットカード番号を使ってください。

stripeのテスト用クレジットカード番号
番号: 4242424242424242
期限: 月/年(任意)
セキュリティコード: 3桁の番号(任意)
参考: stripe | テスト


関連Issue

[分報]入会時に分報チャンネルを自動で作りたい。 #6103

受講生(現役生または研修生)が入会したときに分報チャンネルを自動で作成する #6185

変更確認方法

  1. ブランチchore/replace-newspaper-with-notificationsをローカルに取り込む
git fetch origin chore/replace-newspaper-with-notifications
  1. ブランチを切り替える
git checkout chore/replace-newspaper-with-notifications
  1. bin/setupを実行
  2. foreman start -f Procfile.devでサーバーを起動

↓以降の手順

SignUpNotifier
  1. 生徒としてユーザー新規登録
  2. railsコンソールで、user.unsubscribe_email_tokenの値を確認し存在すればOK
irb(main):002:0> user = User.find_by(login_name: "test-user1")
irb(main):004:0> user.unsubscribe_email_token
=> "xlIlezxryyoAvF3NiAi_6A"
RegularEventUpdateNotifier
  • 任意のユーザーでログインし、定期イベント(開発MTGなど)に参加登録
  • komagataでログインしその定期イベントの内容を更新する
  • 再度、イベントに参加したユーザーでログインし、イベント更新の通知が届いていればOK

スクリーンショット 2025-07-21 20 44 35

TimesChannelCreator
  1. あらかじめ検証の準備を行う
  2. 生徒として新規ユーザー登録する
  3. 検証用のDiscordサーバーの分報に、新規ユーザーの分報が自動で作成されればOK

検証の準備

1.DiscordのサーバーIDを取得

a. まず動作確認用のDiscordサーバーを新規作成する

参考: #5454(WebhookURLの取得は不要)

b. サーバーIDを取得する
作成したサーバーのアイコンを右クリック > メニューのIDをコピーをクリックして取得


2. カテゴリーIDの取得

a. カテゴリーを作成

サーバーのアイコンをクリック > サーバー名の右側の「∨」をクリックしメニューを表示 > メニューからカテゴリーを作成を選択し、カテゴリーを作成する(カテゴリー名は任意)

b. 開発者モードをON

ユーザー設定(歯車マーク)を開く > 詳細設定を選択 > 開発者モードをONに変更

c. カテゴリーIDの取得

カテゴリー名を右クリック > IDをコピーをクリックしてカテゴリーIDを控える


3. Botの設定とトークンの取得

a. アプリケーションを登録

DEVELOPER PORTAL にアクセスし、画面右上のNew Applicationからアプリケーションを登録

  • NAME: 任意のアプリケーション名
  • 利用規約や開発者ポリシーへの同意にチェックを入れて新規作成

b.Install Linkの設定

左メニューペインのInstallationをクリック > Install LinkのプルダウンからNoneを選択

参考
この設定をせずに次のBotの設定でPUBLIC BOTをOFFに変更しようとするとエラーになる

c. Botの設定とトークンの取得

左メニューペインのBotをクリックしてBot設定ページを開く

  • Reset TokenをクリックしTOKENを発行し控える

  • 次の設定を変更する

    • PUBLIC BOTのトグルボタンをOFF
    • INTENTのトグルボタンをON
    • Save Changesをクリックして保存

4. Botをサーバーに追加する

a. 左メニューペインのOAuth2をクリックしてOAuth2画面を開く
b. OAuth2 URL Generator配下のbotにチェックを入れる
c. BOT PERMISSIONS配下のMinage ChannelsKick Membersにチェックを入れる
d. 画面下部のGENERATED URLペインに表示されるURLをコピー
e. URLにアクセスする
f. サーバーを追加: からサーバーを選択しはいをクリック
g. 「チャンネルの管理」と「メンバーをキック」の権限がついていることを確認したら認証をクリック


5. 環境変数を設定する

次のコマンドをターミナルで実行するか、もしくはdirenvを使用する。
export DISCORD_GUILD_ID=サーバーID
export DISCORD_TIMES_CHANNEL_CATEGORY_ID=カテゴリーID
export DISCORD_BOT_TOKEN=BOTのトークン

direnv

direnvのインストールとsetup

  1. インストール
brew install direnv
  1. shellにhookを追加
export EDITOR=お使いのエディタ
eval "$(direnv hook zsh)"
  1. bootcampディレクトリのアプリケーションルートで次のコマンドを実行し.envrcを作成
direnv edit .
  1. .envrcに環境変数を記述
export DISCORD_GUILD_ID=サーバーID
export DISCORD_TIMES_CHANNEL_CATEGORY_ID=カテゴリーID
export DISCORD_BOT_TOKEN=BOTのトークン
  1. ロードする
direnv allow

Summary by CodeRabbit

Summary by CodeRabbit

  • 新機能

    • ユーザー作成やイベント更新時の通知システムが更新され、より柔軟な通知管理が可能になりました。
  • リファクタ

    • 通知ハンドラーのメソッドシグネチャが変更され、拡張性が向上しました。
    • イベント通知の仕組みが従来の方式から新しい方式に切り替わりました。
    • 不要になった旧イベント購読設定が削除されました。
  • テスト

    • 通知関連のテストが新しいシステムに対応するよう呼び出し方法が修正されました。

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jul 21, 2025

"""

Walkthrough

Newspaper.publishによるイベント通知をすべてActiveSupport::Notifications.instrumentへ置き換え、イベント名もシンボルからドット区切りの文字列へ変更しました。関連するリスナーのメソッドシグネチャもActiveSupportの標準に合わせて引数を拡張し、初期化処理とテストもそれに対応しました。

Changes

ファイル群 変更概要
コントローラのイベント通知置換
app/controllers/regular_events_controller.rb, app/controllers/users_controller.rb
イベント通知をNewspaper.publishからActiveSupport::Notifications.instrumentへ置換。イベント名も新しい形式に変更。
リスナーのメソッドシグネチャ更新
app/models/regular_event_update_notifier.rb, app/models/sign_up_notifier.rb, app/models/times_channel_creator.rb
callメソッドのシグネチャをActiveSupport準拠(5引数)に変更。内部ロジックは変更なし。
ActiveSupport::Notifications購読追加
config/initializers/active_support_notifications.rb
新しいイベント(user.create, student_or_trainee.create, regular_event.update)の購読を追加。
Newspaper購読削除
config/initializers/newspaper.rb
上記3イベントのNewspaper購読を削除。
テストコードの呼び出し修正
test/models/times_channel_creator_test.rb
テスト内のcallメソッド呼び出しを新しいシグネチャに合わせて修正。

Sequence Diagram(s)

sequenceDiagram
  participant Controller
  participant ActiveSupport
  participant Notifier

  Controller->>ActiveSupport: Notifications.instrument('event.name', payload)
  ActiveSupport->>Notifier: call(_name, _started, _finished, _unique_id, payload)
  Notifier->>Notifier: payloadを処理
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • komagata

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/regular_events_controller.rb

rubocop-minitest extension supports plugin, specify plugins: rubocop-minitest instead of require: rubocop-minitest in /.rubocop.yml.
For more information, see https://docs.rubocop.org/rubocop/plugin_migration_guide.html.
rubocop-capybara extension supports plugin, specify plugins: rubocop-capybara instead of require: rubocop-capybara in /.rubocop.yml.
For more information, see https://docs.rubocop.org/rubocop/plugin_migration_guide.html.
Unable to find gem rubocop-fjord; is the gem installed? Gem::MissingSpecError
/var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/config_loader_resolver.rb:309:in rescue in gem_config_path' /var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/config_loader_resolver.rb:293:in gem_config_path'
/var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/config_loader_resolver.rb:84:in block (2 levels) in resolve_inheritance_from_gems' /var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/config_loader_resolver.rb:82:in reverse_each'
/var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/config_loader_resolver.rb:82:in block in resolve_inheritance_from_gems' /var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/config_loader_resolver.rb:76:in each_pair'
/var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/config_loader_resolver.rb:76:in resolve_inheritance_from_gems' /var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/config_loader.rb:66:in load_file'
/var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/config_store.rb:29:in options_config=' /var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/cli.rb:160:in act_on_options'
/var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/cli.rb:47:in block in run' /var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/cli.rb:81:in profile_if_needed'
/var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/cli.rb:43:in run' /var/lib/gems/3.1.0/gems/rubocop-1.77.0/exe/rubocop:19:in <top (required)>'
/usr/local/bin/rubocop:25:in load' /usr/local/bin/rubocop:25:in

'

app/models/sign_up_notifier.rb

rubocop-minitest extension supports plugin, specify plugins: rubocop-minitest instead of require: rubocop-minitest in /.rubocop.yml.
For more information, see https://docs.rubocop.org/rubocop/plugin_migration_guide.html.
rubocop-capybara extension supports plugin, specify plugins: rubocop-capybara instead of require: rubocop-capybara in /.rubocop.yml.
For more information, see https://docs.rubocop.org/rubocop/plugin_migration_guide.html.
Unable to find gem rubocop-fjord; is the gem installed? Gem::MissingSpecError
/var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/config_loader_resolver.rb:309:in rescue in gem_config_path' /var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/config_loader_resolver.rb:293:in gem_config_path'
/var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/config_loader_resolver.rb:84:in block (2 levels) in resolve_inheritance_from_gems' /var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/config_loader_resolver.rb:82:in reverse_each'
/var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/config_loader_resolver.rb:82:in block in resolve_inheritance_from_gems' /var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/config_loader_resolver.rb:76:in each_pair'
/var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/config_loader_resolver.rb:76:in resolve_inheritance_from_gems' /var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/config_loader.rb:66:in load_file'
/var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/config_store.rb:29:in options_config=' /var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/cli.rb:160:in act_on_options'
/var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/cli.rb:47:in block in run' /var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/cli.rb:81:in profile_if_needed'
/var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/cli.rb:43:in run' /var/lib/gems/3.1.0/gems/rubocop-1.77.0/exe/rubocop:19:in <top (required)>'
/usr/local/bin/rubocop:25:in load' /usr/local/bin/rubocop:25:in

'

app/controllers/users_controller.rb

rubocop-minitest extension supports plugin, specify plugins: rubocop-minitest instead of require: rubocop-minitest in /.rubocop.yml.
For more information, see https://docs.rubocop.org/rubocop/plugin_migration_guide.html.
rubocop-capybara extension supports plugin, specify plugins: rubocop-capybara instead of require: rubocop-capybara in /.rubocop.yml.
For more information, see https://docs.rubocop.org/rubocop/plugin_migration_guide.html.
Unable to find gem rubocop-fjord; is the gem installed? Gem::MissingSpecError
/var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/config_loader_resolver.rb:309:in rescue in gem_config_path' /var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/config_loader_resolver.rb:293:in gem_config_path'
/var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/config_loader_resolver.rb:84:in block (2 levels) in resolve_inheritance_from_gems' /var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/config_loader_resolver.rb:82:in reverse_each'
/var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/config_loader_resolver.rb:82:in block in resolve_inheritance_from_gems' /var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/config_loader_resolver.rb:76:in each_pair'
/var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/config_loader_resolver.rb:76:in resolve_inheritance_from_gems' /var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/config_loader.rb:66:in load_file'
/var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/config_store.rb:29:in options_config=' /var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/cli.rb:160:in act_on_options'
/var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/cli.rb:47:in block in run' /var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/cli.rb:81:in profile_if_needed'
/var/lib/gems/3.1.0/gems/rubocop-1.77.0/lib/rubocop/cli.rb:43:in run' /var/lib/gems/3.1.0/gems/rubocop-1.77.0/exe/rubocop:19:in <top (required)>'
/usr/local/bin/rubocop:25:in load' /usr/local/bin/rubocop:25:in

'

  • 4 others

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6a28937 and 65e7ee0.

📒 Files selected for processing (8)
  • app/controllers/regular_events_controller.rb (1 hunks)
  • app/controllers/users_controller.rb (3 hunks)
  • app/models/regular_event_update_notifier.rb (1 hunks)
  • app/models/sign_up_notifier.rb (1 hunks)
  • app/models/times_channel_creator.rb (1 hunks)
  • config/initializers/active_support_notifications.rb (1 hunks)
  • config/initializers/newspaper.rb (0 hunks)
  • test/models/times_channel_creator_test.rb (2 hunks)
💤 Files with no reviewable changes (1)
  • config/initializers/newspaper.rb
🚧 Files skipped from review as they are similar to previous changes (7)
  • app/models/times_channel_creator.rb
  • app/controllers/regular_events_controller.rb
  • config/initializers/active_support_notifications.rb
  • test/models/times_channel_creator_test.rb
  • app/models/sign_up_notifier.rb
  • app/controllers/users_controller.rb
  • app/models/regular_event_update_notifier.rb
⏰ 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)
  • GitHub Check: build_and_test
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/replace-newspaper-with-notifications

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Miya096jp Miya096jp marked this pull request as ready for review July 21, 2025 11:54
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
app/models/sign_up_notifier.rb (1)

4-4: パラメータ名の不整合を修正してください

メソッドシグネチャの変更は適切ですが、_started_パラメータに末尾のアンダースコアが余分に付いています。他のパラメータやTimesChannelCreatorとの一貫性を保つため、_startedに修正することを推奨します。

-  def call(_name, _started_, _finished, _unique_id, payload)
+  def call(_name, _started, _finished, _unique_id, payload)
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between abcf915 and c9be074.

📒 Files selected for processing (8)
  • app/controllers/regular_events_controller.rb (1 hunks)
  • app/controllers/users_controller.rb (3 hunks)
  • app/models/regular_event_update_notifier.rb (1 hunks)
  • app/models/sign_up_notifier.rb (1 hunks)
  • app/models/times_channel_creator.rb (1 hunks)
  • config/initializers/active_support_notifications.rb (1 hunks)
  • config/initializers/newspaper.rb (0 hunks)
  • test/models/times_channel_creator_test.rb (2 hunks)
💤 Files with no reviewable changes (1)
  • config/initializers/newspaper.rb
🧰 Additional context used
📓 Path-based instructions (2)
**/*.rb

⚙️ CodeRabbit Configuration File

**/*.rb: # refactoring

  • まずFat Controllerを避け、次にFat Modelを避ける。
  • Serviceクラスの乱用を避ける。
  • controller concernを作ろうとしたらPORO(Plain Old Ruby Object)やActiveRecordモデルでの実装で代替できないか検討する。

Rails Patterns

  • ViewHelperにメソッドを実装する時にはまずDecoratorパターンを使うことを検討する。(active_decorator gemを導入しているのでそれを使う)
  • 複雑なActiveRecordクエリがあり、再利用できそうな場合はQueryObjectパターンを検討する。(rails-patterns gemを導入しているのでそれのQuery機能を使う)
  • Viewにpartialを作る場合はViewComponentを使うことを検討する。
  • 複数のActiveRecordモデルを操作する1つの責務がある時や外部APIとやりとりする処理がある場合にはInteractorオブジェクトパターンを検討する。(interactor gemを導入しているのでそれを使う)
  • 複数のInteractorを実行するような処理がある場合Organizerオブジェクトパターンを検討する。(interactor gemを導入しており、その中にOrganizerの機能があるので使う)

Files:

  • app/controllers/regular_events_controller.rb
  • config/initializers/active_support_notifications.rb
  • app/controllers/users_controller.rb
  • app/models/sign_up_notifier.rb
  • app/models/times_channel_creator.rb
  • app/models/regular_event_update_notifier.rb
  • test/models/times_channel_creator_test.rb
test/**/*

⚙️ CodeRabbit Configuration File

test/**/*: # Test

  • TestCase名は英語で書く。
  • どうしても避けられない時以外にsystem testでsleepは使わない。

Unit Test

model, helper, decorator, view_componentについてはメソッドを追加した場合は必ず対応したUnit TestのTestCaseを1つは書く。

Files:

  • test/models/times_channel_creator_test.rb
🧠 Learnings (5)
📓 Common learnings
Learnt from: reckyy
PR: fjordllc/bootcamp#8356
File: app/models/notification.rb:45-47
Timestamp: 2025-07-15T12:58:02.735Z
Learning: fjordllc/bootcampプロジェクトの`app/models/notification.rb`において、`training_completed`通知種別は`TARGETS_TO_KINDS`ハッシュに含めない設計になっている。これは`training_completed`が通知一覧のフィルタ対象ではないためで、意図的な設計判断である。
app/controllers/regular_events_controller.rb (1)

Learnt from: reckyy
PR: #8356
File: app/models/notification.rb:45-47
Timestamp: 2025-07-15T12:58:02.735Z
Learning: fjordllc/bootcampプロジェクトのapp/models/notification.rbにおいて、training_completed通知種別はTARGETS_TO_KINDSハッシュに含めない設計になっている。これはtraining_completedが通知一覧のフィルタ対象ではないためで、意図的な設計判断である。

config/initializers/active_support_notifications.rb (1)

Learnt from: reckyy
PR: #8356
File: app/models/notification.rb:45-47
Timestamp: 2025-07-15T12:58:02.735Z
Learning: fjordllc/bootcampプロジェクトのapp/models/notification.rbにおいて、training_completed通知種別はTARGETS_TO_KINDSハッシュに含めない設計になっている。これはtraining_completedが通知一覧のフィルタ対象ではないためで、意図的な設計判断である。

app/controllers/users_controller.rb (2)

Learnt from: reckyy
PR: #8356
File: app/models/notification.rb:45-47
Timestamp: 2025-07-15T12:58:02.735Z
Learning: fjordllc/bootcampプロジェクトのapp/models/notification.rbにおいて、training_completed通知種別はTARGETS_TO_KINDSハッシュに含めない設計になっている。これはtraining_completedが通知一覧のフィルタ対象ではないためで、意図的な設計判断である。

Learnt from: reckyy
PR: #8356
File: db/fixtures/users.yml:823-826
Timestamp: 2025-07-15T12:33:04.885Z
Learning: fjordllc/bootcampプロジェクトでは、trainee: trueは「研修に所属していたユーザー」全体を示すフラグであり、研修中のユーザーと研修を終了したユーザーの両方を含む。そのため、trainee: truetraining_completed_atの併存は意図された仕様であり、排他的な関係ではない。

app/models/sign_up_notifier.rb (1)

Learnt from: reckyy
PR: #8356
File: app/models/notification.rb:45-47
Timestamp: 2025-07-15T12:58:02.735Z
Learning: fjordllc/bootcampプロジェクトのapp/models/notification.rbにおいて、training_completed通知種別はTARGETS_TO_KINDSハッシュに含めない設計になっている。これはtraining_completedが通知一覧のフィルタ対象ではないためで、意図的な設計判断である。

🧬 Code Graph Analysis (2)
app/controllers/users_controller.rb (1)
app/models/user.rb (1)
  • student? (641-643)
test/models/times_channel_creator_test.rb (1)
app/models/user.rb (1)
  • student_or_trainee? (690-692)
🔇 Additional comments (12)
app/models/times_channel_creator.rb (1)

4-4: ActiveSupport::Notificationsの標準的なメソッドシグネチャへの変更が適切です

Newspaperからの移行に伴い、ActiveSupport::Notificationsの標準的な5つのパラメータ(_name, _started, _finished, _unique_id, payload)を受け取るように変更されています。使用しないパラメータにアンダースコアプレフィックスを付けるのはRubyの慣例に従っており、適切な実装です。

app/controllers/regular_events_controller.rb (1)

47-47: Newspaperからの移行が適切に実装されています

Newspaper.publish(:regular_event_update, ...)からActiveSupport::Notifications.instrument('regular_event.update', ...)への変更が正しく行われています。イベント名がシンボルからドット区切りの文字列に変更され、ActiveSupport::Notificationsの慣例に従っています。ペイロードの構造は維持されているため、既存の通知ロジックとの互換性が保たれています。

config/initializers/active_support_notifications.rb (1)

9-11: 新しいActiveSupport::Notifications購読が適切に追加されています

3つの新しいイベント購読('student_or_trainee.create', 'user.create', 'regular_event.update')が正しく追加されています。各購読で.newを使用してnotifierクラスの新しいインスタンスを作成しているのは適切で、既存のパターンと一貫性があります。イベント名もActiveSupport::Notificationsの慣例に従ったドット区切りの文字列形式になっています。

test/models/times_channel_creator_test.rb (5)

13-13: テストの呼び出しが新しいメソッドシグネチャに適切に更新されています

TimesChannelCreator#callの新しいメソッドシグネチャに合わせて、テストの呼び出しが正しく更新されています。使用しない最初の4つのパラメータにはnilを渡し、最後のペイロードはキーワード引数として渡すという実装は適切です。


20-20: テストの呼び出しが新しいメソッドシグネチャに適切に更新されています

2つ目のテストケースでも同様に、新しいメソッドシグネチャに合わせた呼び出しが正しく実装されています。


33-33: 例外テストも新しいメソッドシグネチャに適切に更新されています

管理者ユーザーでの例外テストも新しいメソッドシグネチャに合わせて正しく更新されています。


40-40: メンターユーザーでの例外テストも適切に更新されています

メンターユーザーでの例外テストケースも新しいメソッドシグネチャに合わせて正しく更新されています。


47-47: アドバイザーユーザーでの例外テストも適切に更新されています

アドバイザーユーザーでの例外テストケースも新しいメソッドシグネチャに合わせて正しく更新されています。

app/controllers/users_controller.rb (3)

69-69: ActiveSupport::Notificationsへの移行が正しく実装されています

Newspaper.publish(:user_create, user: @user)からActiveSupport::Notifications.instrument('user.create', user: @user)への変更により、イベント通知システムが適切に移行されています。イベント名の命名規則もActiveSupportの標準的なドット区切り形式に従っています。


105-105: 研修生向けイベント通知の移行が適切です

研修生(trainee)の場合のみstudent_or_trainee.createイベントを発火する条件分岐が正しく実装されています。無料ユーザー作成フローでの適切な場所でのイベント発火になっています。


151-151: 学生向けイベント通知の移行が適切です

有料ユーザー作成フローにおいて、学生(student)の場合のみstudent_or_trainee.createイベントを発火する条件分岐が正しく実装されています。支払い処理完了後の適切なタイミングでのイベント発火になっています。

app/models/regular_event_update_notifier.rb (1)

4-4: ActiveSupport::Notificationsの標準インターフェースに正しく対応

callメソッドの引数がActiveSupport::Notificationsのsubscriberインターフェース(name, started, finished, unique_id, payload)に正しく対応しています。使用しない引数にアンダースコア接頭辞を付けることで、意図が明確になっています。

@Miya096jp Miya096jp self-assigned this Jul 22, 2025
@Miya096jp
Copy link
Copy Markdown
Contributor Author

@jun-kondo

お疲れ様です!
お手隙の時にレビューをお願いしてよろしいでしょうか?

@Miya096jp Miya096jp changed the title TimesChannelsCreatorのフックをnewspaperからActiveSupport::notificationsに置換 3クラス分のnewspaperをActiveSupport::notificationsに置換 Jul 22, 2025
@jun-kondo
Copy link
Copy Markdown
Contributor

@Miya096jp
お疲れ様です!!
了解しました。初めてなので少し時間頂くかもですが、よろしくお願い致しますー
お手数ですがレビュワーのところに私をセットしておいてくださいー

プルリクエストをざっと拝見しましたが、読みやすくて良いですね🙌
今後書く際に参考にさせてもらいます😄

@Miya096jp Miya096jp requested a review from jun-kondo July 23, 2025 11:46
@Miya096jp
Copy link
Copy Markdown
Contributor Author

@jun-kondo

ありがとうございます!
急ぎませんので、お手隙のときによろしくお願いします!

@jun-kondo
Copy link
Copy Markdown
Contributor

@Miya096jp
お疲れ様ですー
こちらについて私の方のローカル環境でも動作確認出来ました。
DiscordのBotについてあまり知らなかったので、手順が詳しく案内されていてわかりやすかったですー助かりました🙌
コードの方も問題ないと思います🙆‍♂️
1箇所コンフリクトが発生しているので解消を確認してApproveしたいと思います👀

@Miya096jp Miya096jp force-pushed the chore/replace-newspaper-with-notifications branch from c9be074 to 3062c30 Compare July 26, 2025 09:41
Copy link
Copy Markdown
Contributor

@jun-kondo jun-kondo left a comment

Choose a reason for hiding this comment

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

@Miya096jp
確認しました。Approveしますー🙆‍♂️

@Miya096jp
Copy link
Copy Markdown
Contributor Author

@jun-kondo

ありがとうございます!🙌

@Miya096jp
Copy link
Copy Markdown
Contributor Author

@komagata

お疲れ様です!
レビューをお願いいたします🙏

@komagata
Copy link
Copy Markdown
Member

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

@Miya096jp Miya096jp force-pushed the chore/replace-newspaper-with-notifications branch from 3062c30 to 6a28937 Compare July 29, 2025 01:07
@Miya096jp
Copy link
Copy Markdown
Contributor Author

@komagata

修正しました!

@komagata
Copy link
Copy Markdown
Member

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

@Miya096jp Miya096jp force-pushed the chore/replace-newspaper-with-notifications branch from 6a28937 to 65e7ee0 Compare July 30, 2025 08:16
@Miya096jp
Copy link
Copy Markdown
Contributor Author

@komagata

修正しました!

Copy link
Copy Markdown
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.

確認させて頂きました。OKです〜🙆‍♂️

@komagata komagata merged commit 4b4ca68 into main Aug 2, 2025
5 checks passed
@komagata komagata deleted the chore/replace-newspaper-with-notifications branch August 2, 2025 17:37
@github-actions github-actions bot mentioned this pull request Aug 2, 2025
87 tasks
@Miya096jp
Copy link
Copy Markdown
Contributor Author

@komagata

お疲れ様です!

こちら8/19のリリースでしたが、本番環境での動作確認を依頼させていただくのを忘れておりました。大変申し訳ございません。

SignUpNotifierのみ、動作確認をお願いいたします🙇🏻‍♂️

@komagata
Copy link
Copy Markdown
Member

komagata commented Oct 9, 2025

@Miya096jp 遅くなってもうしわけありません。確認しました〜!

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.

3 participants