Added option to include-exclude ads without price
This commit is contained in:
@@ -98,6 +98,7 @@ const findRealEstatesForSearchRequest = async (searchRequest, maxResults) => {
|
|||||||
floorMin,
|
floorMin,
|
||||||
floorMax,
|
floorMax,
|
||||||
includeIncompleteAds,
|
includeIncompleteAds,
|
||||||
|
includeWithoutPrice,
|
||||||
balcony,
|
balcony,
|
||||||
elevator,
|
elevator,
|
||||||
newBuilding,
|
newBuilding,
|
||||||
@@ -139,15 +140,6 @@ const findRealEstatesForSearchRequest = async (searchRequest, maxResults) => {
|
|||||||
const query = {
|
const query = {
|
||||||
adType,
|
adType,
|
||||||
realEstateType,
|
realEstateType,
|
||||||
price: {
|
|
||||||
[Op.or]: {
|
|
||||||
[Op.and]: {
|
|
||||||
[Op.lte]: priceMax,
|
|
||||||
[Op.gte]: priceMin
|
|
||||||
},
|
|
||||||
[Op.is]: null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
area: {
|
area: {
|
||||||
[Op.lte]: sizeMax,
|
[Op.lte]: sizeMax,
|
||||||
[Op.gte]: sizeMin
|
[Op.gte]: sizeMin
|
||||||
@@ -159,15 +151,6 @@ const findRealEstatesForSearchRequest = async (searchRequest, maxResults) => {
|
|||||||
const queryIncludeIncomplete = {
|
const queryIncludeIncomplete = {
|
||||||
adType,
|
adType,
|
||||||
realEstateType,
|
realEstateType,
|
||||||
price: {
|
|
||||||
[Op.or]: {
|
|
||||||
[Op.and]: {
|
|
||||||
[Op.lte]: priceMax,
|
|
||||||
[Op.gte]: priceMin
|
|
||||||
},
|
|
||||||
[Op.is]: null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
area: {
|
area: {
|
||||||
[Op.or]: {
|
[Op.or]: {
|
||||||
[Op.and]: {
|
[Op.and]: {
|
||||||
@@ -180,6 +163,42 @@ const findRealEstatesForSearchRequest = async (searchRequest, maxResults) => {
|
|||||||
[Op.and]: geoSearchQueryPart
|
[Op.and]: geoSearchQueryPart
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Is user checked includeWithoutPrice TRUE then it should return null values of price
|
||||||
|
//If not then only check for price max and min (this is DEFAULT)
|
||||||
|
//includeIncpompleteAds does not have effect on price query
|
||||||
|
if (includeWithoutPrice) {
|
||||||
|
query.price = {
|
||||||
|
[Op.or]: {
|
||||||
|
[Op.and]: {
|
||||||
|
[Op.lte]: priceMax,
|
||||||
|
[Op.gte]: priceMin
|
||||||
|
},
|
||||||
|
[Op.is]: null
|
||||||
|
}
|
||||||
|
};
|
||||||
|
queryIncludeIncomplete.price = {
|
||||||
|
[Op.or]: {
|
||||||
|
[Op.and]: {
|
||||||
|
[Op.lte]: priceMax,
|
||||||
|
[Op.gte]: priceMin
|
||||||
|
},
|
||||||
|
[Op.is]: null
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
query.price = {
|
||||||
|
[Op.and]: {
|
||||||
|
[Op.lte]: priceMax,
|
||||||
|
[Op.gte]: priceMin
|
||||||
|
}
|
||||||
|
};
|
||||||
|
queryIncludeIncomplete.price = {
|
||||||
|
[Op.and]: {
|
||||||
|
[Op.lte]: priceMax,
|
||||||
|
[Op.gte]: priceMin
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
//Every other attribute is checked separately and included in query only if it is defined for real estate type
|
//Every other attribute is checked separately and included in query only if it is defined for real estate type
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -57,7 +57,8 @@ const findSearchRequestsForRealEstate = async realEstate => {
|
|||||||
|
|
||||||
//Attributes are checked separately to make different query parts
|
//Attributes are checked separately to make different query parts
|
||||||
|
|
||||||
//If price is null it will be excluded from query - it will show properties with null price values
|
//If real estate price is number then it searches for req that have priceMin and priceMax
|
||||||
|
//If real estate price is null it searches for req that accept ads without price
|
||||||
//User always defines price and area (sliders) - not null in search req
|
//User always defines price and area (sliders) - not null in search req
|
||||||
let priceQuery = {};
|
let priceQuery = {};
|
||||||
if (price != null) {
|
if (price != null) {
|
||||||
@@ -75,6 +76,12 @@ const findSearchRequestsForRealEstate = async realEstate => {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
priceQuery = {
|
||||||
|
includeWithoutPrice: {
|
||||||
|
[Op.eq]: true
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let areaQuery = {};
|
let areaQuery = {};
|
||||||
|
|||||||
Reference in New Issue
Block a user