diff --git a/middleware/sizeCalculator.js b/middleware/sizeCalculator.js index 88334d3b..69409e45 100644 --- a/middleware/sizeCalculator.js +++ b/middleware/sizeCalculator.js @@ -2,6 +2,8 @@ var _ = require('lodash'); var SIZE_PADDING = 2; +var MIN_QUERY_SIZE = 20; + /** * Utility for calculating query result size * incorporating padding for dedupe process @@ -24,12 +26,7 @@ function setup() { * @returns {number} */ function calculateSize(cleanSize) { - switch (cleanSize || 1) { - case 1: - return 1; - default: - return cleanSize * SIZE_PADDING; - } + return Math.max(MIN_QUERY_SIZE, cleanSize * SIZE_PADDING); } -module.exports = setup; \ No newline at end of file +module.exports = setup; diff --git a/test/unit/helper/sizeCalculator.js b/test/unit/helper/sizeCalculator.js index 41d854d4..6c8d8d22 100644 --- a/test/unit/helper/sizeCalculator.js +++ b/test/unit/helper/sizeCalculator.js @@ -25,7 +25,7 @@ module.exports.tests.valid = function(test, common) { test('size=0', function (t) { setup(0); calcSize(req, {}, function () { - t.equal(req.clean.querySize, 1); + t.equal(req.clean.querySize, 20); t.end(); }); }); @@ -33,7 +33,7 @@ module.exports.tests.valid = function(test, common) { test('size=1', function (t) { setup(1); calcSize(req, {}, function () { - t.equal(req.clean.querySize, 1); + t.equal(req.clean.querySize, 20); t.end(); }); }); @@ -46,6 +46,14 @@ module.exports.tests.valid = function(test, common) { }); }); + test('size=20', function (t) { + setup(20); + calcSize(req, {}, function () { + t.equal(req.clean.querySize, 40); + t.end(); + }); + }); + test('no size', function (t) { setup(); calcSize(req, {}, function () {