Merge branch 'ads-without-price' into 'master'
Ads without price See merge request saburly/marketalarm/web!88
This commit was merged in pull request #88.
This commit is contained in:
1
.prettierignore
Normal file
1
.prettierignore
Normal file
@@ -0,0 +1 @@
|
|||||||
|
*.ejs
|
||||||
@@ -35,7 +35,8 @@ const getFilters = async (req, res) => {
|
|||||||
balcony,
|
balcony,
|
||||||
elevator,
|
elevator,
|
||||||
newBuilding,
|
newBuilding,
|
||||||
accessRoadType
|
accessRoadType,
|
||||||
|
includeWithoutPrice
|
||||||
} = searchRequest;
|
} = searchRequest;
|
||||||
const category = AD_CATEGORY[realEstateType] || AD_CATEGORY.FLAT;
|
const category = AD_CATEGORY[realEstateType] || AD_CATEGORY.FLAT;
|
||||||
|
|
||||||
@@ -115,7 +116,8 @@ const getFilters = async (req, res) => {
|
|||||||
advancedSegmentSelectFilterValues,
|
advancedSegmentSelectFilterValues,
|
||||||
advancedRangeFilterObjects,
|
advancedRangeFilterObjects,
|
||||||
advancedRangeFilterValues,
|
advancedRangeFilterValues,
|
||||||
includeIncompleteAds
|
includeIncompleteAds,
|
||||||
|
includeWithoutPrice
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -191,6 +193,7 @@ const postFilters = async (req, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const includeIncompleteAds = req.body.includeIncompleteAds === "on";
|
const includeIncompleteAds = req.body.includeIncompleteAds === "on";
|
||||||
|
const includeWithoutPrice = req.body.includeWithoutPrice === "on";
|
||||||
|
|
||||||
const balcony = req.body.balcony === "on";
|
const balcony = req.body.balcony === "on";
|
||||||
const elevator = req.body.elevator === "on";
|
const elevator = req.body.elevator === "on";
|
||||||
@@ -217,6 +220,7 @@ const postFilters = async (req, res) => {
|
|||||||
searchRequest.newBuilding = newBuilding;
|
searchRequest.newBuilding = newBuilding;
|
||||||
|
|
||||||
searchRequest.includeIncompleteAds = includeIncompleteAds;
|
searchRequest.includeIncompleteAds = includeIncompleteAds;
|
||||||
|
searchRequest.includeWithoutPrice = includeWithoutPrice;
|
||||||
|
|
||||||
searchRequest.accessRoadType = accessRoadType;
|
searchRequest.accessRoadType = accessRoadType;
|
||||||
|
|
||||||
|
|||||||
@@ -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 unchecked includeWithoutPrice FALSE then it shouldn't return null values of price
|
||||||
|
//If not then null values are accepted (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 = {};
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
up: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.addColumn("SearchRequests", "includeWithoutPrice", {
|
||||||
|
type: Sequelize.BOOLEAN,
|
||||||
|
defaultValue: true
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
down: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.removeColumn("SearchRequests", "includeWithoutPrice");
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -15,7 +15,15 @@ module.exports = (sequelize, DataTypes) => {
|
|||||||
allowNull: false,
|
allowNull: false,
|
||||||
defaultValue: {
|
defaultValue: {
|
||||||
type: "Polygon",
|
type: "Polygon",
|
||||||
coordinates: [[[0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]],
|
coordinates: [
|
||||||
|
[
|
||||||
|
[0, 0],
|
||||||
|
[0, 0],
|
||||||
|
[0, 0],
|
||||||
|
[0, 0],
|
||||||
|
[0, 0]
|
||||||
|
]
|
||||||
|
],
|
||||||
crs: { type: "name", properties: { name: "EPSG:4326" } }
|
crs: { type: "name", properties: { name: "EPSG:4326" } }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -71,6 +79,7 @@ module.exports = (sequelize, DataTypes) => {
|
|||||||
type: DataTypes.TEXT
|
type: DataTypes.TEXT
|
||||||
},
|
},
|
||||||
includeIncompleteAds: DataTypes.BOOLEAN,
|
includeIncompleteAds: DataTypes.BOOLEAN,
|
||||||
|
includeWithoutPrice: DataTypes.BOOLEAN,
|
||||||
balcony: DataTypes.BOOLEAN,
|
balcony: DataTypes.BOOLEAN,
|
||||||
elevator: DataTypes.BOOLEAN,
|
elevator: DataTypes.BOOLEAN,
|
||||||
newBuilding: DataTypes.BOOLEAN,
|
newBuilding: DataTypes.BOOLEAN,
|
||||||
|
|||||||
@@ -18,6 +18,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
<p class="distinguished">
|
||||||
|
<label class="checkbox-label">
|
||||||
|
<input type="checkbox" class="filled-in" name="includeWithoutPrice"
|
||||||
|
checked
|
||||||
|
>
|
||||||
|
<span>Uključi i oglase bez cijene</span>
|
||||||
|
</label>
|
||||||
|
</p>
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<div class="row center-align">
|
<div class="row center-align">
|
||||||
|
|||||||
Reference in New Issue
Block a user