merry_go_round 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
@@ -43,7 +43,7 @@ module MerryGoRound
|
|
43
43
|
|
44
44
|
# Aggregate existing aggregations (i.e. hour -> day)
|
45
45
|
def compound
|
46
|
-
now = Time.now.utc
|
46
|
+
now = Time.now.utc
|
47
47
|
|
48
48
|
# Loop through all of the granularities except for the first one
|
49
49
|
MerryGoRound.granularities.each_with_index do |granularity, index|
|
@@ -62,10 +62,10 @@ module MerryGoRound
|
|
62
62
|
|
63
63
|
# Loop through the results
|
64
64
|
results.each do |result|
|
65
|
-
timestamp = result.timestamp.to_i
|
66
|
-
while timestamp < now
|
67
|
-
range = window(granularity, Time.at(timestamp))
|
68
|
-
break unless range.last <
|
65
|
+
timestamp = result.timestamp.utc.to_i
|
66
|
+
while timestamp < now.to_i
|
67
|
+
range = window(granularity, Time.at(timestamp).utc)
|
68
|
+
break unless range.first < now and range.last < now
|
69
69
|
|
70
70
|
children = Aggregation.where('key = ? AND granularity = ? AND timestamp >= ? AND timestamp <= ?', result.key, prev_gran, range.first, range.last).order('timestamp ASC')
|
71
71
|
break unless children.length > 0
|
@@ -76,7 +76,6 @@ module MerryGoRound
|
|
76
76
|
|
77
77
|
# Create the aggregation
|
78
78
|
agg = Aggregation.create(key: result.key, value: value, granularity: granularity, timestamp: range.first)
|
79
|
-
# puts agg.inspect
|
80
79
|
|
81
80
|
# Associate the children with their parent
|
82
81
|
children.each do |child|
|
@@ -4,10 +4,10 @@ module MerryGoRound
|
|
4
4
|
class AggregatorTest < TestCase
|
5
5
|
def test_aggregating_from_redis
|
6
6
|
# Load the fixture. There is 60 minutes of data with 3 keys in each minute
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
Timecop.freeze(Time.at(1360695600).utc) do
|
8
|
+
redis_fixture('hour')
|
9
|
+
MerryGoRound.aggregate!
|
10
|
+
end
|
11
11
|
|
12
12
|
# 60 minutes * 3 keys
|
13
13
|
assert_equal 60 * 3, Aggregation.where(granularity: 'minute').count
|
@@ -3,8 +3,10 @@ require 'test_helper'
|
|
3
3
|
module MerryGoRound
|
4
4
|
class QueryTest < TestCase
|
5
5
|
def test_execute
|
6
|
-
|
7
|
-
|
6
|
+
Timecop.freeze(Time.at(1360695600).utc) do
|
7
|
+
redis_fixture('hour')
|
8
|
+
MerryGoRound.aggregate!
|
9
|
+
end
|
8
10
|
|
9
11
|
min = MerryGoRound::Aggregation.minimum(:timestamp).to_i
|
10
12
|
max = MerryGoRound::Aggregation.maximum(:timestamp).to_i
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: merry_go_round
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
152
|
version: '0'
|
153
153
|
segments:
|
154
154
|
- 0
|
155
|
-
hash:
|
155
|
+
hash: 4560439133261810306
|
156
156
|
requirements: []
|
157
157
|
rubyforge_project:
|
158
158
|
rubygems_version: 1.8.23
|