Changed acces road type check and include incomplete

This commit is contained in:
Naida Vatric
2019-12-13 00:45:28 +01:00
parent 0e585e74ae
commit e83712fb33
3 changed files with 129 additions and 16 deletions

View File

@@ -5,7 +5,7 @@ const Op = sequelize.Op;
const getSearchRequest = async searchRequestId => {
try {
console.log("test");
return await db.SearchRequest.findByPk(searchRequestId);
} catch (error) {
@@ -51,12 +51,13 @@ const findSearchRequestsForRealEstate = async realEstate => {
const geoSearchQueryPart = sequelize.where(contains, true);
//WIP This wont work, need to separate queries by adType and realEstateType
//because for example flat does not have gardenSize and that can't be in query
const query = {
adType,
realEstateType,
subscribed: true,
//
accessRoadType,
balcony,
newBuilding,
elevator,
@@ -113,6 +114,14 @@ const findSearchRequestsForRealEstate = async realEstate => {
[Op.gte]: floor
};
}
if (accessRoadType) {
query.accessRoadType = {
[Op.or]: {
[Op.eq]: 'ANY',
[Op.eq]: accessRoadType
}
}
}
return await db.SearchRequest.findAll({ where: query });
};