Browse Source

feat(queries): Normalize all query names

They should start with the endpoint (ideally), and
address_search_using_ids should not have the same query name as
'search_fallback'.
pull/1220/head
Julian Simioni 6 years ago
parent
commit
4adf4b3dd7
No known key found for this signature in database
GPG Key ID: B9EEB0C6EE0910A1
  1. 2
      query/address_search_using_ids.js
  2. 2
      query/search.js
  3. 2
      query/search_original.js
  4. 2
      query/structured_geocoding.js
  5. 2
      test/unit/query/address_search_using_ids.js
  6. 20
      test/unit/query/search.js
  7. 22
      test/unit/query/search_original.js
  8. 2
      test/unit/query/structured_geocoding.js

2
query/address_search_using_ids.js

@ -176,7 +176,7 @@ function generateQuery( clean, res ){
}
return {
type: 'fallback',
type: 'address_search_using_ids',
body: addressUsingIdsQuery.render(vs)
};

2
query/search.js

@ -116,7 +116,7 @@ function generateQuery( clean ){
function getQuery(vs) {
if (hasStreet(vs) || isPostalCodeOnly(vs) || isPostalCodeWithCountry(vs)) {
return {
type: 'fallback',
type: 'search_fallback',
body: fallbackQuery.render(vs)
};
}

2
query/search_original.js

@ -131,7 +131,7 @@ function generateQuery( clean ){
}
return {
type: 'original',
type: 'search_original',
body: query.render(vs)
};
}

2
query/structured_geocoding.js

@ -104,7 +104,7 @@ function generateQuery( clean ){
function getQuery(vs) {
return {
type: 'fallback',
type: 'structured',
body: structuredQuery.render(vs)
};
}

2
test/unit/query/address_search_using_ids.js

@ -49,7 +49,7 @@ module.exports.tests.base_query = (test, common) => {
const generatedQuery = generateQuery(clean, res);
t.equals(generatedQuery.type, 'fallback');
t.equals(generatedQuery.type, 'address_search_using_ids');
t.equals(generatedQuery.body.vs.var('input:housenumber').toString(), 'housenumber value');
t.equals(generatedQuery.body.vs.var('input:street').toString(), 'street value');

20
test/unit/query/search.js

@ -31,7 +31,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_focus_bbox');
t.deepEqual(compiled.type, 'fallback', 'query type set');
t.deepEqual(compiled.type, 'search_fallback', 'query type set');
t.deepEqual(compiled.body, expected, 'search_linguistic_focus_bbox');
t.end();
});
@ -55,7 +55,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_bbox');
t.deepEqual(compiled.type, 'fallback', 'query type set');
t.deepEqual(compiled.type, 'search_fallback', 'query type set');
t.deepEqual(compiled.body, expected, 'search_linguistic_bbox');
t.end();
});
@ -74,7 +74,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_only');
t.deepEqual(compiled.type, 'fallback', 'query type set');
t.deepEqual(compiled.type, 'search_fallback', 'query type set');
t.deepEqual(compiled.body, expected, 'search_linguistic_only');
t.end();
});
@ -94,7 +94,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_focus');
t.deepEqual(compiled.type, 'fallback', 'query type set');
t.deepEqual(compiled.type, 'search_fallback', 'query type set');
t.deepEqual(compiled.body, expected, 'search_linguistic_focus');
t.end();
});
@ -114,7 +114,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_focus_null_island');
t.deepEqual(compiled.type, 'fallback', 'query type set');
t.deepEqual(compiled.type, 'search_fallback', 'query type set');
t.deepEqual(compiled.body, expected, 'search_linguistic_focus_null_island');
t.end();
});
@ -141,7 +141,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse(JSON.stringify(query));
var expected = require('../fixture/search_fallback');
t.deepEqual(compiled.type, 'fallback', 'query type set');
t.deepEqual(compiled.type, 'search_fallback', 'query type set');
t.deepEqual(compiled.body, expected, 'fallbackQuery');
t.end();
@ -180,7 +180,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_boundary_country');
t.deepEqual(compiled.type, 'fallback', 'query type set');
t.deepEqual(compiled.type, 'search_fallback', 'query type set');
t.deepEqual(compiled.body, expected, 'search: valid boundary.country query');
t.end();
});
@ -199,7 +199,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_with_source_filtering');
t.deepEqual(compiled.type, 'fallback', 'query type set');
t.deepEqual(compiled.type, 'search_fallback', 'query type set');
t.deepEqual(compiled.body, expected, 'search: valid search query with source filtering');
t.end();
});
@ -218,7 +218,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_with_category_filtering');
t.deepEqual(compiled.type, 'fallback', 'query type set');
t.deepEqual(compiled.type, 'search_fallback', 'query type set');
t.deepEqual(compiled.body, expected, 'valid search query with category filtering');
t.end();
});
@ -568,7 +568,7 @@ module.exports.tests.city_country = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_fallback_postalcode_only');
t.deepEqual(compiled.type, 'fallback', 'query type set');
t.deepEqual(compiled.type, 'search_fallback', 'query type set');
t.deepEqual(compiled.body, expected, 'search_fallback_postalcode_only');
t.end();
});

