class Almicube::Aggregator::Base
Public Class Methods
connection()
click to toggle source
# File lib/almicube/aggregator/base.rb, line 7 def connection @redis ||= Almicube::Config.config.connection end
Public Instance Methods
aggregate(ranking=nil)
click to toggle source
# File lib/almicube/aggregator/base.rb, line 12 def aggregate(ranking=nil) self.ranking = ranking unless active? || ranking.nil? if self.ranking.data? data_aggregate self.ranking.key else sub_aggregate self.ranking.key end end
Protected Instance Methods
data_aggregate(key)
click to toggle source
# File lib/almicube/aggregator/base.rb, line 24 def data_aggregate(key) ranking.records.each do |record| value = record.send(ranking.attribute_name) if record.respond_to? ranking.attribute_name value = ranking.default_score if value.nil? self.class.connection.zadd(key, value, record.to_param) end end