-added check to make sure size + from stays under 10,000

This commit is contained in:
Mark Beamer Jr 2018-04-29 22:09:28 -04:00
parent ec89049049
commit b7e0cb327a

View file

@ -21,6 +21,18 @@ const eclient = new elasticsearch.Client({
function getResults (input) { function getResults (input) {
if (input.size === undefined) input.size = 10; if (input.size === undefined) input.size = 10;
if (input.from === undefined) input.from = 0; if (input.from === undefined) input.from = 0;
// Beamer - temp fix for https://github.com/lbryio/lighthouse/issues/67
if (input.size > 10000) {
input.size = 10000;
input.from = 0;
}
if (input.from > 10000) {
input.from = 9999;
input.size = 1;
}
if (input.from + input.size > 10000) {
input.from = 10000 - input.size;
}
return eclient.search({ return eclient.search({
index : 'claims', index : 'claims',
_source: ['name', 'value', 'claimId'], _source: ['name', 'value', 'claimId'],