Merge branch 'bugfix/major-searcherror' into 'develop'

fixed 400 search

See merge request tjohn/cc-data!18
This commit is contained in:
Timo Volkmann 2020-06-22 15:42:54 +02:00
commit 47c664894c
2 changed files with 4 additions and 3 deletions

View File

@ -38,7 +38,9 @@ function searchHandler(dbConn) {
console.log('Q:', q) console.log('Q:', q)
// transform syntax and seperate climate queries from price queries // transform syntax and seperate climate queries from price queries
if (!req.query.q) {
q = oldToNewQuerySyntax(q) q = oldToNewQuerySyntax(q)
}
// CHOOSE PARAMS WHICH SHALL BE PASSED TO SCORE AND SEARCH // CHOOSE PARAMS WHICH SHALL BE PASSED TO SCORE AND SEARCH
let scoreQueryObj = prepareQueries(q) let scoreQueryObj = prepareQueries(q)

View File

@ -23,8 +23,7 @@ const MULTIPLIER = {
module.exports = function (dbConn) { module.exports = function (dbConn) {
return async function (from, to, q) { return async function (from, to, q) {
console.log('search') console.log('search')
console.log((_.isEmpty(to) || _.isEmpty(from)) && !_.isEmpty(q)) if ((_.isNil(to) || _.isNil(from)) && !(_.isEmpty(q.climate) || _.isEmpty(q.costs))) {
if ( (_.isEmpty(to) || _.isEmpty(from)) && (!_.isEmpty(q.climate) || !_.isEmpty(q.costs)) ) {
throw new Error('invalid query') throw new Error('invalid query')
} }
// PREPARE SEARCH // PREPARE SEARCH