chawk 0.1.15 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.pryrc +10 -0
- data/.travis.yml +0 -2
- data/CHANGES +5 -0
- data/chawk.gemspec +5 -6
- data/lib/chawk.rb +48 -35
- data/lib/chawk/migration.rb +92 -0
- data/lib/chawk/version.rb +1 -1
- data/lib/models.rb +145 -80
- data/test/lib/addr_test.rb +23 -16
- data/test/lib/failed_node_test.rb +18 -0
- data/test/lib/paddr_test.rb +128 -110
- data/test/lib/vaddr_test.rb +160 -160
- data/test/schema.rb +60 -0
- data/test/test_helper.rb +13 -9
- metadata +34 -18
- data/lib/addr.rb +0 -108
- data/lib/paddr.rb +0 -59
- data/lib/store.rb +0 -124
- data/lib/vaddr.rb +0 -23
data/test/schema.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# This file is auto-generated from the current state of the database. Instead
|
2
|
+
# of editing this file, please use the migrations feature of Active Record to
|
3
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
4
|
+
#
|
5
|
+
# Note that this schema.rb definition is the authoritative source for your
|
6
|
+
# database schema. If you need to create the application database on another
|
7
|
+
# system, you should be using db:schema:load, not running all the migrations
|
8
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
9
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
10
|
+
#
|
11
|
+
# It's strongly recommended that you check this file into your version control system.
|
12
|
+
|
13
|
+
ActiveRecord::Schema.define(version: 0) do
|
14
|
+
|
15
|
+
create_table "chawk_agents", force: true do |t|
|
16
|
+
t.integer "foreign_id"
|
17
|
+
t.string "name", limit: 200
|
18
|
+
t.datetime "created_at"
|
19
|
+
t.datetime "updated_at"
|
20
|
+
end
|
21
|
+
|
22
|
+
create_table "chawk_nodes", force: true do |t|
|
23
|
+
t.string "key", limit: 150
|
24
|
+
t.text "decription"
|
25
|
+
t.boolean "public_read", default: false
|
26
|
+
t.boolean "public_write", default: false
|
27
|
+
end
|
28
|
+
|
29
|
+
create_table "chawk_points", force: true do |t|
|
30
|
+
t.float "observed_at"
|
31
|
+
t.datetime "recorded_at"
|
32
|
+
t.text "meta"
|
33
|
+
t.integer "value"
|
34
|
+
t.integer "node_id", null: false
|
35
|
+
end
|
36
|
+
|
37
|
+
add_index "chawk_points", ["node_id"], name: "index_chawk_points_node"
|
38
|
+
|
39
|
+
create_table "chawk_relations", force: true do |t|
|
40
|
+
t.boolean "admin", default: false
|
41
|
+
t.boolean "read", default: false
|
42
|
+
t.boolean "write", default: false
|
43
|
+
t.integer "agent_id", null: false
|
44
|
+
t.integer "node_id", null: false
|
45
|
+
end
|
46
|
+
|
47
|
+
add_index "chawk_relations", ["agent_id"], name: "index_chawk_relations_agent"
|
48
|
+
add_index "chawk_relations", ["node_id"], name: "index_chawk_relations_node"
|
49
|
+
|
50
|
+
create_table "chawk_values", force: true do |t|
|
51
|
+
t.float "observed_at"
|
52
|
+
t.datetime "recorded_at"
|
53
|
+
t.text "meta"
|
54
|
+
t.text "value"
|
55
|
+
t.integer "node_id", null: false
|
56
|
+
end
|
57
|
+
|
58
|
+
add_index "chawk_values", ["node_id"], name: "index_chawk_values_node"
|
59
|
+
|
60
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -17,17 +17,21 @@ ARGV.clear
|
|
17
17
|
|
18
18
|
ENV["CHAWK_DEBUG"] ? debug_level=ENV["CHAWK_DEBUG"] : debug_level=:info
|
19
19
|
|
20
|
-
if ENV["TEST_DATABASE_LOG"]
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
#if ENV["TEST_DATABASE_LOG"]
|
21
|
+
# ActiveRecord::Base.logger = Logger.new(STDOUT)
|
22
|
+
#end
|
23
|
+
|
24
|
+
require 'active_record'
|
25
25
|
|
26
|
-
if ENV["
|
27
|
-
|
26
|
+
if ENV["TEST_DATABASE_URLX"]
|
27
|
+
ActiveRecord::Base.establish_connection ENV["TEST_DATABASE_URL"]
|
28
28
|
else
|
29
|
-
|
30
|
-
|
29
|
+
ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
|
30
|
+
require "chawk/migration"
|
31
31
|
end
|
32
32
|
|
33
|
+
|
34
|
+
load File.dirname(__FILE__) + '/schema.rb'
|
35
|
+
require File.dirname(__FILE__) + '/../lib/models.rb'
|
36
|
+
|
33
37
|
Chawk.clear_all_data!
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chawk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Russell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 4.0.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 4.0.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 5.3.
|
61
|
+
version: 5.3.1
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 5.3.
|
68
|
+
version: 5.3.1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rack-test
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,30 +98,44 @@ dependencies:
|
|
98
98
|
name: simplecov
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - '='
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 0.8.2
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 0.8.2
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pg
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.17.1
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.17.1
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
126
|
+
name: sqlite3
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
129
|
- - '='
|
116
130
|
- !ruby/object:Gem::Version
|
117
|
-
version: 1.
|
131
|
+
version: 1.3.9
|
118
132
|
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
136
|
- - '='
|
123
137
|
- !ruby/object:Gem::Version
|
124
|
-
version: 1.
|
138
|
+
version: 1.3.9
|
125
139
|
description: A storage engine for time-series data. Eventually to include resampling,
|
126
140
|
statistical and aggregate data management.
|
127
141
|
email:
|
@@ -131,6 +145,7 @@ extensions: []
|
|
131
145
|
extra_rdoc_files: []
|
132
146
|
files:
|
133
147
|
- ".gitignore"
|
148
|
+
- ".pryrc"
|
134
149
|
- ".travis.yml"
|
135
150
|
- CHANGES
|
136
151
|
- Gemfile
|
@@ -138,19 +153,18 @@ files:
|
|
138
153
|
- README.md
|
139
154
|
- Rakefile
|
140
155
|
- chawk.gemspec
|
141
|
-
- lib/addr.rb
|
142
156
|
- lib/chawk.rb
|
143
157
|
- lib/chawk/Jackdaw.svg
|
158
|
+
- lib/chawk/migration.rb
|
144
159
|
- lib/chawk/version.rb
|
145
160
|
- lib/models.rb
|
146
|
-
- lib/paddr.rb
|
147
161
|
- lib/quantizer.rb
|
148
|
-
- lib/store.rb
|
149
|
-
- lib/vaddr.rb
|
150
162
|
- test/lib/addr_test.rb
|
163
|
+
- test/lib/failed_node_test.rb
|
151
164
|
- test/lib/paddr_test.rb
|
152
165
|
- test/lib/quantizer_test.rb
|
153
166
|
- test/lib/vaddr_test.rb
|
167
|
+
- test/schema.rb
|
154
168
|
- test/test_helper.rb
|
155
169
|
homepage: http://www.queuetue.com/Chawk
|
156
170
|
licenses:
|
@@ -178,7 +192,9 @@ specification_version: 4
|
|
178
192
|
summary: Time Series Storage Engine
|
179
193
|
test_files:
|
180
194
|
- test/lib/addr_test.rb
|
195
|
+
- test/lib/failed_node_test.rb
|
181
196
|
- test/lib/paddr_test.rb
|
182
197
|
- test/lib/quantizer_test.rb
|
183
198
|
- test/lib/vaddr_test.rb
|
199
|
+
- test/schema.rb
|
184
200
|
- test/test_helper.rb
|
data/lib/addr.rb
DELETED
@@ -1,108 +0,0 @@
|
|
1
|
-
require 'vaddr'
|
2
|
-
require 'paddr'
|
3
|
-
module Chawk
|
4
|
-
# Manages addressing of Nodes - all data operations in Chawk are done
|
5
|
-
# through an instance of Chawk::Addr.
|
6
|
-
class Addr
|
7
|
-
attr_reader :path, :node, :agent
|
8
|
-
|
9
|
-
# @param agent [Chawk::Agent] the agent whose permission will be used for this request
|
10
|
-
# @param path [String] the string address this addr can be found in the database.
|
11
|
-
# If a path does not exist, it will be created and the current agent will be set as an admin for it.
|
12
|
-
def initialize(agent,path)
|
13
|
-
@path = path
|
14
|
-
@agent = agent
|
15
|
-
|
16
|
-
unless path.is_a?(String)
|
17
|
-
raise entError, "Path must be a String."
|
18
|
-
end
|
19
|
-
|
20
|
-
unless path =~ /^[\w\:\$\!\@\*\[\]\~\(\)]+$/
|
21
|
-
raise ArgumentError, "Path can only contain [A-Za-z0-9_:$!@*[]~()] (#{path})"
|
22
|
-
end
|
23
|
-
|
24
|
-
@node = find_or_create_addr(path)
|
25
|
-
|
26
|
-
unless @node
|
27
|
-
raise ArgumentError,"No node returned."
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# An alias for path
|
32
|
-
# @return [String] the string address this addr can be found in the database.
|
33
|
-
def address
|
34
|
-
@path
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
# Returns the Value Store at this address
|
39
|
-
# @return [Chawk::Vaddr]
|
40
|
-
def values()
|
41
|
-
Chawk::Vaddr.new(self)
|
42
|
-
end
|
43
|
-
|
44
|
-
# Returns the Point Store at this address
|
45
|
-
# @return [Chawk::Paddr]
|
46
|
-
def points()
|
47
|
-
Chawk::Paddr.new(self)
|
48
|
-
end
|
49
|
-
|
50
|
-
# Sets public read flag for this address
|
51
|
-
# @param value [Boolean] true if public reading is allowed, false if it is not.
|
52
|
-
def public_read=(value)
|
53
|
-
value = value ? true : false
|
54
|
-
#DataMapper.logger.debug "MAKING #{@node.address} PUBLIC (#{value})"
|
55
|
-
@node.update(public_read:value)
|
56
|
-
end
|
57
|
-
|
58
|
-
# Sets permissions flag for this address, for a specific agent. The existing Chawk::Relationship will be destroyed and
|
59
|
-
# a new one created as specified. Write access is not yet checked.
|
60
|
-
# @param agent [Chawk::Agent] the agent to give permission.
|
61
|
-
# @param read [Boolean] true/false can the agent read this address.
|
62
|
-
# @param write [Boolean] true/false can the agent write this address. (Read acces is required to write.)
|
63
|
-
# @param admin [Boolean] does the agent have ownership/adnim rights for this address. (Read and write are granted if admin is as well.)
|
64
|
-
def set_permissions(agent,read=false,write=false,admin=false)
|
65
|
-
#DataMapper.logger.debug "REVOKING #{@node.address} / #{@agent.name} "
|
66
|
-
@node.relations.all(agent:agent).destroy()
|
67
|
-
if read || write || admin
|
68
|
-
vals = {agent:agent,read:(read ? true : false),write:(write ? true : false),admin:(admin ? true : false)}
|
69
|
-
#DataMapper.logger.debug "SET PERMISSIONS #{@node.address} / #{vals} "
|
70
|
-
@node.relations.create(vals)
|
71
|
-
end
|
72
|
-
nil
|
73
|
-
end
|
74
|
-
|
75
|
-
private
|
76
|
-
|
77
|
-
def check_node_security(node)
|
78
|
-
if node.public_read
|
79
|
-
#DataMapper.logger.debug "NODE IS PUBLIC ACCESSABLE -- #{@agent.name} - #{@agent.id}"
|
80
|
-
return node
|
81
|
-
end
|
82
|
-
rel = node.relations.first(agent:@agent)
|
83
|
-
if (rel && (rel.read || rel.admin))
|
84
|
-
#DataMapper.logger.debug "NODE IS ACCESSABLE -- #{@agent.name} - #{@agent.id}"
|
85
|
-
return node
|
86
|
-
else
|
87
|
-
#DataMapper.logger.debug "NODE IS INACCESSABLE -- #{@agent.name} - #{@agent.id}"
|
88
|
-
raise SecurityError,"You do not have permission to access this node. #{@agent}"
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def find_or_create_addr(addr)
|
93
|
-
#TODO also accept regex-tested string
|
94
|
-
raise(ArgumentError,"Path must be a string.") unless addr.is_a?(String)
|
95
|
-
|
96
|
-
node = Chawk::Models::Node.first(address:self.address)
|
97
|
-
if node
|
98
|
-
node = check_node_security(node)
|
99
|
-
else
|
100
|
-
#DataMapper.logger.debug "NODE CREATED -- #{@agent.name} -- #{@agent.id}"
|
101
|
-
node = Chawk::Models::Node.create(address:self.address) if node.nil?
|
102
|
-
node.relations.create(agent:@agent,node:node,admin:true,read:true,write:true)
|
103
|
-
return node
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
end
|
108
|
-
end
|
data/lib/paddr.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
require 'store'
|
2
|
-
|
3
|
-
module Chawk
|
4
|
-
|
5
|
-
# The Point Store - where time series integer data is stored, retrieved and aggregated through an instance of Chawk::Addr.
|
6
|
-
class Paddr
|
7
|
-
|
8
|
-
include Chawk::Store
|
9
|
-
|
10
|
-
# @param other [Integer] the integer to add to the value at this address.
|
11
|
-
# Increment the most recent point observed at this address. The most recent observed is
|
12
|
-
# not necessarily the most recent stored, as data can arrive out of order.
|
13
|
-
|
14
|
-
def +(other = 1)
|
15
|
-
raise ArgumentError unless other.is_a?(Numeric) && other.integer?
|
16
|
-
int = (self.last.value.to_i + other.to_i)
|
17
|
-
self << int
|
18
|
-
end
|
19
|
-
|
20
|
-
# @param other [Integer] the integer to subtract to the value at this address.
|
21
|
-
# Decrement the most recent point observed at this address. The most recent observed is
|
22
|
-
# not necessarily the most recent stored, as data can arrive out of order.
|
23
|
-
def -(other = 1)
|
24
|
-
raise ArgumentError unless other.is_a?(Numeric) && other.integer?
|
25
|
-
self + (-other)
|
26
|
-
end
|
27
|
-
|
28
|
-
def length
|
29
|
-
coll.length
|
30
|
-
end
|
31
|
-
|
32
|
-
# @return [Integer] the largest value stored.
|
33
|
-
# Returns the largest value currently stored at this address.
|
34
|
-
def max
|
35
|
-
coll.max(:value)
|
36
|
-
end
|
37
|
-
|
38
|
-
# @return [Integer] the smallest value stored.
|
39
|
-
# Returns the smallest value currently stored at this address.
|
40
|
-
def min
|
41
|
-
coll.min(:value)
|
42
|
-
end
|
43
|
-
private
|
44
|
-
|
45
|
-
def model
|
46
|
-
Chawk::Models::Point
|
47
|
-
end
|
48
|
-
|
49
|
-
def coll
|
50
|
-
@node.points
|
51
|
-
end
|
52
|
-
|
53
|
-
def stored_type
|
54
|
-
Integer
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
data/lib/store.rb
DELETED
@@ -1,124 +0,0 @@
|
|
1
|
-
module Chawk
|
2
|
-
# The base store object, included by both Chawk::Vaddr and Chawk::Paddr
|
3
|
-
# To add a custom datastore, you would begin here.
|
4
|
-
module Store
|
5
|
-
|
6
|
-
# @param addr [Chawk::Addr] an address instance created from Chawk#addr.
|
7
|
-
def initialize(addr)
|
8
|
-
@addr = addr
|
9
|
-
@node = addr.node
|
10
|
-
end
|
11
|
-
|
12
|
-
# @param val [Object] value to store at this address.
|
13
|
-
# @param ts [Time::Time]
|
14
|
-
# @param options [Hash] Meta and Source information can be stored as well.
|
15
|
-
# This is an internal function to add a value to the datastore and specify the observed_at time. It can be used
|
16
|
-
# by external code, but do so carefully.
|
17
|
-
def _insert(val,ts,options={})
|
18
|
-
#DataMapper.logger.debug "PREINSERT #{val} -- #{ts.to_f}"
|
19
|
-
|
20
|
-
values = {value:val,observed_at:ts.to_f,agent:@addr.agent}
|
21
|
-
values[:meta] = options[:meta] if options[:meta]
|
22
|
-
|
23
|
-
coll.create(values)
|
24
|
-
end
|
25
|
-
|
26
|
-
# This will clear out all of the data stored at this address for this datastore. Use with caution.
|
27
|
-
def clear_history!
|
28
|
-
model.all(node_id:@node.id).destroy
|
29
|
-
end
|
30
|
-
|
31
|
-
# The number of stores data points in this datastore at this address.
|
32
|
-
def length
|
33
|
-
coll.length
|
34
|
-
end
|
35
|
-
|
36
|
-
def insert_recognizer(item, dt, options={})
|
37
|
-
case
|
38
|
-
|
39
|
-
when item.is_a?(stored_type)
|
40
|
-
_insert item,dt, options
|
41
|
-
when item.is_a?(Array)
|
42
|
-
if item.length == 2 && item[0].is_a?(stored_type) #value, timestamp
|
43
|
-
_insert item[0],item[1], options
|
44
|
-
else
|
45
|
-
raise ArgumentError, "Array Items must be in [value,timestamp] format. #{item.inspect}"
|
46
|
-
end
|
47
|
-
when item.is_a?(Hash)
|
48
|
-
if item['v'] && item['v'].is_a?(stored_type)
|
49
|
-
if item['t']
|
50
|
-
_insert item['v'],item['t'], options
|
51
|
-
else
|
52
|
-
_insert item['v'],dt, options
|
53
|
-
end
|
54
|
-
else
|
55
|
-
raise ArgumentError, "Hash must have 'v' key set to proper type.. #{item.inspect}"
|
56
|
-
end
|
57
|
-
else
|
58
|
-
raise ArgumentError, "Can't recognize format of data item. #{item.inspect}"
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
# @param args [Object, Array of Objects]
|
63
|
-
# @param options [Hash] You can also pass in :meta and :timestamp
|
64
|
-
# Add an item or an array of items (one at a time) to the datastore.
|
65
|
-
def append(args,options={})
|
66
|
-
options[:observed_at] ? dt = options[:observed_at] : dt = Time.now
|
67
|
-
if args.is_a?(Array)
|
68
|
-
args.each do |arg|
|
69
|
-
insert_recognizer(arg, dt, options)
|
70
|
-
end
|
71
|
-
else
|
72
|
-
insert_recognizer(args, dt, options)
|
73
|
-
end
|
74
|
-
self.last
|
75
|
-
end
|
76
|
-
|
77
|
-
def <<(args)
|
78
|
-
append(args)
|
79
|
-
#options[:observed_at] ? dt = options[:observed_at] : dt = Time.now
|
80
|
-
#if args.is_a?(Array)
|
81
|
-
# args.each do |arg|
|
82
|
-
# insert_recognizer(arg, dt, options)
|
83
|
-
# end
|
84
|
-
#else
|
85
|
-
# insert_recognizer(args, dt, options)
|
86
|
-
#end
|
87
|
-
#self.last
|
88
|
-
end
|
89
|
-
|
90
|
-
# @param count [Integer] returns an array with the last [0..count] items in the datastore. If set to 1 or left empty, this returns a single item.
|
91
|
-
# Either the last item added to the datastore or an array of the last n items added to the datastore.
|
92
|
-
def last(count=1)
|
93
|
-
if count == 1
|
94
|
-
if coll.length > 0
|
95
|
-
coll.last
|
96
|
-
#PPoint.new(self, coll.last)
|
97
|
-
else
|
98
|
-
nil
|
99
|
-
end
|
100
|
-
else
|
101
|
-
vals = coll.all(limit:count,order:[:observed_at.asc, :id.asc])
|
102
|
-
#last_items = vals #.each.collect{|val|PPoint.new(self, val)}
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
# Returns items whose observed_at times fit within from a range.
|
107
|
-
# @param dt_from [Time::Time] The start time.
|
108
|
-
# @param dt_to [Time::Time] The end time.
|
109
|
-
# @return [Array of Objects]
|
110
|
-
def range(dt_from, dt_to,options={})
|
111
|
-
vals = coll.all(:observed_at.gte => dt_from, :observed_at.lte =>dt_to, limit:1000,order:[:observed_at.asc, :id.asc])
|
112
|
-
return vals
|
113
|
-
end
|
114
|
-
|
115
|
-
# Returns items whose observed_at times fit within from a range ending now.
|
116
|
-
# @param dt_from [Time::Time] The start time.
|
117
|
-
# @return [Array of Objects]
|
118
|
-
def since(dt_from)
|
119
|
-
self.range(dt_from,Time.now)
|
120
|
-
end
|
121
|
-
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|