Class: Scorecard::Scorer

Inherits:
Object
  • Object
show all
Defined in:
lib/scorecard/scorer.rb

Class Method Summary collapse

Class Method Details

.level(user) ⇒ Object



2
3
4
5
6
7
8
9
# File 'lib/scorecard/scorer.rb', line 2

def self.level(user)
  level = Scorecard::Level.for_user(user) || Scorecard::Level.new(user: user)
  level.amount = Scorecard.levels.call user
  return unless level.amount_changed?

  level.save
  ActiveSupport::Notifications.instrument 'level.scorecard', user: user
end

.points(context, options) ⇒ Object



11
12
13
14
# File 'lib/scorecard/scorer.rb', line 11

def self.points(context, options)
  ActiveSupport::Notifications.instrument 'points.internal.scorecard',
    options.merge(context: context)
end

.points_async(context, options) ⇒ Object



16
17
18
19
# File 'lib/scorecard/scorer.rb', line 16

def self.points_async(context, options)
  Scorecard::ScoreWorker.perform_async context,
    Scorecard::Parameters.new(options).expand
end

.refresh(options) ⇒ Object



21
22
23
24
25
26
# File 'lib/scorecard/scorer.rb', line 21

def self.refresh(options)
  ActiveSupport::Notifications.instrument 'progress.internal.scorecard',
    options
  ActiveSupport::Notifications.instrument 'badge.internal.scorecard',
    options
end

.refresh_async(options) ⇒ Object



28
29
30
31
32
# File 'lib/scorecard/scorer.rb', line 28

def self.refresh_async(options)
  Scorecard::RefreshWorker.perform_async(
    Scorecard::Parameters.new(options).expand
  )
end