FEATURE: allow "developer" account flagging via developers table

This mechanism for flagging developer accounts will eventually replace
DISCOURSE_DEVELOPER_EMAILS
This commit is contained in:
Sam
2016-07-28 10:14:06 +10:00
parent c6dbaca0dc
commit ab68e0c9db
4 changed files with 51 additions and 1 deletions

22
app/models/developer.rb Normal file
View File

@ -0,0 +1,22 @@
require_dependency 'distributed_cache'
class Developer < ActiveRecord::Base
belongs_to :user
after_save :rebuild_cache
after_destroy :rebuild_cache
@id_cache = DistributedCache.new('developer_ids')
def self.user_ids
@id_cache["ids"] ||= rebuild_cache
end
def self.rebuild_cache
@id_cache["ids"] = Set.new(Developer.pluck(:user_id))
end
def rebuild_cache
Developer.rebuild_cache
end
end