From 8bba66e01872a624d9a02133525a529240ff0b34 Mon Sep 17 00:00:00 2001 From: jun-kondo Date: Sat, 19 Jul 2025 16:50:43 +0900 Subject: [PATCH 1/3] =?UTF-8?q?ReportNotifier=E3=82=92Newspaper=E3=81=8B?= =?UTF-8?q?=E3=82=89ActiveSupport::Notifications=E3=81=B8=E7=A7=BB?= =?UTF-8?q?=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/report_notifier.rb | 2 +- config/initializers/active_support_notifications.rb | 2 ++ config/initializers/newspaper.rb | 2 -- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/report_notifier.rb b/app/models/report_notifier.rb index 652f263529d..db793737dbd 100644 --- a/app/models/report_notifier.rb +++ b/app/models/report_notifier.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class ReportNotifier - def call(payload) + def call(_name, _started, _finished, _unique_id, payload) report = payload[:report] Cache.delete_unchecked_report_count diff --git a/config/initializers/active_support_notifications.rb b/config/initializers/active_support_notifications.rb index 00470e88461..b8fed969633 100644 --- a/config/initializers/active_support_notifications.rb +++ b/config/initializers/active_support_notifications.rb @@ -8,6 +8,8 @@ ActiveSupport::Notifications.subscribe('regular_event.create', RegularEventOrganizerWatcher.new) ActiveSupport::Notifications.subscribe('report.create', FirstReportNotifier.new) ActiveSupport::Notifications.subscribe('report.update', FirstReportNotifier.new) + ActiveSupport::Notifications.subscribe('report.create', ReportNotifier.new) + ActiveSupport::Notifications.subscribe('report.update', ReportNotifier.new) ActiveSupport::Notifications.subscribe('announcement.create', AnnouncementNotifier.new) ActiveSupport::Notifications.subscribe('announcement.update', AnnouncementNotifier.new) ActiveSupport::Notifications.subscribe('announcement.destroy', AnnouncementNotificationDestroyer.new) diff --git a/config/initializers/newspaper.rb b/config/initializers/newspaper.rb index 82f261cdfcf..7874c5540ba 100644 --- a/config/initializers/newspaper.rb +++ b/config/initializers/newspaper.rb @@ -5,8 +5,6 @@ Newspaper.subscribe(:report_save, sad_streak_updater) Newspaper.subscribe(:report_destroy, sad_streak_updater) - Newspaper.subscribe(:report_save, ReportNotifier.new) - learning_cache_destroyer = LearningCacheDestroyer.new Newspaper.subscribe(:learning_create, learning_cache_destroyer) Newspaper.subscribe(:learning_destroy, learning_cache_destroyer) From 25004373a8ab34cde1d890caff196eeb708e3476 Mon Sep 17 00:00:00 2001 From: jun-kondo Date: Sat, 19 Jul 2025 17:57:50 +0900 Subject: [PATCH 2/3] =?UTF-8?q?WorkNotificationDestroyer=E3=82=92Newspaper?= =?UTF-8?q?=E3=81=8B=E3=82=89ActiveSupport::Notifications=E3=81=B8?= =?UTF-8?q?=E7=A7=BB=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/works_controller.rb | 2 +- app/models/work_notification_destroyer.rb | 2 +- config/initializers/active_support_notifications.rb | 1 + config/initializers/newspaper.rb | 3 --- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/controllers/works_controller.rb b/app/controllers/works_controller.rb index 856ce9a9b13..972363e72a8 100644 --- a/app/controllers/works_controller.rb +++ b/app/controllers/works_controller.rb @@ -44,7 +44,7 @@ def update def destroy @work.destroy - Newspaper.publish(:work_destroy, { work: @work }) + ActiveSupport::Notifications.instrument('work.destroy', work: @work) redirect_to user_portfolio_url(@work.user), notice: 'ポートフォリオから作品を削除しました。' end diff --git a/app/models/work_notification_destroyer.rb b/app/models/work_notification_destroyer.rb index cb1dcf4d80b..5c8d56b9753 100644 --- a/app/models/work_notification_destroyer.rb +++ b/app/models/work_notification_destroyer.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class WorkNotificationDestroyer - def call(payload) + def call(_name, _started, _finished, _unique_id, payload) work = payload[:work] Notification.where(link: "/works/#{work.id}").destroy_all diff --git a/config/initializers/active_support_notifications.rb b/config/initializers/active_support_notifications.rb index b8fed969633..6492ba9a27a 100644 --- a/config/initializers/active_support_notifications.rb +++ b/config/initializers/active_support_notifications.rb @@ -16,6 +16,7 @@ ActiveSupport::Notifications.subscribe('article.create', ArticleNotifier.new) ActiveSupport::Notifications.subscribe('article.destroy', ArticleNotificationDestroyer.new) ActiveSupport::Notifications.subscribe('work.create', WorkNotifier.new) + ActiveSupport::Notifications.subscribe('work.destroy', WorkNotificationDestroyer.new) ActiveSupport::Notifications.subscribe('product.create', ProductAuthorWatcher.new) ActiveSupport::Notifications.subscribe('product.create', ProductNotifierForColleague.new) ActiveSupport::Notifications.subscribe('product.create', ProductNotifierForPracticeWatcher.new) diff --git a/config/initializers/newspaper.rb b/config/initializers/newspaper.rb index 7874c5540ba..94057342109 100644 --- a/config/initializers/newspaper.rb +++ b/config/initializers/newspaper.rb @@ -51,8 +51,5 @@ Newspaper.subscribe(:product_update, ProductUpdateNotifierForChecker.new) Newspaper.subscribe(:came_comment, CommentNotifier.new) Newspaper.subscribe(:came_comment_in_talk, CommentNotifierForAdmin.new) - - Newspaper.subscribe(:work_destroy, WorkNotificationDestroyer.new) - Newspaper.subscribe(:came_inquiry, InquiryNotifier.new) end From ba4dc91155eae95a6c71c99683b75f2304ce7df1 Mon Sep 17 00:00:00 2001 From: jun-kondo Date: Sat, 19 Jul 2025 18:59:40 +0900 Subject: [PATCH 3/3] =?UTF-8?q?InquiryNotifier=E3=82=92Newspaper=E3=81=8B?= =?UTF-8?q?=E3=82=89ActiveSupport::Notifications=E3=81=B8=E7=A7=BB?= =?UTF-8?q?=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/inquiries_controller.rb | 2 +- app/models/inquiry_notifier.rb | 2 +- config/initializers/active_support_notifications.rb | 1 + config/initializers/newspaper.rb | 1 - 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/inquiries_controller.rb b/app/controllers/inquiries_controller.rb index f0bd71c7ec3..6046caaa7b0 100644 --- a/app/controllers/inquiries_controller.rb +++ b/app/controllers/inquiries_controller.rb @@ -13,7 +13,7 @@ def create result = valid_recaptcha?('inquiry') if result && @inquiry.save - Newspaper.publish(:came_inquiry, { inquiry: @inquiry }) + ActiveSupport::Notifications.instrument('came.inquiry', inquiry: @inquiry) InquiryMailer.incoming(@inquiry).deliver_later redirect_to new_inquiry_url, notice: 'お問い合わせを送信しました。' else diff --git a/app/models/inquiry_notifier.rb b/app/models/inquiry_notifier.rb index fc51872db3a..921a0629f33 100644 --- a/app/models/inquiry_notifier.rb +++ b/app/models/inquiry_notifier.rb @@ -3,7 +3,7 @@ class InquiryNotifier NOTIFICATION_SENDER_NAME = 'pjord' - def call(payload) + def call(_name, _started, _finished, _unique_id, payload) inquiry = payload[:inquiry] return if inquiry.nil? diff --git a/config/initializers/active_support_notifications.rb b/config/initializers/active_support_notifications.rb index 6492ba9a27a..e2cf940ebf2 100644 --- a/config/initializers/active_support_notifications.rb +++ b/config/initializers/active_support_notifications.rb @@ -20,4 +20,5 @@ ActiveSupport::Notifications.subscribe('product.create', ProductAuthorWatcher.new) ActiveSupport::Notifications.subscribe('product.create', ProductNotifierForColleague.new) ActiveSupport::Notifications.subscribe('product.create', ProductNotifierForPracticeWatcher.new) + ActiveSupport::Notifications.subscribe('came.inquiry', InquiryNotifier.new) end diff --git a/config/initializers/newspaper.rb b/config/initializers/newspaper.rb index 94057342109..2ef00f64851 100644 --- a/config/initializers/newspaper.rb +++ b/config/initializers/newspaper.rb @@ -51,5 +51,4 @@ Newspaper.subscribe(:product_update, ProductUpdateNotifierForChecker.new) Newspaper.subscribe(:came_comment, CommentNotifier.new) Newspaper.subscribe(:came_comment_in_talk, CommentNotifierForAdmin.new) - Newspaper.subscribe(:came_inquiry, InquiryNotifier.new) end