Class: Workarea::SynchronizeUserMetrics

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::CallbacksWorker, Sidekiq::Worker
Defined in:
app/workers/workarea/synchronize_user_metrics.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.enabled?Boolean

It’s essential for the Metrics::User#admin field always be in sync, so we always want this worker enabled.

Returns:

  • (Boolean)


16
17
18
# File 'app/workers/workarea/synchronize_user_metrics.rb', line 16

def self.enabled?
  true
end

Instance Method Details

#perform(id) ⇒ Object



20
21
22
23
24
# File 'app/workers/workarea/synchronize_user_metrics.rb', line 20

def perform(id)
  user = User.find(id)
  metrics = Metrics::User.find_or_create_by(id: user.email)
  metrics.set(admin: user.admin?, tags: user.tags)
end