|
|
@ -40,13 +40,13 @@ function isFallbackQuery(results) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function hasRecordsAtLayers(results, layer) { |
|
|
|
function hasRecordsAtLayers(results, layer) { |
|
|
|
return results.some(function(result) { |
|
|
|
return results.some( (result) => { |
|
|
|
return result._matched_queries[0] === 'fallback.' + layer; |
|
|
|
return result._matched_queries[0] === 'fallback.' + layer; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function retainRecordsAtLayers(results, layer) { |
|
|
|
function retainRecordsAtLayers(results, layer) { |
|
|
|
return results.filter(function(result) { |
|
|
|
return results.filter( (result) => { |
|
|
|
return result._matched_queries[0] === 'fallback.' + layer; |
|
|
|
return result._matched_queries[0] === 'fallback.' + layer; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
@ -61,7 +61,7 @@ function setup() { |
|
|
|
|
|
|
|
|
|
|
|
// start at the most granular possible layer. if there are results at a layer
|
|
|
|
// start at the most granular possible layer. if there are results at a layer
|
|
|
|
// then remove everything not at that layer.
|
|
|
|
// then remove everything not at that layer.
|
|
|
|
layers.forEach(function(layer) { |
|
|
|
layers.forEach( (layer) => { |
|
|
|
if (hasRecordsAtLayers(res.data, layer )) { |
|
|
|
if (hasRecordsAtLayers(res.data, layer )) { |
|
|
|
res.data = retainRecordsAtLayers(res.data, layer); |
|
|
|
res.data = retainRecordsAtLayers(res.data, layer); |
|
|
|
} |
|
|
|
} |
|
|
|