Skip to content

SadStreakUpdaterとLearningCacheDestroyerをnewspaperからActiveSupport::Notificationsに移行#8977

Merged
komagata merged 2 commits intomainfrom
chore/replace-newspaper-with-activesupport_notifications-in-sad_streak_updater-and-learning_cache_destroyer
Jul 30, 2025
Merged

SadStreakUpdaterとLearningCacheDestroyerをnewspaperからActiveSupport::Notificationsに移行#8977
komagata merged 2 commits intomainfrom
chore/replace-newspaper-with-activesupport_notifications-in-sad_streak_updater-and-learning_cache_destroyer

Conversation

@jun-kondo
Copy link
Copy Markdown
Contributor

@jun-kondo jun-kondo commented Jul 23, 2025

Issue

概要

以下の2クラスをnewspaperの利用をActiveSupport::Notificationsに移行しました。

  • SadStreakUpdater
  • LearningCacheDestroyer

変更確認方法

ブランチをローカルに取り込む

git fetch origin chore/replace-newspaper-with-activesupport_notifications-in-sad_streak_updater-and-learning_cache_destroyer
git checkout chore/replace-newspaper-with-activesupport_notifications-in-sad_streak_updater-and-learning_cache_destroyer

ローカルサーバーの立ち上げ

rails db:reset
bin/setup
foreman start -f Procfile.dev

以下の手順でSadStreakUpdater、LearningCacheDestroyerが移行前と変わらず動作することを確認する

SadStreakUpdater

日報の新規作成、更新、削除のイベントが発生すると、オブザーバーのSadStreakUpdaterクラスが日報情報を受け取りupdate_sad_streakメソッドを実行してユーザー情報を更新する
更新されたユーザー情報をコンソール上で確認する

日報の作成、更新 イベントでの動作確認

ユーザー: take8でログイン(パスワード: testtest)
ターミナルで

rails c

コンソールでユーザー: take8sad_streak属性がfalseであることを確認する

user = User.find_by(login_name: "take8")
user.sad_streak

