mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 20:44:40 +08:00
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:
@ -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
|
||||
|
Reference in New Issue
Block a user