22
test/unit/query/search_original.js

@ -24,7 +24,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_focus_bbox_original');
t.deepEqual(compiled.type, 'original', 'query type set');
t.deepEqual(compiled.type, 'search_original', 'query type set');
t.deepEqual(compiled.body, expected, 'search_linguistic_focus_bbox');
t.end();
});
@ -42,7 +42,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_bbox_original');
t.deepEqual(compiled.type, 'original', 'query type set');
t.deepEqual(compiled.type, 'search_original', 'query type set');
t.deepEqual(compiled.body, expected, 'search_linguistic_bbox');
t.end();
});
@ -56,7 +56,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_only_original');
t.deepEqual(compiled.type, 'original', 'query type set');
t.deepEqual(compiled.type, 'search_original', 'query type set');
t.deepEqual(compiled.body, expected, 'search_linguistic_only');
t.end();
});
@ -71,7 +71,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_focus_original');
t.deepEqual(compiled.type, 'original', 'query type set');
t.deepEqual(compiled.type, 'search_original', 'query type set');
t.deepEqual(compiled.body, expected, 'search_linguistic_focus');
t.end();
});
@ -86,7 +86,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_focus_null_island_original');
t.deepEqual(compiled.type, 'original', 'query type set');
t.deepEqual(compiled.type, 'search_original', 'query type set');
t.deepEqual(compiled.body, expected, 'search_linguistic_focus_null_island');
t.end();
});
@ -108,7 +108,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_full_address_original');
t.deepEqual(compiled.type, 'original', 'query type set');
t.deepEqual(compiled.type, 'search_original', 'query type set');
t.deepEqual(compiled.body, expected, 'search_full_address');
t.end();
});
@ -127,7 +127,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_partial_address_original');
t.deepEqual(compiled.type, 'original', 'query type set');
t.deepEqual(compiled.type, 'search_original', 'query type set');
t.deepEqual(compiled.body, expected, 'search_partial_address');
t.end();
});
@ -146,7 +146,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_regions_address_original');
t.deepEqual(compiled.type, 'original', 'query type set');
t.deepEqual(compiled.type, 'search_original', 'query type set');
t.deepEqual(compiled.body, expected, 'search_regions_address');
t.end();
});
@ -161,7 +161,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_boundary_country_original');
t.deepEqual(compiled.type, 'original', 'query type set');
t.deepEqual(compiled.type, 'search_original', 'query type set');
t.deepEqual(compiled.body, expected, 'search: valid boundary.country query');
t.end();
});
@ -175,7 +175,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_with_source_filtering_original');
t.deepEqual(compiled.type, 'original', 'query type set');
t.deepEqual(compiled.type, 'search_original', 'query type set');
t.deepEqual(compiled.body, expected, 'search: valid search query with source filtering');
t.end();
});
@ -189,7 +189,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_with_category_filtering_original');
t.deepEqual(compiled.type, 'original', 'query type set');
t.deepEqual(compiled.type, 'search_original', 'query type set');
t.deepEqual(compiled.body, expected, 'valid search query with category filtering');
t.end();
});

2
test/unit/query/structured_geocoding.js

@ -50,7 +50,7 @@ module.exports.tests.query = (test, common) => {
}
})(clean);
t.equals(query.type, 'fallback', 'query type set');
t.equals(query.type, 'structured', 'query type set');
t.equals(query.body.vs.var('input:name').toString(), 'text value');
t.equals(query.body.vs.var('sources').toString(), 'sources value');
t.equals(query.body.vs.var('layers').toString(), 'layers value');

Loading…
Cancel
Save