Permalink
Browse files

Fix a bug when zero metrics were requested.

  • Loading branch information...
1 parent a4a4665 commit 46e887f47aa2ca4dec1e6d889a156ff6043e9431 @mbostock mbostock committed Apr 20, 2012
Showing with 6 additions and 3 deletions.
  1. +6 −3 lib/cube/metric.js
View
@@ -74,14 +74,17 @@ exports.getter = function(db) {
queue = queueByName[name],
step = tier.key;
+ // Compute the expected number of values.
+ while (time < stop) ++remaining, time = tier.step(time);
+
+ // If no results were requested, return immediately.
+ if (!remaining) return callback(stop);
+
// Add this task to the appropriate queue.
if (queue) queue.next = task;
else process.nextTick(task);
queueByName[name] = task;
- // Compute the expected number of values.
- while (time < stop) ++remaining, time = tier.step(time);
-
function task() {
findOrComputeUnary(expression, start, stop, tier, function(time, value) {
callback(time, value);

0 comments on commit 46e887f

Please sign in to comment.