discourse/app/models/developer.rb
Sam Saffron 30990006a9 DEV: enable frozen string literal on all files
This reduces chances of errors where consumers of strings mutate inputs
and reduces memory usage of the app.

Test suite passes now, but there may be some stuff left, so we will run
a few sites on a branch prior to merging
2019-05-13 09:31:32 +08:00

33 lines
599 B
Ruby

# frozen_string_literal: true
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
# == Schema Information
#
# Table name: developers
#
# id :integer not null, primary key
# user_id :integer not null
#