FIX: faster update of all badges

Introduced badge triggers, introduced concept of badge that happens due to a post but has the post hidden

Delta badge grant happens once a minute, backed by redis
This commit is contained in:
Sam
2014-07-23 11:42:24 +10:00
parent 007310c4a2
commit 0f9678fe49
18 changed files with 229 additions and 121 deletions

View File

@ -1,6 +1,7 @@
class UserStat < ActiveRecord::Base
belongs_to :user
after_save :trigger_badges
# Updates the denormalized view counts for all users
def self.update_view_counts
@ -64,6 +65,12 @@ class UserStat < ActiveRecord::Base
cache_last_seen(Time.now.to_f)
end
protected
def trigger_badges
BadgeGranter.queue_badge_grant(Badge::Trigger::UserChange, user: self.user)
end
private
def last_seen_key