Browse Source

switch importance of address/street

pull/736/head
Stephen Hess 8 years ago
parent
commit
da72a968f9
  1. 4
      middleware/trimByGranularityComponent.js
  2. 24
      test/unit/middleware/trimByGranularityComponent.js

4
middleware/trimByGranularityComponent.js

@ -22,8 +22,8 @@ const _ = require('lodash');
// supplied we want to retain borough=Manhattan and city=Manhattan results
const layers = [
'venue',
'street',
'address',
'street',
'neighbourhood',
['borough', 'locality'],
'localadmin',
@ -44,8 +44,8 @@ const layers = [
// city=Manhattan
const explicit_borough_layers = [
'venue',
'street',
'address',
'street',
'neighbourhood',
'borough',
'locality',

24
test/unit/middleware/trimByGranularityComponent.js

@ -19,8 +19,8 @@ module.exports.tests.trimByGranularity = function(test, common) {
data: [
{ name: 'venue 1', _matched_queries: ['fallback.venue'] },
{ name: 'venue 2', _matched_queries: ['fallback.venue'] },
{ name: 'street 1', _matched_queries: ['fallback.street'] },
{ name: 'address 1', _matched_queries: ['fallback.address'] },
{ name: 'street 1', _matched_queries: ['fallback.street'] },
{ name: 'neighbourhood 1', _matched_queries: ['fallback.neighbourhood'] },
{ name: 'borough 1', _matched_queries: ['fallback.borough'] },
{ name: 'locality 1', _matched_queries: ['fallback.locality'] },
@ -55,9 +55,9 @@ module.exports.tests.trimByGranularity = function(test, common) {
var res = {
data: [
{ name: 'street 1', _matched_queries: ['fallback.street'] },
{ name: 'street 2', _matched_queries: ['fallback.street'] },
{ name: 'address 1', _matched_queries: ['fallback.address'] },
{ name: 'address 2', _matched_queries: ['fallback.address'] },
{ name: 'street 1', _matched_queries: ['fallback.street'] },
{ name: 'neighbourhood 1', _matched_queries: ['fallback.neighbourhood'] },
{ name: 'borough 1', _matched_queries: ['fallback.borough'] },
{ name: 'locality 1', _matched_queries: ['fallback.locality'] },
@ -73,13 +73,13 @@ module.exports.tests.trimByGranularity = function(test, common) {
};
var expected_data = [
{ name: 'street 1', _matched_queries: ['fallback.street'] },
{ name: 'street 2', _matched_queries: ['fallback.street'] }
{ name: 'address 1', _matched_queries: ['fallback.address'] },
{ name: 'address 2', _matched_queries: ['fallback.address'] }
];
function testIt() {
trimByGranularity(req, res, function() {
t.deepEquals(res.data, expected_data, 'only street records should be here');
t.deepEquals(res.data, expected_data, 'only address records should be here');
t.end();
});
}
@ -87,13 +87,13 @@ module.exports.tests.trimByGranularity = function(test, common) {
testIt();
});
test('all records with fallback.* matched_queries name should retain only address when they are most granular', function(t) {
test('all records with fallback.* matched_queries name should retain only street when they are most granular', function(t) {
var req = { clean: {} };
var res = {
data: [
{ name: 'address 1', _matched_queries: ['fallback.address'] },
{ name: 'address 2', _matched_queries: ['fallback.address'] },
{ name: 'street 1', _matched_queries: ['fallback.street'] },
{ name: 'street 2', _matched_queries: ['fallback.street'] },
{ name: 'neighbourhood 1', _matched_queries: ['fallback.neighbourhood'] },
{ name: 'borough 1', _matched_queries: ['fallback.borough'] },
{ name: 'locality 1', _matched_queries: ['fallback.locality'] },
@ -109,13 +109,13 @@ module.exports.tests.trimByGranularity = function(test, common) {
};
var expected_data = [
{ name: 'address 1', _matched_queries: ['fallback.address'] },
{ name: 'address 2', _matched_queries: ['fallback.address'] },
{ name: 'street 1', _matched_queries: ['fallback.street'] },
{ name: 'street 2', _matched_queries: ['fallback.street'] },
];
function testIt() {
trimByGranularity(req, res, function() {
t.deepEquals(res.data, expected_data, 'only address records should be here');
t.deepEquals(res.data, expected_data, 'only street records should be here');
t.end();
});
}

Loading…
Cancel
Save