* This change abstracts the DatadogStatsClient into a ForemStatsClient. The purpose of this abstraction is to set the foundation for a subsequent PR that will allow one to use New Relic for recording Forem stats, instead of Datadog, if there is a New Relic configuration found. This specific change creates an abstraction layer that can be built upon, without changing any actual default behavior. All specs still pass. * Use delegate instead of explicit methods. * Delegate instead of explicit methods. * Fix the error. * Refactor according to the suggestions in the comments. * Ooops. Stats work better when all of the code is committed. * Removing the alias of count to increment since that was done in error.
16 lines
475 B
Ruby
16 lines
475 B
Ruby
module Moderator
|
|
class BanishUserWorker
|
|
include Sidekiq::Worker
|
|
|
|
sidekiq_options queue: :high_priority, retry: 10
|
|
|
|
def perform(admin_id, abuser_id)
|
|
abuser = User.find(abuser_id)
|
|
admin = User.find(admin_id)
|
|
Moderator::BanishUser.call(admin: admin, user: abuser)
|
|
rescue StandardError => e
|
|
ForemStatsClient.count("moderators.banishuser", 1, tags: ["action:failed", "user_id:#{abuser.id}"])
|
|
Honeybadger.notify(e)
|
|
end
|
|
end
|
|
end
|