Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/controllers/api/checks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def create
user: current_user,
checkable:
)
Newspaper.publish(:check_create, { check: @check })
ActiveSupport::Notifications.instrument('check.create', check: @check)
head :created
else
render json: { message: "この#{checkable.class.model_name.human}は確認済です。" }, status: :unprocessable_entity
Expand All @@ -24,7 +24,7 @@ def create

def destroy
@check = Check.find(params[:id]).destroy
Newspaper.publish(:check_cancel, { check: @check })
ActiveSupport::Notifications.instrument('check.cancel', check: @check)

head :no_content
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/products_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def create
update_published_at
if @product.save
ActiveSupport::Notifications.instrument('product.create', product: @product)
Newspaper.publish(:product_save, { product: @product })
ActiveSupport::Notifications.instrument('product.save', product: @product)
redirect_to Redirection.determin_url(self, @product), notice: notice_message(@product, :create)
else
render :new
Expand All @@ -61,7 +61,7 @@ def update
update_published_at
if @product.update(product_params)
Newspaper.publish(:product_update, { product: @product, current_user: })
Newspaper.publish(:product_save, { product: @product })
ActiveSupport::Notifications.instrument('product.save', product: @product)
notice_another_mentor_assigned_as_checker
redirect_to Redirection.determin_url(self, @product), notice: notice_message(@product, :update)
else
Expand Down
2 changes: 1 addition & 1 deletion app/models/learning_status_updater.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class LearningStatusUpdater
def call(payload)
def call(_name, _started, _finished, _id, payload)
product_or_associated_object = payload[:product] || payload[:check]
case product_or_associated_object
when Product
Expand Down
5 changes: 5 additions & 0 deletions config/initializers/active_support_notifications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,9 @@
ActiveSupport::Notifications.subscribe('product.create', ProductNotifierForColleague.new)
ActiveSupport::Notifications.subscribe('product.create', ProductNotifierForPracticeWatcher.new)
ActiveSupport::Notifications.subscribe('came.inquiry', InquiryNotifier.new)

learning_status_updater = LearningStatusUpdater.new
ActiveSupport::Notifications.subscribe('product.save', learning_status_updater)
ActiveSupport::Notifications.subscribe('check.create', learning_status_updater)
ActiveSupport::Notifications.subscribe('check.cancel', learning_status_updater)
end
5 changes: 0 additions & 5 deletions config/initializers/newspaper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@

Newspaper.subscribe(:comeback_update, ComebackNotifier.new)

learning_status_updater = LearningStatusUpdater.new
Newspaper.subscribe(:check_create, learning_status_updater)
Newspaper.subscribe(:product_save, learning_status_updater)
Newspaper.subscribe(:check_cancel, learning_status_updater)

page_notifier = PageNotifier.new
Newspaper.subscribe(:page_create, page_notifier)
Newspaper.subscribe(:page_update, page_notifier)
Expand Down