implemented null score filter
This commit is contained in:
parent
76d9036a61
commit
d92c164127
@ -43,6 +43,7 @@ function searchHandler(dbConn) {
|
||||
if (q.precipitation) scoreQueryObj['precipitation'] = q.precipitation
|
||||
if (q.rain_days) scoreQueryObj['rain_days'] = q.rain_days
|
||||
if (q.sun_hours) scoreQueryObj['sun_hours'] = q.sun_hours
|
||||
|
||||
if (q.accommodation_costs) scoreQueryObj['accommodation_costs'] = q.accommodation_costs
|
||||
if (q.food_costs) scoreQueryObj['food_costs'] = q.food_costs
|
||||
if (q.alcohol_costs) scoreQueryObj['alcohol_costs'] = q.alcohol_costs
|
||||
@ -65,7 +66,15 @@ function searchHandler(dbConn) {
|
||||
} else {
|
||||
response = searchResults
|
||||
}
|
||||
|
||||
// FILTER NULLSCORES
|
||||
if (_.get(q, 'showRegionsWithNullScore', false)) {
|
||||
console.log('without null scores');
|
||||
response = response.filter(el => !_.some(el.scores, score => _.isNaN(score.score) || _.isNull(score.score) || _.isUndefined(score.score)))//.filter(el => !_.isNaN(el.score))
|
||||
}
|
||||
// SEND RESPONSE
|
||||
res.json(response)
|
||||
|
||||
}).catch(e => {
|
||||
// TODO error handling
|
||||
console.log(e)
|
||||
@ -76,8 +85,8 @@ function searchHandler(dbConn) {
|
||||
|
||||
function filterByString(searchResults, filterString, boolFulltext) {
|
||||
return _.filter(searchResults, region => {
|
||||
console.log("filtering: filterString, boolFulltext");
|
||||
console.log(filterString, boolFulltext);
|
||||
// console.log("filtering: filterString, boolFulltext");
|
||||
// console.log(filterString, boolFulltext);
|
||||
filterString = filterString.toLowerCase()
|
||||
let name = region.name.toLowerCase()
|
||||
let country = region.country.toLowerCase()
|
||||
|
||||
@ -27,7 +27,7 @@ module.exports = function (dbConn) {
|
||||
console.log('search')
|
||||
console.log((_.isEmpty(to) || _.isEmpty(from)) && !_.isEmpty(queries))
|
||||
if ((_.isEmpty(to) || _.isEmpty(from)) && !_.isEmpty(queries)) {
|
||||
throw new Error('Invalid Parameters...')
|
||||
throw new Error('invalid query')
|
||||
}
|
||||
// PREPARE SEARCH
|
||||
// validate dates
|
||||
|
||||
Loading…
Reference in New Issue
Block a user