Class: Scorecard::Scorer
- Inherits:
-
Object
- Object
- Scorecard::Scorer
- Defined in:
- lib/scorecard/scorer.rb
Class Method Summary collapse
- .level(user) ⇒ Object
- .points(context, options) ⇒ Object
- .points_async(context, options) ⇒ Object
- .refresh(options) ⇒ Object
- .refresh_async(options) ⇒ Object
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, ) ActiveSupport::Notifications.instrument 'points.internal.scorecard', .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, ) Scorecard::ScoreWorker.perform_async context, Scorecard::Parameters.new(). end |
.refresh(options) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/scorecard/scorer.rb', line 21 def self.refresh() ActiveSupport::Notifications.instrument 'progress.internal.scorecard', ActiveSupport::Notifications.instrument 'badge.internal.scorecard', end |
.refresh_async(options) ⇒ Object
28 29 30 31 32 |
# File 'lib/scorecard/scorer.rb', line 28 def self.refresh_async() Scorecard::RefreshWorker.perform_async( Scorecard::Parameters.new(). ) end |