Skip to content

LearningStatusUpdaterをNewspaperからActiveSupport::Notificationsに移行#8938

Merged
komagata merged 1 commit intomainfrom
chore/replace-newspaper-with-activesupport-nofitications-for-learning-status-updater
Jul 28, 2025
Merged

LearningStatusUpdaterをNewspaperからActiveSupport::Notificationsに移行#8938
komagata merged 1 commit intomainfrom
chore/replace-newspaper-with-activesupport-nofitications-for-learning-status-updater

Conversation

@matuaya
Copy link
Copy Markdown
Contributor

@matuaya matuaya commented Jul 16, 2025

Issue

概要

LearningStatusUpdaterクラスをnewspaperからActiveSupport::Notificationsのsubscribeの仕組みに移行しました。
AnswererWatcherをnewspaperからActiveSupport::Notificationsに移行のPRを参考にしました。

変更確認方法

  1. ブランチchore/replace-newspaper-with-activesupport-nofitications-for-learning-status-updaterをローカルに取り込む
  2. foreman start -f Procfile.devでローカル環境を立ち上げる
  3. 以下のテストが通ることを確認
    bin/rails test test/system/products_test.rb:105
    bin/rails test test/system/products_test.rb:133
  4. 以下の動作を確認
  • 提出物をWIPにした時や提出した際に、プラクティスのステータスが「未着手」から適切なステータスに変更されること
    (「着手」や「提出」)
スクリーンショット 2025-07-16 19 41 19
  • 提出物が合格した時にプラティスのステータスが「修了」に変更されてること
スクリーンショット 2025-07-16 19 40 18

Screenshot

UIに変化がなかったためスクリーンショットは省略しています。

Summary by CodeRabbit

Summary by CodeRabbit

  • 新機能

    • プロダクト作成・更新時やチェック作成・キャンセル時に新しい通知イベントが追加されました。
  • リファクタ

    • イベント通知の仕組みが標準的な通知システムに置き換えられ、より一貫性が向上しました。
  • その他

    • イベント購読設定が整理され、通知の管理が最適化されました。

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jul 16, 2025

"""

Walkthrough

この変更は、イベントのブロードキャストとサブスクライブの仕組みを Newspaper から ActiveSupport::Notifications に移行し、関連するコントローラー、モデル、イニシャライザのロジックを更新しています。イベント購読の登録・解除やメソッドシグネチャの調整も含まれています。

Changes

ファイル群 変更概要
コントローラーのイベント発行置換
app/controllers/api/checks_controller.rb, app/controllers/products_controller.rb
Newspaper.publishActiveSupport::Notifications.instrument に置換し、イベント名やペイロードを調整
モデルの通知受信メソッド修正
app/models/learning_status_updater.rb
call メソッドのシグネチャを通知イベントの標準引数に対応して変更(4つの引数を追加)
ActiveSupport通知の購読追加
config/initializers/active_support_notifications.rb
LearningStatusUpdater'product.save', 'check.create', 'check.cancel' イベントにサブスクライブするロジックを追加
Newspaper購読解除
config/initializers/newspaper.rb
LearningStatusUpdater のイベント購読登録を削除

Sequence Diagram(s)

sequenceDiagram
    participant Controller as Controller (Product/Check)
    participant ActiveSupport as ActiveSupport::Notifications
    participant Updater as LearningStatusUpdater

    Controller->>ActiveSupport: instrument('product.save' / 'check.create' / 'check.cancel', payload)
    ActiveSupport-->>Updater: 通知イベントを購読者に送信
    Updater->>Updater: call(_name, _started, _finished, _id, payload)
    Updater->>Updater: payloadに応じて update_after_submission / update_after_check を実行
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers

  • thmz337
  • 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/models/learning_status_updater.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/checks_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/products_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

'

  • 1 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 c3b4c3d and 87f9c83.

📒 Files selected for processing (5)
  • app/controllers/api/checks_controller.rb (2 hunks)
  • app/controllers/products_controller.rb (2 hunks)
  • app/models/learning_status_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
🚧 Files skipped from review as they are similar to previous changes (4)
  • config/initializers/active_support_notifications.rb
  • app/controllers/api/checks_controller.rb
  • app/models/learning_status_updater.rb
  • app/controllers/products_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-nofitications-for-learning-status-updater

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.

@matuaya
Copy link
Copy Markdown
Contributor Author

matuaya commented Jul 16, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jul 16, 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.

@matuaya matuaya marked this pull request as ready for review July 16, 2025 11:06
@matuaya
Copy link
Copy Markdown
Contributor Author

matuaya commented Jul 16, 2025

@thmz337
はじめまして!
ご都合よろしければ、レビューをお願いできますでしょうか?

@matuaya matuaya self-assigned this Jul 16, 2025
@thmz337
Copy link
Copy Markdown
Contributor

thmz337 commented Jul 16, 2025

@matuaya

お疲れ様です!レビュー承知しました。
1週間ほどいただくと思いますが、問題ないでしょうか。

@matuaya
Copy link
Copy Markdown
Contributor Author

matuaya commented Jul 16, 2025

@thmz337
ありがとうございます!
時間は問題ありませんのでよろしくお願いいたします🙏

@matuaya matuaya requested a review from thmz337 July 16, 2025 17:12
@matuaya matuaya force-pushed the chore/replace-newspaper-with-activesupport-nofitications-for-learning-status-updater branch from e9cd100 to c3b4c3d Compare July 24, 2025 18:58
@thmz337
Copy link
Copy Markdown
Contributor

thmz337 commented Jul 25, 2025

@matuaya

お疲れ様です。問題なさそうですので、approveさせていただきます。

@matuaya
Copy link
Copy Markdown
Contributor Author

matuaya commented Jul 25, 2025

@thmz337
レビューありがとうございました!🙇‍♀️

@komagata
メンバーのApproveをいただきましたのでレビューよろしくお願いいたします🙇‍♀️

@matuaya matuaya requested a review from komagata July 25, 2025 18:44
@komagata
Copy link
Copy Markdown
Member

@matuaya conflictの修正をお願いします〜

@matuaya matuaya force-pushed the chore/replace-newspaper-with-activesupport-nofitications-for-learning-status-updater branch from c3b4c3d to 87f9c83 Compare July 28, 2025 07:47
@matuaya
Copy link
Copy Markdown
Contributor Author

matuaya commented Jul 28, 2025

@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 93c3adb into main Jul 28, 2025
5 checks passed
@komagata komagata deleted the chore/replace-newspaper-with-activesupport-nofitications-for-learning-status-updater branch July 28, 2025 19:00
@github-actions github-actions bot mentioned this pull request Jul 28, 2025
87 tasks
@komagata
Copy link
Copy Markdown
Member

@matuaya 本番環境で確認してOKでした〜

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