added enable_grouping option to disable grouping features, enabled by default

This commit is contained in:
2011-03-04 13:02:20 +00:00
parent 7b1feda061
commit fe221c3f31
3 changed files with 18 additions and 4 deletions

View File

@@ -31,7 +31,10 @@ module Redistat
end
def default_options
{ :depth => :hour, :store_event => false, :connection_ref => nil }
{ :depth => :hour,
:store_event => false,
:connection_ref => nil,
:enable_grouping => true }
end
def new?
@@ -72,7 +75,7 @@ module Redistat
def save
return false if !self.new?
Summary.update_all(@key, @stats, depth_limit, @connection_ref)
Summary.update_all(@key, @stats, depth_limit, @connection_ref, @options[:enable_grouping])
if @options[:store_event]
@id = self.next_id
db.hmset("#{self.scope}#{KEY_EVENT}#{@id}",

View File

@@ -2,9 +2,10 @@ module Redistat
class Summary
include Database
def self.update_all(key, stats = {}, depth_limit = nil, connection_ref = nil)
def self.update_all(key, stats = {}, depth_limit = nil, connection_ref = nil, enable_grouping = nil)
stats ||= {}
stats = inject_group_summaries(stats)
enable_grouping = true if enable_grouping.nil?
stats = inject_group_summaries(stats) if enable_grouping
depth_limit ||= key.depth
return nil if stats.size == 0
Date::DEPTHS.each do |depth|