lib/redistat/summary.rb in redistat-0.2.1 vs lib/redistat/summary.rb in redistat-0.2.2

- old
+ new

@@ -16,14 +16,14 @@ depth_limit ||= key.depth if options[:enable_grouping] stats = inject_group_summaries(stats) - key.groups.each { |k| + key.groups.each do |k| update_key(k, stats, depth_limit, options[:connection_ref]) k.update_index if options[:label_indexing] - } + end else update_key(key, stats, depth_limit, options[:connection_ref]) end end @@ -41,22 +41,23 @@ db(connection_ref).hincrby key.to_s(depth), field, value end end def self.inject_group_summaries!(stats) + summaries = {} stats.each do |key, value| parts = key.to_s.split(GROUP_SEPARATOR) parts.pop if parts.size > 0 sum_parts = [] parts.each do |part| sum_parts << part sum_key = sum_parts.join(GROUP_SEPARATOR) - (stats.has_key?(sum_key)) ? stats[sum_key] += value : stats[sum_key] = value + (summaries.has_key?(sum_key)) ? summaries[sum_key] += value : summaries[sum_key] = value end end end - stats + stats.merge_and_incr!(summaries) end def self.inject_group_summaries(stats) inject_group_summaries!(stats.clone) end \ No newline at end of file