Sha256: 75522f29ed15b6011544b10582ddc2452485aa42dcec4f9dd944719e7e364665
Contents?: true
Size: 921 Bytes
Versions: 5
Compression:
Stored size: 921 Bytes
Contents
module DataSets def dataset(name,&block) @datasets ||= {} @datasets[name] = block end def run_dataset_collector(dat,rcv=nil,host=nil) @datasets.map do |(name,dataset)| dataset.call(dat) end if @datasets end def get_data_set(data_set_name,s_time,e_time=Time.now,host=host) CityWatch.redis.zrevrangebyscore(data_set_key(data_set_name,host), s_time.to_i, e_time.to_i, :with_scores => true).map do |(val,score)| timestamp,value = val.split(",") [Time.at(timestamp.to_i),value] end end def data_set_key(data_set_name,host=host) CityWatch.redis.sadd "#{CityWatch.config[:prefix]}::#{host}::#{self.name}::data_sets", data_set_name "#{CityWatch.config[:prefix]}::#{host}::#{self.name}::data_set::#{data_set_name}" end def add_to_data_set(data_set_name,val,time=Time.now,host=host) CityWatch.redis.zadd data_set_key(data_set_name,host), time.to_i, "#{Time.now.to_i},#{val}" end end
Version data entries
5 entries across 5 versions & 1 rubygems