Browse Source

fix(confidence): Update query type names in confidence score code

4adf4b3dd7
renamed some queries to be quite a bit more informative, however it
wasn't obvious that these query names were used elsewhere in the code.

With those changes, no confidence score middleware was running, which
this should help fix.
pull/1224/head
Julian Simioni 6 years ago
parent
commit
c548a73cb9
No known key found for this signature in database
GPG Key ID: B9EEB0C6EE0910A1
  1. 2
      controller/placeholder.js
  2. 2
      middleware/confidenceScore.js
  3. 2
      middleware/confidenceScoreFallback.js
  4. 42
      test/unit/controller/placeholder.js
  5. 14
      test/unit/middleware/confidenceScore.js
  6. 30
      test/unit/middleware/confidenceScoreFallback.js

2
controller/placeholder.js

@ -250,7 +250,7 @@ function setup(placeholderService, do_geometric_filters_apply, should_execute) {
// boundary.country filter must happen after synthesis since multiple // boundary.country filter must happen after synthesis since multiple
// lineages may produce different country docs // lineages may produce different country docs
res.meta = { res.meta = {
query_type: 'fallback' query_type: 'search_fallback'
}; };
res.data = results res.data = results

2
middleware/confidenceScore.js

@ -29,7 +29,7 @@ function computeScores(req, res, next) {
// do nothing if no result data set or if query is not of the original variety // do nothing if no result data set or if query is not of the original variety
if (check.undefined(req.clean) || check.undefined(res) || if (check.undefined(req.clean) || check.undefined(res) ||
check.undefined(res.data) || check.undefined(res.meta) || check.undefined(res.data) || check.undefined(res.meta) ||
res.meta.query_type !== 'original') { res.meta.query_type !== 'search_original') {
return next(); return next();
} }

2
middleware/confidenceScoreFallback.js

@ -22,7 +22,7 @@ function computeScores(req, res, next) {
// later add disambiguation to this list // later add disambiguation to this list
if (check.undefined(req.clean) || check.undefined(res) || if (check.undefined(req.clean) || check.undefined(res) ||
check.undefined(res.data) || check.undefined(res.meta) || check.undefined(res.data) || check.undefined(res.meta) ||
res.meta.query_type !== 'fallback') { res.meta.query_type !== 'search_fallback') {
return next(); return next();
} }

42
test/unit/controller/placeholder.js

@ -212,7 +212,7 @@ module.exports.tests.success = (test, common) => {
controller(req, res, () => { controller(req, res, () => {
const expected_res = { const expected_res = {
meta: { meta: {
query_type: 'fallback' query_type: 'search_fallback'
}, },
data: [ data: [
{ {
@ -330,7 +330,7 @@ module.exports.tests.success = (test, common) => {
controller(req, res, () => { controller(req, res, () => {
const expected_res = { const expected_res = {
meta: { meta: {
query_type: 'fallback' query_type: 'search_fallback'
}, },
data: [ data: [
{ {
@ -393,7 +393,7 @@ module.exports.tests.success = (test, common) => {
controller(req, res, () => { controller(req, res, () => {
const expected_res = { const expected_res = {
meta: { meta: {
query_type: 'fallback' query_type: 'search_fallback'
}, },
data: [ data: [
{ {
@ -453,7 +453,7 @@ module.exports.tests.success = (test, common) => {
controller(req, res, () => { controller(req, res, () => {
const expected_res = { const expected_res = {
meta: { meta: {
query_type: 'fallback' query_type: 'search_fallback'
}, },
data: [ data: [
{ {
@ -518,7 +518,7 @@ module.exports.tests.success = (test, common) => {
controller(req, res, () => { controller(req, res, () => {
const expected_res = { const expected_res = {
meta: { meta: {
query_type: 'fallback' query_type: 'search_fallback'
}, },
data: [ data: [
{ {
@ -583,7 +583,7 @@ module.exports.tests.success = (test, common) => {
controller(req, res, () => { controller(req, res, () => {
const expected_res = { const expected_res = {
meta: { meta: {
query_type: 'fallback' query_type: 'search_fallback'
}, },
data: [ data: [
{ {
@ -756,7 +756,7 @@ module.exports.tests.result_filtering = (test, common) => {
controller(req, res, () => { controller(req, res, () => {
const expected_res = { const expected_res = {
meta: { meta: {
query_type: 'fallback' query_type: 'search_fallback'
}, },
data: [ data: [
{ {
@ -874,7 +874,7 @@ module.exports.tests.result_filtering = (test, common) => {
controller(req, res, () => { controller(req, res, () => {
const expected_res = { const expected_res = {
meta: { meta: {
query_type: 'fallback' query_type: 'search_fallback'
}, },
data: [ data: [
{ {
@ -1075,7 +1075,7 @@ module.exports.tests.result_filtering = (test, common) => {
controller(req, res, () => { controller(req, res, () => {
const expected_res = { const expected_res = {
meta: { meta: {
query_type: 'fallback' query_type: 'search_fallback'
}, },
data: [ data: [
{ {
@ -1191,7 +1191,7 @@ module.exports.tests.result_filtering = (test, common) => {
controller(req, res, () => { controller(req, res, () => {
const expected_res = { const expected_res = {
meta: { meta: {
query_type: 'fallback' query_type: 'search_fallback'
}, },
data: [ data: [
{ {
@ -1345,7 +1345,7 @@ module.exports.tests.result_filtering = (test, common) => {
controller(req, res, () => { controller(req, res, () => {
const expected_res = { const expected_res = {
meta: { meta: {
query_type: 'fallback' query_type: 'search_fallback'
}, },
data: [ data: [
{ {
@ -1480,7 +1480,7 @@ module.exports.tests.result_filtering = (test, common) => {
controller(req, res, () => { controller(req, res, () => {
const expected_res = { const expected_res = {
meta: { meta: {
query_type: 'fallback' query_type: 'search_fallback'
}, },
data: [ data: [
{ {
@ -1629,7 +1629,7 @@ module.exports.tests.result_filtering = (test, common) => {
controller(req, res, () => { controller(req, res, () => {
const expected_res = { const expected_res = {
meta: { meta: {
query_type: 'fallback' query_type: 'search_fallback'
}, },
data: [ data: [
{ {
@ -1779,7 +1779,7 @@ module.exports.tests.result_filtering = (test, common) => {
controller(req, res, () => { controller(req, res, () => {
const expected_res = { const expected_res = {
meta: { meta: {
query_type: 'fallback' query_type: 'search_fallback'
}, },
data: [ data: [
{ {
@ -1906,7 +1906,7 @@ module.exports.tests.lineage_errors = (test, common) => {
controller(req, res, () => { controller(req, res, () => {
const expected_res = { const expected_res = {
meta: { meta: {
query_type: 'fallback' query_type: 'search_fallback'
}, },
data: [ data: [
{ {
@ -1980,7 +1980,7 @@ module.exports.tests.lineage_errors = (test, common) => {
controller(req, res, () => { controller(req, res, () => {
const expected_res = { const expected_res = {
meta: { meta: {
query_type: 'fallback' query_type: 'search_fallback'
}, },
data: [ data: [
{ {
@ -2053,7 +2053,7 @@ module.exports.tests.lineage_errors = (test, common) => {
controller(req, res, () => { controller(req, res, () => {
const expected_res = { const expected_res = {
meta: { meta: {
query_type: 'fallback' query_type: 'search_fallback'
}, },
data: [ data: [
{ {
@ -2113,7 +2113,7 @@ module.exports.tests.geometry_errors = (test, common) => {
controller(req, res, () => { controller(req, res, () => {
const expected_res = { const expected_res = {
meta: { meta: {
query_type: 'fallback' query_type: 'search_fallback'
}, },
data: [ data: [
{ {
@ -2172,7 +2172,7 @@ module.exports.tests.centroid_errors = (test, common) => {
controller(req, res, () => { controller(req, res, () => {
const expected_res = { const expected_res = {
meta: { meta: {
query_type: 'fallback' query_type: 'search_fallback'
}, },
data: [ data: [
{ {
@ -2232,7 +2232,7 @@ module.exports.tests.centroid_errors = (test, common) => {
controller(req, res, () => { controller(req, res, () => {
const expected_res = { const expected_res = {
meta: { meta: {
query_type: 'fallback' query_type: 'search_fallback'
}, },
data: [ data: [
{ {
@ -2302,7 +2302,7 @@ module.exports.tests.boundingbox_errors = (test, common) => {
controller(req, res, () => { controller(req, res, () => {
const expected_res = { const expected_res = {
meta: { meta: {
query_type: 'fallback' query_type: 'search_fallback'
}, },
data: [ data: [
{ {

14
test/unit/middleware/confidenceScore.js

@ -47,7 +47,7 @@ module.exports.tests.confidenceScore = function(test, common) {
}], }],
meta: { meta: {
scores: [10], scores: [10],
query_type: 'original' query_type: 'search_original'
} }
}; };
@ -89,7 +89,7 @@ module.exports.tests.confidenceScore = function(test, common) {
}], }],
meta: { meta: {
scores: [10], scores: [10],
query_type: 'original' query_type: 'search_original'
} }
}; };
@ -125,7 +125,7 @@ module.exports.tests.confidenceScore = function(test, common) {
}], }],
meta: { meta: {
scores: [10], scores: [10],
query_type: 'original' query_type: 'search_original'
} }
}; };
@ -134,7 +134,7 @@ module.exports.tests.confidenceScore = function(test, common) {
t.end(); t.end();
}); });
test('should only work for original query_type', function(t) { test('should only work for search_original query_type', function(t) {
var req = { var req = {
clean: { clean: {
text: '123 Main St, City, NM', text: '123 Main St, City, NM',
@ -161,7 +161,7 @@ module.exports.tests.confidenceScore = function(test, common) {
}], }],
meta: { meta: {
scores: [10], scores: [10],
query_type: 'fallback' query_type: 'search_fallback'
} }
}; };
@ -191,7 +191,7 @@ module.exports.tests.confidenceScore = function(test, common) {
}], }],
meta: { meta: {
scores: [10], scores: [10],
query_type: 'original' query_type: 'search_original'
} }
}; };
@ -223,7 +223,7 @@ module.exports.tests.confidenceScore = function(test, common) {
}], }],
meta: { meta: {
scores: [10], scores: [10],
query_type: 'original' query_type: 'search_original'
} }
}; };

30
test/unit/middleware/confidenceScoreFallback.js

@ -47,7 +47,7 @@ module.exports.tests.confidenceScore = function(test, common) {
}], }],
meta: { meta: {
scores: [10], scores: [10],
query_type: 'original' query_type: 'search_fallback'
} }
}; };
@ -89,7 +89,7 @@ module.exports.tests.confidenceScore = function(test, common) {
}], }],
meta: { meta: {
scores: [10], scores: [10],
query_type: 'fallback' query_type: 'search_fallback'
} }
}; };
@ -127,7 +127,7 @@ module.exports.tests.confidenceScore = function(test, common) {
}], }],
meta: { meta: {
scores: [10], scores: [10],
query_type: 'fallback' query_type: 'search_fallback'
} }
}; };
@ -163,7 +163,7 @@ module.exports.tests.confidenceScore = function(test, common) {
}], }],
meta: { meta: {
scores: [10], scores: [10],
query_type: 'fallback' query_type: 'search_fallback'
} }
}; };
@ -197,7 +197,7 @@ module.exports.tests.confidenceScore = function(test, common) {
}], }],
meta: { meta: {
scores: [10], scores: [10],
query_type: 'fallback' query_type: 'search_fallback'
} }
}; };
@ -230,7 +230,7 @@ module.exports.tests.confidenceScore = function(test, common) {
}], }],
meta: { meta: {
scores: [10], scores: [10],
query_type: 'fallback' query_type: 'search_fallback'
} }
}; };
@ -265,7 +265,7 @@ module.exports.tests.confidenceScore = function(test, common) {
}], }],
meta: { meta: {
scores: [10], scores: [10],
query_type: 'fallback' query_type: 'search_fallback'
} }
}; };
@ -300,7 +300,7 @@ module.exports.tests.confidenceScore = function(test, common) {
}], }],
meta: { meta: {
scores: [10], scores: [10],
query_type: 'fallback' query_type: 'search_fallback'
} }
}; };
@ -336,7 +336,7 @@ module.exports.tests.confidenceScore = function(test, common) {
}], }],
meta: { meta: {
scores: [10], scores: [10],
query_type: 'fallback' query_type: 'search_fallback'
} }
}; };
@ -360,7 +360,7 @@ module.exports.tests.confidenceScore = function(test, common) {
layer: 'locality' layer: 'locality'
}], }],
meta: { meta: {
query_type: 'fallback' query_type: 'search_fallback'
} }
}; };
@ -384,7 +384,7 @@ module.exports.tests.confidenceScore = function(test, common) {
layer: 'localadmin' layer: 'localadmin'
}], }],
meta: { meta: {
query_type: 'fallback' query_type: 'search_fallback'
} }
}; };
@ -408,7 +408,7 @@ module.exports.tests.confidenceScore = function(test, common) {
layer: 'region' layer: 'region'
}], }],
meta: { meta: {
query_type: 'fallback' query_type: 'search_fallback'
} }
}; };
@ -433,7 +433,7 @@ module.exports.tests.confidenceScore = function(test, common) {
layer: 'country' layer: 'country'
}], }],
meta: { meta: {
query_type: 'fallback' query_type: 'search_fallback'
} }
}; };
@ -461,7 +461,7 @@ module.exports.tests.confidenceScore = function(test, common) {
layer: 'postalcode' layer: 'postalcode'
}], }],
meta: { meta: {
query_type: 'fallback' query_type: 'search_fallback'
} }
}; };
confidenceScore(req, res, function() {}); confidenceScore(req, res, function() {});
@ -485,7 +485,7 @@ module.exports.tests.confidenceScore = function(test, common) {
layer: 'postalcode' layer: 'postalcode'
}], }],
meta: { meta: {
query_type: 'fallback' query_type: 'search_fallback'
} }
}; };
confidenceScore(req, res, function() {}); confidenceScore(req, res, function() {});

Loading…
Cancel
Save