In that PR there was special care taken to make sure we didn't break certain performance enhancing features where we filter out addresses. But even with all that care it looks like we broke it anyway!
This PR fixes that issue and allows performance enhancing filters on layers work as intended.
The core of the bug was that the clean.positive_layers property, which is intended to be set only to the list of layers the API parameters explicitly opt into, was instead being set to the list of all layers, minus the layers that the parameter didn't opt into.
For example, a query with param layers=-venue should result in clean.positive_layers: [], clean.negative_layers: ['venue'], and clean.layers temporarily set to all layers except venue.
Subsequent middleware can then look at clean.positive_layers to decide if any layers can/should be removed from clean.layers. For example, in some situations we've decided it's ok to remove address from clean.layers, since clean.positive_layers does not explicitly opt into the address layer.
In https://github.com/pelias/api/pull/1525 we introduced the concept of negative sources and layers.
In that PR there was special care taken to make sure we didn't break certain performance enhancing features where we filter out addresses. But even with all that care it looks like we broke it anyway!
This PR fixes that issue and allows performance enhancing filters on layers work as intended.
The core of the bug was that the
clean.positive_layers
property, which is intended to be set only to the list of layers the API parameters explicitly opt into, was instead being set to the list of all layers, minus the layers that the parameter didn't opt into.For example, a query with param
layers=-venue
should result inclean.positive_layers: []
,clean.negative_layers: ['venue']
, andclean.layers
temporarily set to all layers exceptvenue
.Subsequent middleware can then look at
clean.positive_layers
to decide if any layers can/should be removed fromclean.layers
. For example, in some situations we've decided it's ok to removeaddress
fromclean.layers
, sinceclean.positive_layers
does not explicitly opt into the address layer.Fixes https://github.com/pelias/api/issues/1601