nightfury 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
data/lib/nightfury.rb
CHANGED
@@ -39,6 +39,7 @@ require "nightfury/version"
|
|
39
39
|
require "nightfury/metric"
|
40
40
|
require "nightfury/metric/value"
|
41
41
|
require "nightfury/metric/time_series"
|
42
|
+
require "nightfury/metric/count_time_series"
|
42
43
|
require "nightfury/metric/avg_time_series"
|
43
44
|
require "nightfury/identity"
|
44
45
|
|
data/lib/nightfury/identity.rb
CHANGED
@@ -5,7 +5,8 @@ module Nightfury
|
|
5
5
|
METRIC_MAPPINGS = {
|
6
6
|
:value => Nightfury::Metric::Value,
|
7
7
|
:time_series => Nightfury::Metric::TimeSeries,
|
8
|
-
:avg_time_series => Nightfury::Metric::AvgTimeSeries
|
8
|
+
:avg_time_series => Nightfury::Metric::AvgTimeSeries,
|
9
|
+
:count_time_series => Nightfury::Metric::CountTimeSeries
|
9
10
|
}
|
10
11
|
|
11
12
|
class << self
|
@@ -21,7 +21,7 @@ module Nightfury
|
|
21
21
|
data_point = ''
|
22
22
|
if timestamp
|
23
23
|
timestamp = timestamp.to_i
|
24
|
-
data_point = redis.zrangebyscore(redis_key,
|
24
|
+
data_point = redis.zrangebyscore(redis_key, 0, timestamp, withscores: true)
|
25
25
|
data_point = data_point.each_slice(2).map {|pair| pair }.last
|
26
26
|
else
|
27
27
|
data_point = redis.zrevrange(redis_key, 0, 0, withscores: true)
|
data/lib/nightfury/version.rb
CHANGED
@@ -45,9 +45,19 @@ describe Nightfury::Metric::TimeSeries do
|
|
45
45
|
result[time_now.to_i.to_s].should == '1'
|
46
46
|
end
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
context "no data point at the timestamp" do
|
49
|
+
it "should return nil if there are no data points in the time series" do
|
50
|
+
ts_metric = Nightfury::Metric::TimeSeries.new(:time)
|
51
|
+
ts_metric.get(Time.now).should be_nil
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should return the nearest data point in the past" do
|
55
|
+
ts_metric = Nightfury::Metric::TimeSeries.new(:time)
|
56
|
+
set_time = Time.now - 60
|
57
|
+
ts_metric.set(1, set_time)
|
58
|
+
result = ts_metric.get(Time.now)
|
59
|
+
result[set_time.to_i.to_s].should == '1'
|
60
|
+
end
|
51
61
|
end
|
52
62
|
end
|
53
63
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nightfury
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2013-01-07 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: Nightfury is a reporting/analytics backend written on Redis
|
16
16
|
email:
|