Browse Source

Send warning when sources=quattroshapes

pull/465/head
Julian Simioni 9 years ago
parent
commit
e97d72d7b6
  1. 25
      sanitiser/_warn_quattroshapes.js
  2. 1
      sanitiser/reverse.js
  3. 1
      sanitiser/search.js
  4. 3
      test/unit/sanitiser/reverse.js
  5. 3
      test/unit/sanitiser/search.js

25
sanitiser/_warn_quattroshapes.js

@ -0,0 +1,25 @@
var _ = require('lodash');
function setup( paramName, targetMap ) {
return function( raw, clean ){
return sanitize( raw, clean );
};
}
function sanitize( raw, clean, opts ) {
// error & warning messages
var messages = { errors: [], warnings: [] };
if (_.includes(raw.sources, 'quattroshapes') || _.includes(raw.sources, 'qs')) {
messages.warnings.push( 'You are using Quattroshapes as a data source in this query. ' +
'Quattroshapes will be disabled as a data source for Mapzen Search in the next several ' +
'weeks, and is being replaced by Who\'s on First, an actively maintained data project ' +
'based on Quattroshapes. Your existing queries WILL CONTINUE TO WORK for the foreseeable ' +
'future, but results will be coming from Who\'s on First and `source=quattroshapes` will ' +
'be deprecated. If you have any questions, please email search@mapzen.com.');
}
return messages;
}
module.exports = setup;

1
sanitiser/reverse.js

@ -5,6 +5,7 @@ var sanitizeAll = require('../sanitiser/sanitizeAll'),
singleScalarParameters: require('../sanitiser/_single_scalar_parameters'), singleScalarParameters: require('../sanitiser/_single_scalar_parameters'),
layers: require('../sanitiser/_targets')('layers', type_mapping.layer_with_aliases_to_type), layers: require('../sanitiser/_targets')('layers', type_mapping.layer_with_aliases_to_type),
sources: require('../sanitiser/_targets')('sources', type_mapping.source_to_type), sources: require('../sanitiser/_targets')('sources', type_mapping.source_to_type),
quattroshapes_warning: require('../sanitiser/_warn_quattroshapes')(),
size: require('../sanitiser/_size'), size: require('../sanitiser/_size'),
private: require('../sanitiser/_flag_bool')('private', false), private: require('../sanitiser/_flag_bool')('private', false),
geo_reverse: require('../sanitiser/_geo_reverse'), geo_reverse: require('../sanitiser/_geo_reverse'),

1
sanitiser/search.js

@ -7,6 +7,7 @@ var sanitizeAll = require('../sanitiser/sanitizeAll'),
size: require('../sanitiser/_size'), size: require('../sanitiser/_size'),
layers: require('../sanitiser/_targets')('layers', type_mapping.layer_with_aliases_to_type), layers: require('../sanitiser/_targets')('layers', type_mapping.layer_with_aliases_to_type),
sources: require('../sanitiser/_targets')('sources', type_mapping.source_to_type), sources: require('../sanitiser/_targets')('sources', type_mapping.source_to_type),
quattroshapes_warning: require('../sanitiser/_warn_quattroshapes')(),
private: require('../sanitiser/_flag_bool')('private', false), private: require('../sanitiser/_flag_bool')('private', false),
geo_search: require('../sanitiser/_geo_search'), geo_search: require('../sanitiser/_geo_search'),
boundary_country: require('../sanitiser/_boundary_country'), boundary_country: require('../sanitiser/_boundary_country'),

3
test/unit/sanitiser/reverse.js

@ -38,7 +38,8 @@ module.exports.tests.interface = function(test, common) {
module.exports.tests.sanitisers = function(test, common) { module.exports.tests.sanitisers = function(test, common) {
test('check sanitiser list', function (t) { test('check sanitiser list', function (t) {
var expected = ['singleScalarParameters', 'layers', 'sources', 'size', 'private', 'geo_reverse', 'boundary_country']; var expected = [ 'singleScalarParameters', 'layers', 'sources', 'quattroshapes_warning',
'size', 'private', 'geo_reverse', 'boundary_country' ];
t.deepEqual(Object.keys(reverse.sanitiser_list), expected); t.deepEqual(Object.keys(reverse.sanitiser_list), expected);
t.end(); t.end();
}); });

3
test/unit/sanitiser/search.js

@ -24,7 +24,8 @@ module.exports.tests.interface = function(test, common) {
module.exports.tests.sanitisers = function(test, common) { module.exports.tests.sanitisers = function(test, common) {
test('check sanitiser list', function (t) { test('check sanitiser list', function (t) {
var expected = ['singleScalarParameters', 'text', 'size', 'layers', 'sources', 'private', 'geo_search', 'boundary_country' ]; var expected = [ 'singleScalarParameters', 'text', 'size', 'layers', 'sources',
'quattroshapes_warning', 'private', 'geo_search', 'boundary_country' ];
t.deepEqual(Object.keys(search.sanitiser_list), expected); t.deepEqual(Object.keys(search.sanitiser_list), expected);
t.end(); t.end();
}); });

Loading…
Cancel
Save