From c42a55af1299a88ba4fea6ceb4a952c94f04e4d5 Mon Sep 17 00:00:00 2001 From: Timo Volkmann Date: Mon, 22 Jun 2020 15:41:22 +0200 Subject: [PATCH] fixed 400 search --- backend/routes/search.js | 4 +++- backend/util/scoreAndSearch.js | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/routes/search.js b/backend/routes/search.js index 0f1427f..f10eacb 100644 --- a/backend/routes/search.js +++ b/backend/routes/search.js @@ -38,7 +38,9 @@ function searchHandler(dbConn) { console.log('Q:', q) // transform syntax and seperate climate queries from price queries - q = oldToNewQuerySyntax(q) + if (!req.query.q) { + q = oldToNewQuerySyntax(q) + } // CHOOSE PARAMS WHICH SHALL BE PASSED TO SCORE AND SEARCH let scoreQueryObj = prepareQueries(q) diff --git a/backend/util/scoreAndSearch.js b/backend/util/scoreAndSearch.js index e7d5f41..ebd7ba4 100644 --- a/backend/util/scoreAndSearch.js +++ b/backend/util/scoreAndSearch.js @@ -23,8 +23,7 @@ const MULTIPLIER = { module.exports = function (dbConn) { return async function (from, to, q) { console.log('search') - console.log((_.isEmpty(to) || _.isEmpty(from)) && !_.isEmpty(q)) - if ( (_.isEmpty(to) || _.isEmpty(from)) && (!_.isEmpty(q.climate) || !_.isEmpty(q.costs)) ) { + if ((_.isNil(to) || _.isNil(from)) && !(_.isEmpty(q.climate) || _.isEmpty(q.costs))) { throw new Error('invalid query') } // PREPARE SEARCH