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/package.json b/package.json index bb4b6c28..5a91cc60 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "node": ">=4.0.0" }, "dependencies": { - "addressit": "1.4.0", + "addressit": "1.5.0", "async": "^2.0.0", "check-types": "^7.0.0", "elasticsearch": "^12.0.1", @@ -55,14 +55,14 @@ "lodash": "^4.5.0", "markdown": "0.5.0", "morgan": "1.8.1", - "pelias-config": "2.9.0", + "pelias-config": "2.10.0", "pelias-categories": "1.2.0", "pelias-labels": "1.6.0", "pelias-logger": "0.2.0", "pelias-mock-logger": "^1.0.1", - "pelias-model": "4.6.0", + "pelias-model": "4.8.0", "pelias-query": "8.15.0", - "pelias-text-analyzer": "1.8.0", + "pelias-text-analyzer": "1.8.1", "predicates": "^1.0.1", "retry": "^0.10.1", "request": "^2.79.0", 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 () {