mirror of
https://github.com/jimeh/redistat.git
synced 2026-02-19 13:26:39 +00:00
updated Redistat::Summary to make it easier to plugin the buffer interception code
This commit is contained in:
@@ -194,13 +194,13 @@ describe Redistat::Finder do
|
||||
|
||||
def create_example_stats
|
||||
key = Redistat::Key.new(@scope, @label, (first = Time.parse("2010-05-14 13:43")))
|
||||
Redistat::Summary.update(key, @stats, :hour)
|
||||
Redistat::Summary.send(:update_fields, key, @stats, :hour)
|
||||
key = Redistat::Key.new(@scope, @label, Time.parse("2010-05-14 13:53"))
|
||||
Redistat::Summary.update(key, @stats, :hour)
|
||||
Redistat::Summary.send(:update_fields, key, @stats, :hour)
|
||||
key = Redistat::Key.new(@scope, @label, Time.parse("2010-05-14 14:52"))
|
||||
Redistat::Summary.update(key, @stats, :hour)
|
||||
Redistat::Summary.send(:update_fields, key, @stats, :hour)
|
||||
key = Redistat::Key.new(@scope, @label, (last = Time.parse("2010-05-14 15:02")))
|
||||
Redistat::Summary.update(key, @stats, :hour)
|
||||
Redistat::Summary.send(:update_fields, key, @stats, :hour)
|
||||
[first - 1.hour, last + 1.hour]
|
||||
end
|
||||
|
||||
|
||||
@@ -13,19 +13,19 @@ describe Redistat::Summary do
|
||||
end
|
||||
|
||||
it "should update a single summary properly" do
|
||||
Redistat::Summary.update(@key, @stats, :hour)
|
||||
Redistat::Summary.send(:update_fields, @key, @stats, :hour)
|
||||
summary = db.hgetall(@key.to_s(:hour))
|
||||
summary.should have(2).items
|
||||
summary["views"].should == "3"
|
||||
summary["visitors"].should == "2"
|
||||
|
||||
Redistat::Summary.update(@key, @stats, :hour)
|
||||
Redistat::Summary.send(:update_fields, @key, @stats, :hour)
|
||||
summary = db.hgetall(@key.to_s(:hour))
|
||||
summary.should have(2).items
|
||||
summary["views"].should == "6"
|
||||
summary["visitors"].should == "4"
|
||||
|
||||
Redistat::Summary.update(@key, {"views" => -4, "visitors" => -3}, :hour)
|
||||
Redistat::Summary.send(:update_fields, @key, {"views" => -4, "visitors" => -3}, :hour)
|
||||
summary = db.hgetall(@key.to_s(:hour))
|
||||
summary.should have(2).items
|
||||
summary["views"].should == "2"
|
||||
@@ -48,7 +48,7 @@ describe Redistat::Summary do
|
||||
|
||||
it "should update summaries even if no label is set" do
|
||||
key = Redistat::Key.new(@scope, nil, @date, {:depth => :day})
|
||||
Redistat::Summary.update(key, @stats, :hour)
|
||||
Redistat::Summary.send(:update_fields, key, @stats, :hour)
|
||||
summary = db.hgetall(key.to_s(:hour))
|
||||
summary.should have(2).items
|
||||
summary["views"].should == "3"
|
||||
|
||||
Reference in New Issue
Block a user