(http://localhost:3000/reports/new) にアクセスし、今日の気分sosoで日報を新規作成(プラクティス、日報タイトル、本文は任意)
コンソールでユーザー: take8sad_streak属性がfalseであることを確認する

user = User.find_by(login_name: "take8")
user.sad_streak
  • 最新の二件の日報が両方ともsadではないのでsad_streakfalseになることを確認

先ほど作成した日報の編集ページへアクセスし、今日の気分をsadに変更
コンソールでユーザー: take8sad_streak属性がtrueになることを確認する

user = User.find_by(login_name: "take8")
user.sad_streak
  • 最新の二件の日報が両方ともsadなのでsad_streaktrueになることを確認

日報の削除イベントでの動作確認

アプリ上で先程追加した日報を削除する
コンソールでユーザー: take8sad_streak属性がfalseであることを確認する

user = User.find_by(login_name: "take8")
user.sad_streak
  • 最新の二件の日報が両方sadである条件を満たさないのでsad_streakfalseになることを確認
LearningCacheDestroyer

ユーザーがプラクティスの進捗ステータスを更新、管理者がユーザーを削除のイベントが発生するとオブザーバーのLearningCacheDestroyerクラスがユーザー情報を受け取りキャッシュを削除する処理が実行される
ターミナル上のdevelopmentログに[LearningCacheDestroyer] Cache destroyed for user (ユーザーID)が出力されるので、それを確認する

プラクティス進捗ステータス更新時の動作確認

ターミナルで

tail -f log/development.log | grep "LearningCacheDestroyer"

を実行し、developmentログを監視する

ユーザー: hajimeでログイン(パスワード: testtest)
着手中の「OS X Mountain Lionをクリーンインストールする」のプラクティスページに行く (http://localhost:3000/practices/315059988)
ページ上部のステータスを「着手」から「未着手」変更する

  • developmentログに下記メッセージが出ていることを確認する
    • [LearningCacheDestroyer] Cache destroyed for user 253826460

ユーザー削除イベントでの動作確認

ターミナルで

tail -f log/development.log | grep "LearningCacheDestroyer"

を実行し、developmentログを監視する

ユーザー: komagataでログイン(パスワード: testtest)
yameoの管理者用ユーザーページにアクセス(http://localhost:3000/users/888299165)し、退会済みユーザーの`yameo`を管理者ページから削除する
「このユーザーを削除する」のリンクをクリックして、確認のダイアログでOKをクリック

  • developmentログに下記メッセージが出ていることを確認する
    • [LearningCacheDestroyer] Cache destroyed for user 888299165

Screenshot

内部的な変更なのでスクリーンショットはありません。

Summary by CodeRabbit

  • リファクタ

    • 内部イベント通知の仕組みを更新し、通知方法を統一しました。
    • 一部のイベントハンドラの引数仕様を変更しました(ユーザーへの影響はありません)。
  • その他

    • イベント通知の設定を整理し、不要な初期化処理を削除しました。

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jul 23, 2025

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/reports_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/controllers/admin/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

'

app/controllers/api/practices/learning_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

'

  • 3 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 d2ef468 and 5965505.

📒 Files selected for processing (7)
  • app/controllers/admin/users_controller.rb (1 hunks)
  • app/controllers/api/practices/learning_controller.rb (1 hunks)
  • app/controllers/reports_controller.rb (1 hunks)
  • app/models/learning_cache_destroyer.rb (1 hunks)
  • app/models/sad_streak_updater.rb (1 hunks)
  • config/initializers/active_support_notifications.rb (2 hunks)
  • config/initializers/newspaper.rb (0 hunks)
💤 Files with no reviewable changes (1)
  • config/initializers/newspaper.rb
🚧 Files skipped from review as they are similar to previous changes (6)
  • config/initializers/active_support_notifications.rb
  • app/controllers/api/practices/learning_controller.rb
  • app/controllers/reports_controller.rb
  • app/models/learning_cache_destroyer.rb
  • app/models/sad_streak_updater.rb
  • app/controllers/admin/users_controller.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-activesupport_notifications-in-sad_streak_updater-and-learning_cache_destroyer

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.

@jun-kondo jun-kondo changed the title Chore/replace newspaper with activesupport notifications in sad streak updater and learning cache destroyer SadStreakUpdaterとLearningCacheDestroyerをnewspaperからActiveSupport::Notificationsに移行 Jul 23, 2025
@jun-kondo jun-kondo force-pushed the chore/replace-newspaper-with-activesupport_notifications-in-sad_streak_updater-and-learning_cache_destroyer branch from cc4bc46 to 35dfbce Compare July 23, 2025 06:42
@jun-kondo jun-kondo self-assigned this Jul 23, 2025
@jun-kondo jun-kondo marked this pull request as ready for review July 23, 2025 07:38
@jun-kondo
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jul 23, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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: 1

📜 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 35dfbce.

📒 Files selected for processing (7)
  • app/controllers/admin/users_controller.rb (1 hunks)
  • app/controllers/api/practices/learning_controller.rb (1 hunks)
  • app/controllers/reports_controller.rb (3 hunks)
  • app/models/learning_cache_destroyer.rb (1 hunks)
  • app/models/sad_streak_updater.rb (1 hunks)
  • config/initializers/active_support_notifications.rb (1 hunks)
  • config/initializers/newspaper.rb (0 hunks)
💤 Files with no reviewable changes (1)
  • config/initializers/newspaper.rb
🧰 Additional context used
📓 Path-based instructions (1)
**/*.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/api/practices/learning_controller.rb
  • app/controllers/admin/users_controller.rb
  • config/initializers/active_support_notifications.rb
  • app/models/sad_streak_updater.rb
  • app/controllers/reports_controller.rb
  • app/models/learning_cache_destroyer.rb
🧠 Learnings (4)
📓 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`が通知一覧のフィルタ対象ではないためで、意図的な設計判断である。
Learnt from: hirokiej
PR: fjordllc/bootcamp#8740
File: app/helpers/reports_helper.rb:56-64
Timestamp: 2025-06-29T03:44:15.179Z
Learning: このプロジェクト(fjordllc/bootcamp)では、ja.ymlファイルで一部の単語や文章のみI18n対応されているが、多くのテキストは日本語でハードコーディングされており、完全な国際化対応は行われていない。新しい機能でもI18n対応は不要と判断される。
app/controllers/api/practices/learning_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が通知一覧のフィルタ対象ではないためで、意図的な設計判断である。

app/controllers/admin/users_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が通知一覧のフィルタ対象ではないためで、意図的な設計判断である。

🔇 Additional comments (7)
app/controllers/api/practices/learning_controller.rb (1)

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

Newspaper.publishからActiveSupport::Notifications.instrumentへの変更が適切に行われています。イベント名'learning.create'とペイロード構造{user: learning.user}も正しく設定されています。

config/initializers/active_support_notifications.rb (1)

10-16: イベントハンドラーの購読設定が適切に実装されています

SadStreakUpdaterとLearningCacheDestroyerのActiveSupport::Notifications購読設定が正しく行われています。インスタンスの再利用と適切なイベント名の使用により、効率的な実装となっています。

app/models/sad_streak_updater.rb (1)

4-7: ActiveSupport::Notifications対応のメソッドシグネチャが正しく実装されています

callメソッドがActiveSupport::Notificationsのサブスクライバーインターフェースに適合するよう正しく更新されています。未使用パラメータのアンダースコアプレフィックスも適切で、内部ロジックは変更されていないため動作の一貫性が保たれています。

app/controllers/admin/users_controller.rb (1)

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

Newspaper.publishからActiveSupport::Notifications.instrumentへの変更が適切に行われています。イベント名'learning.destroy'とペイロード構造{user:}も正しく設定されており、LearningCacheDestroyerが期待通りに動作します。

app/models/learning_cache_destroyer.rb (1)

4-8: ActiveSupport::Notifications対応のメソッドシグネチャが正しく実装されています

callメソッドがActiveSupport::Notificationsのサブスクライバーインターフェースに適合するよう正しく更新されています。内部のキャッシュ削除とログ出力ロジックは変更されておらず、動作の一貫性が保たれています。

app/controllers/reports_controller.rb (2)

90-90: 完全移行が適切に実装されています

destroy アクションでは Newspaper.publish から ActiveSupport::Notifications.instrument への完全な移行が行われており、これは適切です。ペイロード形式も一貫性が保たれています。


80-80: ペイロード形式の整合性を確認済みです

SadStreakUpdater が新しい instrument('report.save', report: @report) のペイロード形式(payload[:report])に対応していることを確認しました。

  • app/models/sad_streak_updater.rb
    • def call(_name, _started, _finished, _unique_id, payload) 内で report = payload[:report] を取得
  • config/initializers/active_support_notifications.rb
    • ActiveSupport::Notifications.subscribe('report.save', sad_streak_updater) で正しくサブスクライブ

他に追加対応は不要です。

coderabbitai bot added a commit that referenced this pull request Jul 23, 2025
…ications-in-sad_streak_updater-and-learning_cache_destroyer`

Docstrings generation was requested by @jun-kondo.

* #8977 (comment)

The following files were modified:

* `app/controllers/admin/users_controller.rb`
* `app/controllers/api/practices/learning_controller.rb`
* `app/controllers/reports_controller.rb`
* `app/models/learning_cache_destroyer.rb`
* `app/models/sad_streak_updater.rb`
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jul 23, 2025

Note

Generated docstrings for this pull request at #8981

@jun-kondo jun-kondo force-pushed the chore/replace-newspaper-with-activesupport_notifications-in-sad_streak_updater-and-learning_cache_destroyer branch 2 times, most recently from ced0d44 to b1e4676 Compare July 24, 2025 08:09
@jun-kondo
Copy link
Copy Markdown
Contributor Author

@smallmonkeykey
お疲れ様ですー
お手隙の際にレビューお願いしてもよろしいでしょうか?🙇‍♂️

@smallmonkeykey
Copy link
Copy Markdown
Contributor

@jun-kondo
承知しました!!2-3日以内にお返事します!

@jun-kondo
Copy link
Copy Markdown
Contributor Author

@smallmonkeykey
ありがとうございます🙇‍♂️
急ぎませんので、どうぞよろしくお願い致しますー🙏

Copy link
Copy Markdown
Contributor

@smallmonkeykey smallmonkeykey left a comment

Choose a reason for hiding this comment

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

@jun-kondo
コメントしましたので、ご確認お願いします🙏

Comment on lines +10 to +11
ActiveSupport::Notifications.subscribe('report.create', sad_streak_updater)
ActiveSupport::Notifications.subscribe('report.update', sad_streak_updater)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

背景を確認させてください!
今回、元々の :report_save イベントを report.createreport.update に分けて処理されている意図を教えていただけますか?
私としては、一つのイベントとして report.save として書き換えるでも良いかなと思ったのですが、今回分けることにした理由があれば教えていただけると嬉しいです🙏

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@smallmonkeykey

背景としては、当初はreport.saveで書いていたのですが、メインの変更を取り込んだときにコンフリクトが起きて、コントローラにあるイベントの発行側のコード(ActiveSupport::Notifications.instrument)がreport.createreport.updateでマージされていることに気がついた、というものです。担当箇所が一部他のissueと被っていた感じです。

調べたところ、こちらのプルリクエストでのやり取りを見つけました👀Pull Request #8869
こちらコメントのリンクです👀

迷ったのですが、この書き方で既に合意が取れているのが上記のコメントのやり取りでわかったのでそれに合わせました。

事前に説明しておくべきでした。申し訳ありません🙏

Copy link
Copy Markdown
Contributor

@smallmonkeykey smallmonkeykey left a comment

Choose a reason for hiding this comment

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

@jun-kondo
説明してくださってありがとうございます!納得しました🙆
Approveさせていただきます!

@jun-kondo
Copy link
Copy Markdown
Contributor Author

@smallmonkeykey
ありがとうございますー🙏

@jun-kondo jun-kondo force-pushed the chore/replace-newspaper-with-activesupport_notifications-in-sad_streak_updater-and-learning_cache_destroyer branch from b1e4676 to d2ef468 Compare July 29, 2025 15:12
@jun-kondo
Copy link
Copy Markdown
Contributor Author

@smallmonkeykey
お手隙の際にこちらApproveしていただけますと嬉しいです🙏

@komagata
こちらチームメンバーから承認頂きましたのでレビューよろしくお願い致します🙇‍♂️

@komagata
Copy link
Copy Markdown
Member

@jun-kondo conflictの解消をお願いします。

@jun-kondo jun-kondo force-pushed the chore/replace-newspaper-with-activesupport_notifications-in-sad_streak_updater-and-learning_cache_destroyer branch from d2ef468 to 5965505 Compare July 30, 2025 04:58
@jun-kondo
Copy link
Copy Markdown
Contributor Author

@komagata
conflictの解消を行いました。

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 c868887 into main Jul 30, 2025
5 checks passed
@komagata komagata deleted the chore/replace-newspaper-with-activesupport_notifications-in-sad_streak_updater-and-learning_cache_destroyer branch July 30, 2025 05:42
@github-actions github-actions bot mentioned this pull request Jul 30, 2025
87 tasks
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