Comparing version 0.1.4 to 0.2.0
@@ -6,3 +6,6 @@ // Default configuration for development. | ||
"mongo-database": "cube_development", | ||
"http-port": 1080 | ||
"mongo-username": null, | ||
"mongo-password": null, | ||
"http-port": 1080, | ||
"udp-port": 1180 | ||
}; |
@@ -6,3 +6,5 @@ // Default configuration for development. | ||
"mongo-database": "cube_development", | ||
"mongo-username": null, | ||
"mongo-password": null, | ||
"http-port": 1081 | ||
}; |
@@ -7,5 +7,4 @@ var options = require("./evaluator-config"), | ||
cube.evaluator.register(db, endpoints); | ||
cube.visualizer.register(db, endpoints); | ||
}; | ||
server.start(); |
@@ -1,7 +0,5 @@ | ||
exports.version = "0.0.9"; | ||
exports.emitter = require("./server/emitter"); | ||
exports.server = require("./server/server"); | ||
exports.collector = require("./server/collector"); | ||
exports.evaluator = require("./server/evaluator"); | ||
exports.visualizer = require("./server/visualizer"); | ||
exports.endpoint = require("./server/endpoint"); | ||
exports.emitter = require("./emitter"); | ||
exports.server = require("./server"); | ||
exports.collector = require("./collector"); | ||
exports.evaluator = require("./evaluator"); | ||
exports.endpoint = require("./endpoint"); |
{ | ||
"name": "cube", | ||
"version": "0.1.4", | ||
"description": "A system for time series visualization using MongoDB, Node and D3.", | ||
"keywords": ["time series", "visualization"], | ||
"version": "0.2.0", | ||
"description": "A system for analyzing time series data using MongoDB and Node.", | ||
"keywords": ["time series"], | ||
"homepage": "http://square.github.com/cube/", | ||
@@ -11,9 +11,9 @@ "author": {"name": "Mike Bostock", "url": "http://bost.ocks.org/mike"}, | ||
"dependencies": { | ||
"d3": "2.7.2", | ||
"mongodb": "0.9.9-7", | ||
"mongodb": "0.9.9-8", | ||
"node-static": "0.5.9", | ||
"pegjs": "0.6.2", | ||
"vows": "0.5.11", | ||
"websocket": "1.0.2", | ||
"websocket": "1.0.3", | ||
"websocket-server": "1.4.04" | ||
} | ||
} |
# Cube | ||
__ | ||
/\ \ | ||
___ __ __\ \ \____ ____ | ||
/ ___\/\ \/\ \\ \ __ \ / __ \ | ||
/\ \__/\ \ \_\ \\ \ \_\ \/\ __/ | ||
\ \____\\ \____/ \ \____/\ \____\ | ||
\/____/ \/___/ \/___/ \/____/ | ||
See <http://square.github.com/cube> for an introduction. | ||
See <http://github.com/square/cube/wiki> for documentation. | ||
**Cube** is a system for collecting timestamped events and deriving metrics. By collecting events rather than metrics, Cube lets you compute aggregate statistics *post hoc*. It also enables richer analysis, such as quantiles and histograms of arbitrary event sets. Cube is built on [MongoDB](http://www.mongodb.org) and available under the [Apache License](/square/cube/blob/master/LICENSE). | ||
## Thank You | ||
Cube is built with the following open-source systems and libraries: | ||
* [D3.js](http://mbostock.github.com/d3/) | ||
* [MongoDB](http://www.mongodb.org/) | ||
* [node-mongodb-native](/christkv/node-mongodb-native) | ||
* [Node.js](http://nodejs.org/) | ||
* [PEG.js](http://pegjs.majda.cz/) | ||
* [Vows](http://vowsjs.org/) | ||
* [websocket](/Worlize/WebSocket-Node) | ||
* [websocket-server](/miksago/node-websocket-server) | ||
## Contributing | ||
We'd love for you to participate in the development of Cube. Before we can accept your pull request, please sign our [Individual Contributor License Agreement](https://spreadsheets.google.com/spreadsheet/viewform?formkey=dDViT2xzUHAwRkI3X3k5Z0lQM091OGc6MQ&ndplr=1). It's a short form that covers our bases and makes sure you're eligible to contribute. Thank you! | ||
Want to learn more? [See the wiki.](/square/cube/wiki) |
@@ -31,3 +31,3 @@ var vows = require("vows"), | ||
assert.equal(response.statusCode, 400); | ||
assert.deepEqual(JSON.parse(response.body), {status: 400}); | ||
assert.deepEqual(JSON.parse(response.body), {error: "SyntaxError: Unexpected token T"}); | ||
} | ||
@@ -42,3 +42,3 @@ } | ||
assert.equal(response.statusCode, 400); | ||
assert.deepEqual(JSON.parse(response.body), {status: 400}); | ||
assert.deepEqual(JSON.parse(response.body), {error: "TypeError: Object #<Object> has no method 'forEach'"}); | ||
} | ||
@@ -53,3 +53,3 @@ } | ||
assert.equal(response.statusCode, 200); | ||
assert.deepEqual(JSON.parse(response.body), {status: 200}); | ||
assert.deepEqual(JSON.parse(response.body), {}); | ||
} | ||
@@ -64,3 +64,3 @@ } | ||
assert.equal(response.statusCode, 400); | ||
assert.deepEqual(JSON.parse(response.body), {status: 400}); | ||
assert.deepEqual(JSON.parse(response.body), {error: "TypeError: Object 42 has no method 'forEach'"}); | ||
} | ||
@@ -67,0 +67,0 @@ } |
var vows = require("vows"), | ||
assert = require("assert"), | ||
parser = require("../lib/cube/server/event-expression"); | ||
parser = require("../lib/cube/event-expression"); | ||
@@ -23,2 +23,5 @@ var suite = vows.describe("event-expression"); | ||
assert.deepEqual(filter, {}); | ||
}, | ||
"has the expected source": function(e) { | ||
assert.equal(e.source, "test"); | ||
} | ||
@@ -38,2 +41,5 @@ }, | ||
assert.deepEqual(filter, {"d.i": {$exists: true}}); | ||
}, | ||
"has the expected source": function(e) { | ||
assert.equal(e.source, "test(i)"); | ||
} | ||
@@ -53,2 +59,5 @@ }, | ||
assert.deepEqual(filter, {"d.i": {$exists: true}, "d.j": {$exists: true}}); | ||
}, | ||
"has the expected source": function(e) { | ||
assert.equal(e.source, "test(i, j)"); | ||
} | ||
@@ -68,2 +77,5 @@ }, | ||
assert.deepEqual(filter, {"d.i": {$gt: 42}}); | ||
}, | ||
"has the expected source": function(e) { | ||
assert.equal(e.source, "test(i).gt(i, 42)"); | ||
} | ||
@@ -92,2 +104,5 @@ }, | ||
assert.deepEqual(filter, {"d.i": {$gt: 42, $lte: 52}}); | ||
}, | ||
"has the expected source": function(e) { | ||
assert.equal(e.source, "test.gt(i, 42).le(i, 52)"); | ||
} | ||
@@ -102,2 +117,5 @@ }, | ||
assert.deepEqual(filter, {"d.i": 52}); | ||
}, | ||
"has the expected source": function(e) { | ||
assert.equal(e.source, "test.gt(i, 42).eq(i, 52)"); | ||
} | ||
@@ -112,2 +130,5 @@ }, | ||
assert.deepEqual(filter, {"d.i": 52}); | ||
}, | ||
"has the expected source": function(e) { | ||
assert.equal(e.source, "test.eq(i, 52).gt(i, 42)"); | ||
} | ||
@@ -127,2 +148,5 @@ }, | ||
assert.deepEqual(filter, {"d.i.j": {$exists: true}}); | ||
}, | ||
"has the expected source": function(e) { | ||
assert.equal(e.source, "test(i.j)"); | ||
} | ||
@@ -142,2 +166,5 @@ }, | ||
assert.deepEqual(filter, {"d.i": {$exists: true}}); | ||
}, | ||
"has the expected source": function(e) { | ||
assert.equal(e.source, "test(i[0])"); | ||
} | ||
@@ -157,2 +184,5 @@ }, | ||
assert.deepEqual(filter, {"d.i.j.k": {$exists: true}}); | ||
}, | ||
"has the expected source": function(e) { | ||
assert.equal(e.source, "test(i.j[0].k)"); | ||
} | ||
@@ -172,2 +202,5 @@ }, | ||
assert.deepEqual(filter, {"d.i.j.0.k": {$gt: 42}}); | ||
}, | ||
"has the expected source": function(e) { | ||
assert.equal(e.source, "test.gt(i.j[0].k, 42)"); | ||
} | ||
@@ -174,0 +207,0 @@ }, |
var vows = require("vows"), | ||
assert = require("assert"), | ||
parser = require("../lib/cube/server/metric-expression"); | ||
parser = require("../lib/cube/metric-expression"); | ||
@@ -53,2 +53,5 @@ var suite = vows.describe("metric-expression"); | ||
assert.equal(e.value({d: {i: -1}}), -1); | ||
}, | ||
"has the expected source": function(e) { | ||
assert.equal(e.source, "sum(test(i))"); | ||
} | ||
@@ -72,2 +75,5 @@ }, | ||
assert.equal(e.value({d: {i: -1}}), -2); | ||
}, | ||
"has the expected source": function(e) { | ||
assert.equal(e.source, "sum(test(i + i * i - 2))"); | ||
} | ||
@@ -87,2 +93,5 @@ }, | ||
assert.deepEqual(filter, {"d.i": {$gt: 42}}); | ||
}, | ||
"has the expected source": function(e) { | ||
assert.equal(e.source, "sum(test(i).gt(i, 42))"); | ||
} | ||
@@ -102,2 +111,5 @@ }, | ||
assert.deepEqual(filter, {"d.i": {$gt: 42}, "d.j": "foo"}); | ||
}, | ||
"has the expected source": function(e) { | ||
assert.equal(e.source, "sum(test.gt(i, 42).eq(j, \"foo\"))"); | ||
} | ||
@@ -121,2 +133,5 @@ }, | ||
assert.equal(e.value({d: {i: {j: -1}}}), -1); | ||
}, | ||
"has the expected source": function(e) { | ||
assert.equal(e.source, "sum(test(i.j))"); | ||
} | ||
@@ -140,2 +155,5 @@ }, | ||
assert.equal(e.value({d: {i: [-1]}}), -1); | ||
}, | ||
"has the expected source": function(e) { | ||
assert.equal(e.source, "sum(test(i[0]))"); | ||
} | ||
@@ -159,6 +177,9 @@ }, | ||
assert.equal(e.value({d: {i: {j: [{k: -1}]}}}), -1); | ||
}, | ||
"has the expected source": function(e) { | ||
assert.equal(e.source, "sum(test(i.j[0].k))"); | ||
} | ||
}, | ||
"a compound expression": { | ||
"a compound expression of two unary expressions": { | ||
topic: parser.parse("sum(foo(2)) + sum(bar(3))"), | ||
@@ -174,2 +195,3 @@ "is compound (has an associated binary operator)": function(e) { | ||
assert.deepEqual(fields, {}); | ||
assert.equal(e.left.source, "sum(foo(2))"); | ||
assert.equal(e.left.type, "foo"); | ||
@@ -185,2 +207,3 @@ assert.equal(e.left.reduce, "sum"); | ||
assert.deepEqual(fields, {}); | ||
assert.equal(e.right.source, "sum(bar(3))"); | ||
assert.equal(e.right.type, "bar"); | ||
@@ -190,2 +213,5 @@ assert.equal(e.right.reduce, "sum"); | ||
}, | ||
"does not have a source": function(e) { | ||
assert.isUndefined(e.source); | ||
}, | ||
"computes the specified value expression": function(e) { | ||
@@ -196,2 +222,13 @@ assert.equal(e.op(2, 3), 5) | ||
"a compound expression of three unary expressions": { | ||
topic: parser.parse("sum(foo(2)) + median(bar(3)) + max(baz(qux))"), | ||
"has the expected subexpression sources": function(e) { | ||
assert.isUndefined(e.source); | ||
assert.equal(e.left.source, "sum(foo(2))"); | ||
assert.isUndefined(e.right.source); | ||
assert.equal(e.right.left.source, "median(bar(3))"); | ||
assert.equal(e.right.right.source, "max(baz(qux))"); | ||
} | ||
}, | ||
"a negated unary expression": { | ||
@@ -201,2 +238,5 @@ topic: parser.parse("-sum(foo)"), | ||
assert.equal(e.value(), -1) | ||
}, | ||
"has the expected source": function(e) { | ||
assert.equal(e.source, "-sum(foo)"); | ||
} | ||
@@ -209,41 +249,8 @@ }, | ||
assert.equal(e.value(), -4) | ||
}, | ||
"does not have a source": function(e) { | ||
assert.isUndefined(e.source); | ||
} | ||
}, | ||
"a grouped expression": { | ||
topic: parser.parse("sum(test(bar).group(foo))"), | ||
"has the expected expression": function(e) { | ||
var filter = {}, fields = {}, group = {}; | ||
e.filter(filter); | ||
e.fields(fields); | ||
e.group.fields(group); | ||
assert.deepEqual(filter, {"d.bar": {$exists: true}}); | ||
assert.deepEqual(fields, {"d.bar": 1}); | ||
assert.deepEqual(group, {"d.foo": 1}); | ||
assert.equal(e.type, "test"); | ||
assert.equal(e.reduce, "sum"); | ||
assert.equal(e.value({d: {bar: 42}}), 42); | ||
assert.equal(e.group.field, "d.foo"); | ||
assert.isTrue(!e.group.multi); | ||
} | ||
}, | ||
"a multi-grouped (labeled) expression": { | ||
topic: parser.parse("sum(test(bar).groups(foo))"), | ||
"has the expected expression": function(e) { | ||
var filter = {}, fields = {}, group = {}; | ||
e.filter(filter); | ||
e.fields(fields); | ||
e.group.fields(group); | ||
assert.deepEqual(filter, {"d.bar": {$exists: true}}); | ||
assert.deepEqual(fields, {"d.bar": 1}); | ||
assert.deepEqual(group, {"d.foo": 1}); | ||
assert.equal(e.type, "test"); | ||
assert.equal(e.reduce, "sum"); | ||
assert.equal(e.value({d: {bar: 42}}), 42); | ||
assert.equal(e.group.field, "d.foo"); | ||
assert.isTrue(e.group.multi); | ||
} | ||
}, | ||
"filters": { | ||
@@ -250,0 +257,0 @@ "multiple filters on the same field are combined": function() { |
var vows = require("vows"), | ||
assert = require("assert"), | ||
test = require("./test"), | ||
event = require("../lib/cube/server/event"), | ||
metric = require("../lib/cube/server/metric"); | ||
event = require("../lib/cube/event"), | ||
metric = require("../lib/cube/metric"); | ||
@@ -10,20 +10,23 @@ var suite = vows.describe("metric"); | ||
var steps = { | ||
1e4: function(date, n) { return new Date((Math.floor(date / 1e4) + n) * 1e4); }, | ||
6e4: function(date, n) { return new Date((Math.floor(date / 6e4) + n) * 6e4); }, | ||
3e5: function(date, n) { return new Date((Math.floor(date / 3e5) + n) * 3e5); }, | ||
36e5: function(date, n) { return new Date((Math.floor(date / 36e5) + n) * 36e5); }, | ||
864e5: function(date, n) { return new Date((Math.floor(date / 864e5) + n) * 864e5); }, | ||
6048e5: function(date, n) { (date = steps[864e5](date, n * 7)).setUTCDate(date.getUTCDate() - date.getUTCDay()); return date; }, | ||
2592e6: function(date, n) { return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth() + n, 1)); } | ||
864e5: function(date, n) { return new Date((Math.floor(date / 864e5) + n) * 864e5); } | ||
}; | ||
steps[1e4].description = "10-second"; | ||
steps[6e4].description = "1-minute"; | ||
steps[3e5].description = "5-minute"; | ||
steps[36e5].description = "1-hour"; | ||
steps[864e5].description = "1-day"; | ||
steps[6048e5].description = "1-week"; | ||
steps[2592e6].description = "1-month"; | ||
suite.addBatch(test.batch({ | ||
topic: function(test) { | ||
var emit = event.putter(test.db); | ||
var putter = event.putter(test.db), | ||
getter = metric.getter(test.db), | ||
callback = this.callback; | ||
for (var i = 0; i < 2500; i++) { | ||
emit({ | ||
putter({ | ||
type: "test", | ||
@@ -34,3 +37,4 @@ time: new Date(Date.UTC(2011, 6, 18, 0, Math.sqrt(i) - 10)).toISOString(), | ||
} | ||
return metric.getter(test.db); | ||
setTimeout(function() { callback(null, getter); }, 500); | ||
}, | ||
@@ -43,7 +47,6 @@ | ||
}, { | ||
6e4: [0, 0, 0, 1, 1, 3, 5, 7, 9, 11, 13, 15, 17, 39, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
3e5: [0, 17, 65, 143, 175, 225, 275, 325, 375, 425, 475, 0, 0], | ||
36e5: [82, 2418], | ||
864e5: [82, 2418], | ||
6048e5: [2500], | ||
2592e6: [2500] | ||
864e5: [82, 2418] | ||
} | ||
@@ -59,5 +62,3 @@ ), | ||
36e5: [3321, 3120429], | ||
864e5: [3321, 3120429], | ||
6048e5: [3123750], | ||
2592e6: [3123750] | ||
864e5: [3321, 3120429] | ||
} | ||
@@ -73,5 +74,3 @@ ), | ||
36e5: [33.21, 31204.29], | ||
864e5: [33.21, 31204.29], | ||
6048e5: [31237.5], | ||
2592e6: [31237.5] | ||
864e5: [33.21, 31204.29] | ||
} | ||
@@ -87,5 +86,3 @@ ), | ||
36e5: [81, 2417], | ||
864e5: [81, 2417], | ||
6048e5: [2499], | ||
2592e6: [2499] | ||
864e5: [81, 2417] | ||
} | ||
@@ -101,5 +98,3 @@ ), | ||
36e5: [82, 2418], | ||
864e5: [82, 2418], | ||
6048e5: [2500], | ||
2592e6: [2500] | ||
864e5: [82, 2418] | ||
} | ||
@@ -115,5 +110,3 @@ ), | ||
36e5: [3280.5, 3119138.5], | ||
864e5: [3280.5, 3119138.5], | ||
6048e5: [3122500.5], | ||
2592e6: [3122500.5] | ||
864e5: [3280.5, 3119138.5] | ||
} | ||
@@ -129,5 +122,3 @@ ), | ||
36e5: [81, 2417], | ||
864e5: [81, 2417], | ||
6048e5: [2499], | ||
2592e6: [2499] | ||
864e5: [81, 2417] | ||
} | ||
@@ -157,13 +148,17 @@ ) | ||
var actual = [], | ||
total = expected.length, | ||
timeout = setTimeout(function() { cb("Time's up!"); }, 10000), | ||
cb = this.callback, | ||
req = Object.create(request); | ||
req = Object.create(request), | ||
test = arguments[depth]; | ||
req.step = step; | ||
arguments[depth](req, function(response) { | ||
if (actual.push(response) >= total) { | ||
clearTimeout(timeout); | ||
cb(null, actual.sort(function(a, b) { return a.time - b.time; })); | ||
} | ||
}); | ||
setTimeout(function() { | ||
test(req, function(response) { | ||
if (response.time >= stop) { | ||
clearTimeout(timeout); | ||
cb(null, actual.sort(function(a, b) { return a.time - b.time; })); | ||
} else { | ||
actual.push(response); | ||
} | ||
}); | ||
}, depth * 250); | ||
} | ||
@@ -209,2 +204,4 @@ }; | ||
// returns the expected values | ||
var actualValues = actual.map(function(d) { return d.value; }); | ||
assert.equal(expected.length, actual.length, "expected " + expected + ", got " + actualValues); | ||
expected.forEach(function(value, i) { | ||
@@ -211,0 +208,0 @@ if (Math.abs(actual[i].value - value) > 1e-6) { |
var vows = require("vows"), | ||
assert = require("assert"), | ||
reduces = require("../lib/cube/server/reduces"); | ||
reduces = require("../lib/cube/reduces"); | ||
@@ -5,0 +5,0 @@ var suite = vows.describe("reduces"); |
@@ -17,23 +17,4 @@ var mongodb = require("mongodb"), | ||
var collectionsRemaining = 2; | ||
db.dropCollection("test_events", function(error) { | ||
db.createCollection("test_events", function(error, events) { | ||
events.ensureIndex({t: 1}, collectionReady); | ||
}); | ||
}); | ||
db.dropCollection("test_metrics", function(error) { | ||
db.createCollection("test_metrics", {capped: true, size: 1e6, autoIndexId: false}, function(error, metrics) { | ||
var indexesRemaining = 3; | ||
metrics.ensureIndex({e: 1, l: 1, t: 1, g: 1}, {unique: true}, indexReady); | ||
metrics.ensureIndex({i: 1, e: 1, l: 1, t: 1}, indexReady); | ||
metrics.ensureIndex({i: 1, l: 1, t: 1}, indexReady); | ||
function indexReady() { | ||
if (!--indexesRemaining) { | ||
collectionReady(); | ||
} | ||
} | ||
}); | ||
}); | ||
db.dropCollection("test_events", collectionReady); | ||
db.dropCollection("test_metrics", collectionReady); | ||
function collectionReady() { | ||
@@ -40,0 +21,0 @@ if (!--collectionsRemaining) { |
var vows = require("vows"), | ||
assert = require("assert"), | ||
tiers = require("../lib/cube/server/tiers"); | ||
tiers = require("../lib/cube/tiers"); | ||
@@ -16,3 +16,3 @@ var suite = vows.describe("tiers"); | ||
keys.sort(function(a, b) { return a - b; }); | ||
assert.deepEqual(keys, [1e4, 3e5, 36e5, 864e5, 6048e5, 2592e6]); | ||
assert.deepEqual(keys, [1e4, 6e4, 3e5, 36e5, 864e5]); | ||
} | ||
@@ -83,2 +83,67 @@ }, | ||
}, | ||
"minute": { | ||
topic: tiers[6e4], | ||
"has the key 6e4": function(tier) { | ||
assert.strictEqual(tier.key, 6e4); | ||
}, | ||
"next is undefined": function(tier) { | ||
assert.isUndefined(tier.next); | ||
}, | ||
"size is undefined": function(tier) { | ||
assert.isUndefined(tier.size); | ||
}, | ||
"floor": { | ||
"rounds down to minutes": function(tier) { | ||
assert.deepEqual(tier.floor(utc(2011, 08, 02, 12, 20, 00)), utc(2011, 08, 02, 12, 20)); | ||
assert.deepEqual(tier.floor(utc(2011, 08, 02, 12, 20, 01)), utc(2011, 08, 02, 12, 20)); | ||
assert.deepEqual(tier.floor(utc(2011, 08, 02, 12, 21, 00)), utc(2011, 08, 02, 12, 21)); | ||
assert.deepEqual(tier.floor(utc(2011, 08, 02, 12, 23, 00)), utc(2011, 08, 02, 12, 23)); | ||
assert.deepEqual(tier.floor(utc(2011, 08, 02, 12, 24, 59)), utc(2011, 08, 02, 12, 24)); | ||
assert.deepEqual(tier.floor(utc(2011, 08, 02, 12, 25, 00)), utc(2011, 08, 02, 12, 25)); | ||
}, | ||
"does not modify the passed-in date": function(tier) { | ||
var date = utc(2011, 08, 02, 12, 21, 20); | ||
assert.deepEqual(tier.floor(date), utc(2011, 08, 02, 12, 21)); | ||
assert.deepEqual(date, utc(2011, 08, 02, 12, 21, 20)); | ||
} | ||
}, | ||
"ceil": { | ||
"rounds up to minutes": function(tier) { | ||
assert.deepEqual(tier.ceil(utc(2011, 08, 02, 12, 20, 00)), utc(2011, 08, 02, 12, 20)); | ||
assert.deepEqual(tier.ceil(utc(2011, 08, 02, 12, 20, 01)), utc(2011, 08, 02, 12, 21)); | ||
assert.deepEqual(tier.ceil(utc(2011, 08, 02, 12, 21, 00)), utc(2011, 08, 02, 12, 21)); | ||
assert.deepEqual(tier.ceil(utc(2011, 08, 02, 12, 23, 00)), utc(2011, 08, 02, 12, 23)); | ||
assert.deepEqual(tier.ceil(utc(2011, 08, 02, 12, 24, 59)), utc(2011, 08, 02, 12, 25)); | ||
assert.deepEqual(tier.ceil(utc(2011, 08, 02, 12, 25, 00)), utc(2011, 08, 02, 12, 25)); | ||
}, | ||
"does not modified the specified date": function(tier) { | ||
var date = utc(2011, 08, 02, 12, 21, 20); | ||
assert.deepEqual(tier.ceil(date), utc(2011, 08, 02, 12, 22)); | ||
assert.deepEqual(date, utc(2011, 08, 02, 12, 21, 20)); | ||
} | ||
}, | ||
"step": { | ||
"increments time by one minute": function(tier) { | ||
var date = utc(2011, 08, 02, 23, 45, 00); | ||
assert.deepEqual(date = tier.step(date), utc(2011, 08, 02, 23, 46)); | ||
assert.deepEqual(date = tier.step(date), utc(2011, 08, 02, 23, 47)); | ||
assert.deepEqual(date = tier.step(date), utc(2011, 08, 02, 23, 48)); | ||
assert.deepEqual(date = tier.step(date), utc(2011, 08, 02, 23, 49)); | ||
assert.deepEqual(date = tier.step(date), utc(2011, 08, 02, 23, 50)); | ||
}, | ||
"does not round the specified date": function(tier) { | ||
assert.deepEqual(tier.step(utc(2011, 08, 02, 12, 21, 23)), utc(2011, 08, 02, 12, 22, 23)); | ||
}, | ||
"does not modify the specified date": function(tier) { | ||
var date = utc(2011, 08, 02, 12, 20); | ||
assert.deepEqual(tier.step(date), utc(2011, 08, 02, 12, 21)); | ||
assert.deepEqual(date, utc(2011, 08, 02, 12, 20)); | ||
} | ||
} | ||
}, | ||
"minute5": { | ||
@@ -270,128 +335,2 @@ topic: tiers[3e5], | ||
} | ||
}, | ||
"week": { | ||
topic: tiers[6048e5], | ||
"has the key 6048e5": function(tier) { | ||
assert.strictEqual(tier.key, 6048e5); | ||
}, | ||
"next is the one-day tier": function(tier) { | ||
assert.equal(tier.next, tiers[864e5]); | ||
}, | ||
"size is 7": function(tier) { | ||
assert.strictEqual(tier.size(), 7); | ||
}, | ||
"floor": { | ||
"rounds down to weeks": function(tier) { | ||
assert.deepEqual(tier.floor(utc(2011, 08, 04, 00, 00, 00)), utc(2011, 08, 04, 00, 00)); | ||
assert.deepEqual(tier.floor(utc(2011, 08, 04, 00, 00, 01)), utc(2011, 08, 04, 00, 00)); | ||
assert.deepEqual(tier.floor(utc(2011, 08, 04, 12, 21, 00)), utc(2011, 08, 04, 00, 00)); | ||
assert.deepEqual(tier.floor(utc(2011, 08, 10, 23, 59, 59)), utc(2011, 08, 04, 00, 00)); | ||
assert.deepEqual(tier.floor(utc(2011, 08, 11, 00, 00, 00)), utc(2011, 08, 11, 00, 00)); | ||
}, | ||
"does not modify the passed-in date": function(tier) { | ||
var date = utc(2011, 08, 04, 12, 21); | ||
assert.deepEqual(tier.floor(date), utc(2011, 08, 04, 00, 00)); | ||
assert.deepEqual(date, utc(2011, 08, 04, 12, 21)); | ||
} | ||
}, | ||
"ceil": { | ||
"rounds up to weeks": function(tier) { | ||
assert.deepEqual(tier.ceil(utc(2011, 08, 04, 00, 00, 00)), utc(2011, 08, 04, 00, 00)); | ||
assert.deepEqual(tier.ceil(utc(2011, 08, 04, 00, 00, 01)), utc(2011, 08, 11, 00, 00)); | ||
assert.deepEqual(tier.ceil(utc(2011, 08, 04, 12, 21, 00)), utc(2011, 08, 11, 00, 00)); | ||
assert.deepEqual(tier.ceil(utc(2011, 08, 10, 23, 59, 59)), utc(2011, 08, 11, 00, 00)); | ||
assert.deepEqual(tier.ceil(utc(2011, 08, 11, 00, 00, 00)), utc(2011, 08, 11, 00, 00)); | ||
}, | ||
"does not modified the specified date": function(tier) { | ||
var date = utc(2011, 08, 02, 12, 21, 00); | ||
assert.deepEqual(tier.ceil(date), utc(2011, 08, 04, 00, 00)); | ||
assert.deepEqual(date, utc(2011, 08, 02, 12, 21)); | ||
} | ||
}, | ||
"step": { | ||
"increments time by one week": function(tier) { | ||
var date = utc(2011, 08, 04, 00, 00, 00); | ||
assert.deepEqual(date = tier.step(date), utc(2011, 08, 11, 00, 00)); | ||
assert.deepEqual(date = tier.step(date), utc(2011, 08, 18, 00, 00)); | ||
assert.deepEqual(date = tier.step(date), utc(2011, 08, 25, 00, 00)); | ||
assert.deepEqual(date = tier.step(date), utc(2011, 09, 02, 00, 00)); | ||
assert.deepEqual(date = tier.step(date), utc(2011, 09, 09, 00, 00)); | ||
}, | ||
"does not round the specified date": function(tier) { | ||
assert.deepEqual(tier.step(utc(2011, 08, 02, 12, 21, 23)), utc(2011, 08, 09, 12, 21, 23)); | ||
}, | ||
"does not modify the specified date": function(tier) { | ||
var date = utc(2011, 08, 04, 00, 00, 00); | ||
assert.deepEqual(tier.step(date), utc(2011, 08, 11, 00, 00)); | ||
assert.deepEqual(date, utc(2011, 08, 04, 00, 00)); | ||
} | ||
} | ||
}, | ||
"month": { | ||
topic: tiers[2592e6], | ||
"has the key 2592e6": function(tier) { | ||
assert.strictEqual(tier.key, 2592e6); | ||
}, | ||
"next is the one-day tier": function(tier) { | ||
assert.equal(tier.next, tiers[864e5]); | ||
}, | ||
"size is number of days in a month": function(tier) { | ||
assert.strictEqual(tier.size(utc(2011, 00, 01)), 31); | ||
assert.strictEqual(tier.size(utc(2011, 01, 01)), 28); | ||
}, | ||
"floor": { | ||
"rounds down to months": function(tier) { | ||
assert.deepEqual(tier.floor(utc(2011, 08, 01, 00, 00, 00)), utc(2011, 08, 01, 00, 00)); | ||
assert.deepEqual(tier.floor(utc(2011, 08, 01, 00, 00, 01)), utc(2011, 08, 01, 00, 00)); | ||
assert.deepEqual(tier.floor(utc(2011, 08, 04, 12, 21, 00)), utc(2011, 08, 01, 00, 00)); | ||
assert.deepEqual(tier.floor(utc(2011, 08, 29, 23, 59, 59)), utc(2011, 08, 01, 00, 00)); | ||
assert.deepEqual(tier.floor(utc(2011, 09, 01, 00, 00, 00)), utc(2011, 09, 01, 00, 00)); | ||
}, | ||
"does not modify the passed-in date": function(tier) { | ||
var date = utc(2011, 08, 04, 12, 21); | ||
assert.deepEqual(tier.floor(date), utc(2011, 08, 01, 00, 00)); | ||
assert.deepEqual(date, utc(2011, 08, 04, 12, 21)); | ||
} | ||
}, | ||
"ceil": { | ||
"rounds up to weeks": function(tier) { | ||
assert.deepEqual(tier.ceil(utc(2011, 08, 01, 00, 00, 00)), utc(2011, 08, 01, 00, 00)); | ||
assert.deepEqual(tier.ceil(utc(2011, 08, 01, 00, 00, 01)), utc(2011, 09, 01, 00, 00)); | ||
assert.deepEqual(tier.ceil(utc(2011, 08, 04, 12, 21, 00)), utc(2011, 09, 01, 00, 00)); | ||
assert.deepEqual(tier.ceil(utc(2011, 08, 29, 23, 59, 59)), utc(2011, 09, 01, 00, 00)); | ||
assert.deepEqual(tier.ceil(utc(2011, 09, 01, 00, 00, 00)), utc(2011, 09, 01, 00, 00)); | ||
}, | ||
"does not modified the specified date": function(tier) { | ||
var date = utc(2011, 08, 02, 12, 21, 00); | ||
assert.deepEqual(tier.ceil(date), utc(2011, 09, 01, 00, 00)); | ||
assert.deepEqual(date, utc(2011, 08, 02, 12, 21)); | ||
} | ||
}, | ||
"step": { | ||
"increments time by one month": function(tier) { | ||
var date = utc(2011, 08, 01, 00, 00, 00); | ||
assert.deepEqual(date = tier.step(date), utc(2011, 09, 01, 00, 00)); | ||
assert.deepEqual(date = tier.step(date), utc(2011, 10, 01, 00, 00)); | ||
assert.deepEqual(date = tier.step(date), utc(2011, 11, 01, 00, 00)); | ||
assert.deepEqual(date = tier.step(date), utc(2012, 00, 01, 00, 00)); | ||
assert.deepEqual(date = tier.step(date), utc(2012, 01, 01, 00, 00)); | ||
}, | ||
"does not round the specified date": function(tier) { | ||
assert.deepEqual(tier.step(utc(2011, 01, 02, 12, 21, 23)), utc(2011, 02, 02, 12, 21, 23)); | ||
assert.deepEqual(tier.step(utc(2011, 08, 02, 12, 21, 23)), utc(2011, 09, 02, 12, 21, 23)); | ||
}, | ||
"does not modify the specified date": function(tier) { | ||
var date = utc(2011, 08, 01, 00, 00, 00); | ||
assert.deepEqual(tier.step(date), utc(2011, 09, 01, 00, 00)); | ||
assert.deepEqual(date, utc(2011, 08, 01, 00, 00)); | ||
} | ||
} | ||
} | ||
@@ -398,0 +337,0 @@ |
var vows = require("vows"), | ||
assert = require("assert"), | ||
test = require("./test"), | ||
types = require("../lib/cube/server/types"), | ||
types = require("../lib/cube/types"), | ||
mongodb = require("mongodb"); | ||
@@ -6,0 +6,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
738001
18492
48
6
5
+ Addednode-static@0.5.9
+ Addedmongodb@0.9.9-8(transitive)
+ Addednode-static@0.5.9(transitive)
+ Addedwebsocket@1.0.3(transitive)
- Removedd3@2.7.2
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcontextify@0.0.7(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removedcssom@0.2.5(transitive)
- Removedd3@2.7.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhtmlparser@1.7.7(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjsdom@0.2.10(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedmongodb@0.9.9-7(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.13.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)
- Removedwebsocket@1.0.2(transitive)
Updatedmongodb@0.9.9-8
Updatedwebsocket@1.0.3