Compare commits
9 Commits
edit-locat
...
results-li
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d23ddf849f | ||
|
|
38bd0343f5 | ||
|
|
259799144e | ||
|
|
bc73d4159d | ||
|
|
37ad32fe76 | ||
|
|
94875a0fa3 | ||
|
|
fa4e0d64de | ||
|
|
0c2d218d29 | ||
|
|
fed2dc00dc |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -2,4 +2,4 @@ node_modules/
|
|||||||
.env
|
.env
|
||||||
.idea/
|
.idea/
|
||||||
.eslintrc
|
.eslintrc
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ class RentalCrawler {
|
|||||||
|
|
||||||
let numberOfRooms =
|
let numberOfRooms =
|
||||||
parseInt(extractedData["re_realEstates_roomsNO"]) +
|
parseInt(extractedData["re_realEstates_roomsNO"]) +
|
||||||
parseInt(extractedData["re_realEstates_bedroomNO"]) || null,
|
parseInt(extractedData["re_realEstates_bedNO"]) || null,
|
||||||
numberOfFloors =
|
numberOfFloors =
|
||||||
parseInt(extractedData["re_realEstates_floorsNO"]) ||
|
parseInt(extractedData["re_realEstates_floorsNO"]) ||
|
||||||
this.getNumberOfFloorsFromFloorId(extractedData["re_floorNO_id"]),
|
this.getNumberOfFloorsFromFloorId(extractedData["re_floorNO_id"]),
|
||||||
@@ -352,7 +352,9 @@ class RentalCrawler {
|
|||||||
realEstatePropertiesFromInfrastructure.phoneConnection,
|
realEstatePropertiesFromInfrastructure.phoneConnection,
|
||||||
cableTV = realEstatePropertiesFromInfrastructure.cableTV,
|
cableTV = realEstatePropertiesFromInfrastructure.cableTV,
|
||||||
internet = realEstatePropertiesFromInfrastructure.internet,
|
internet = realEstatePropertiesFromInfrastructure.internet,
|
||||||
basementAttic = realEstatePropertiesFromSpaces.basementAttic,
|
basementAttic =
|
||||||
|
realEstatePropertiesFromSpaces.basementAttic ||
|
||||||
|
this.checkBasemAtticFromFloors(extractedData["re_floorNO_id"]),
|
||||||
storeRoom = realEstatePropertiesFromSpaces.storeRoom,
|
storeRoom = realEstatePropertiesFromSpaces.storeRoom,
|
||||||
videoSurveillance =
|
videoSurveillance =
|
||||||
realEstatePropertiesFromDescriptions.videoSurveillance ||
|
realEstatePropertiesFromDescriptions.videoSurveillance ||
|
||||||
@@ -397,9 +399,7 @@ class RentalCrawler {
|
|||||||
);
|
);
|
||||||
if (!publishedDateMoment.isValid()) {
|
if (!publishedDateMoment.isValid()) {
|
||||||
throw {
|
throw {
|
||||||
message: `Invalid published date : ${
|
message: `Invalid published date : ${extractedData["re_realEstates_inserted"]}`
|
||||||
extractedData["re_realEstates_inserted"]
|
|
||||||
}`
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,9 +410,7 @@ class RentalCrawler {
|
|||||||
);
|
);
|
||||||
if (!renewedDateMoment.isValid()) {
|
if (!renewedDateMoment.isValid()) {
|
||||||
throw {
|
throw {
|
||||||
message: `Invalid renewed date : ${
|
message: `Invalid renewed date : ${extractedData["re_realEstates_edited"]}`
|
||||||
extractedData["re_realEstates_edited"]
|
|
||||||
}`
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -782,8 +780,42 @@ class RentalCrawler {
|
|||||||
if (floorIds.length === 0) {
|
if (floorIds.length === 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
let noOfFloors = floorIds.length;
|
||||||
|
// Floors of 'suteren', 'podrum', 'tavan' and 'potkrovlje' are not counted
|
||||||
|
floorIds.forEach(id => {
|
||||||
|
if (
|
||||||
|
parseInt(id) === 1 ||
|
||||||
|
parseInt(id) === 2 ||
|
||||||
|
parseInt(id) === 12 ||
|
||||||
|
parseInt(id) === 14
|
||||||
|
) {
|
||||||
|
noOfFloors--;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return noOfFloors;
|
||||||
|
}
|
||||||
|
|
||||||
return floorIds.length;
|
checkBasemAtticFromFloors(floorsIdText) {
|
||||||
|
// floorIdText can be array of numbers, separated by comma or number
|
||||||
|
const floorIds = floorsIdText.split(",");
|
||||||
|
|
||||||
|
let check = false;
|
||||||
|
|
||||||
|
if (floorIds.length === 0) {
|
||||||
|
check = false;
|
||||||
|
}
|
||||||
|
//If floors 'suteren', 'podrum', 'tavan' and 'potkrovlje' exists then tag for basement-attic is true
|
||||||
|
floorIds.forEach(id => {
|
||||||
|
if (
|
||||||
|
parseInt(id) === 1 ||
|
||||||
|
parseInt(id) === 2 ||
|
||||||
|
parseInt(id) === 12 ||
|
||||||
|
parseInt(id) === 14
|
||||||
|
) {
|
||||||
|
check = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return check;
|
||||||
}
|
}
|
||||||
|
|
||||||
async sleep(ms) {
|
async sleep(ms) {
|
||||||
|
|||||||
@@ -23,16 +23,19 @@ const generateRealEstateLinks = realEstates => {
|
|||||||
const generateNotificationEmail = (
|
const generateNotificationEmail = (
|
||||||
realEstates,
|
realEstates,
|
||||||
searchRequestId,
|
searchRequestId,
|
||||||
|
noAllRealEstates,
|
||||||
dailyNotification = false
|
dailyNotification = false
|
||||||
) => {
|
) => {
|
||||||
const truncateList = realEstates.length > MAX_REAL_ESTATES_IN_EMAIL;
|
const truncateList = realEstates.length > MAX_REAL_ESTATES_IN_EMAIL;
|
||||||
|
|
||||||
const realEstatesToShow = truncateList
|
const realEstatesToShow = truncateList
|
||||||
? realEstates.slice(0, MAX_REAL_ESTATES_IN_EMAIL)
|
? realEstates.slice(0, MAX_REAL_ESTATES_IN_EMAIL)
|
||||||
: realEstates;
|
: realEstates;
|
||||||
|
|
||||||
const allRealEstatesLink = `${APP_URL}/nekretnine/${searchRequestId}`;
|
const allRealEstatesLink = `${APP_URL}/nekretnine/${searchRequestId}`;
|
||||||
|
|
||||||
const realEstateLinks = generateRealEstateLinks(realEstatesToShow);
|
const realEstateLinks = generateRealEstateLinks(realEstatesToShow);
|
||||||
const moreRealEstates = `<div>Kompletan spisak nekretnina možete pogledati na <a href="${allRealEstatesLink}">listi nekretnina</a><div>`;
|
const moreRealEstates = `<div>Kompletan spisak nekretnina (${noAllRealEstates}) možete pogledati na <a href="${allRealEstatesLink}">listi nekretnina</a><div>`;
|
||||||
const emailFooter = generateEmailFooter(searchRequestId);
|
const emailFooter = generateEmailFooter(searchRequestId);
|
||||||
const asapMessageBody =
|
const asapMessageBody =
|
||||||
realEstates.length > 1
|
realEstates.length > 1
|
||||||
@@ -70,6 +73,7 @@ const generateNewSearchRequestEmail = (searchRequest, matchingRealEstates) => {
|
|||||||
} = searchRequest;
|
} = searchRequest;
|
||||||
|
|
||||||
const realEstateLinks = generateRealEstateLinks(matchingRealEstates);
|
const realEstateLinks = generateRealEstateLinks(matchingRealEstates);
|
||||||
|
|
||||||
const instantRealEstatesText = `<br/>
|
const instantRealEstatesText = `<br/>
|
||||||
<div>
|
<div>
|
||||||
U međuvremenu pogledajte neke od nedavno objavljenih nekretnina koje odgovaraju Vašim uslovima pretrage :<br/>
|
U međuvremenu pogledajte neke od nedavno objavljenih nekretnina koje odgovaraju Vašim uslovima pretrage :<br/>
|
||||||
|
|||||||
@@ -154,3 +154,7 @@ h3 {
|
|||||||
margin-top: 2rem;
|
margin-top: 2rem;
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.estates-link {
|
||||||
|
color: rgba(0, 0, 0, 0.87);
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,7 +8,10 @@ const {
|
|||||||
generateNewSearchRequestEmail,
|
generateNewSearchRequestEmail,
|
||||||
generateEmailSubject
|
generateEmailSubject
|
||||||
} = require("../helpers/emailContentGenerator");
|
} = require("../helpers/emailContentGenerator");
|
||||||
const { findNotNotifiedMatches } = require("../helpers/db/searchRequestMatch");
|
const {
|
||||||
|
findNotNotifiedMatches,
|
||||||
|
findRealEstatesForSearchRequest
|
||||||
|
} = require("../helpers/db/searchRequestMatch");
|
||||||
const { sendEmail } = require("../services/emailService");
|
const { sendEmail } = require("../services/emailService");
|
||||||
|
|
||||||
const notifyForNewRealEstates = async newRealEstates => {
|
const notifyForNewRealEstates = async newRealEstates => {
|
||||||
@@ -39,10 +42,18 @@ const notifyMatches = async (matches, dailyNotification = false) => {
|
|||||||
const { email, subscribed } = searchRequest;
|
const { email, subscribed } = searchRequest;
|
||||||
if (notifyNow && subscribed) {
|
if (notifyNow && subscribed) {
|
||||||
const allMatchingRealEstates = matches[id].realEstates || [];
|
const allMatchingRealEstates = matches[id].realEstates || [];
|
||||||
|
|
||||||
|
//Variable allMatchingRealEstates are real estates that are "new" on the market
|
||||||
|
//the ones that we notify user in this moment, not all that already exists in db
|
||||||
|
//New variable allRealEstates are all real estates that exists in db for search req
|
||||||
|
const allRealEstates = await findRealEstatesForSearchRequest(id);
|
||||||
|
const noAllRealEstates = allRealEstates.length;
|
||||||
|
|
||||||
if (allMatchingRealEstates.length > 0) {
|
if (allMatchingRealEstates.length > 0) {
|
||||||
const emailContent = generateNotificationEmail(
|
const emailContent = generateNotificationEmail(
|
||||||
allMatchingRealEstates,
|
allMatchingRealEstates,
|
||||||
id,
|
id,
|
||||||
|
noAllRealEstates,
|
||||||
dailyNotification
|
dailyNotification
|
||||||
);
|
);
|
||||||
const emailSubject = generateEmailSubject(
|
const emailSubject = generateEmailSubject(
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
<div class="row center-align">
|
<div class="row center-align">
|
||||||
<ul class="collection with-header">
|
<ul class="collection with-header">
|
||||||
<% for(const realEstate of realEstates) { %>
|
<% for(const realEstate of realEstates) { %>
|
||||||
<li class="collection-item">
|
<li class="collection-item">
|
||||||
<div><%= realEstate.title %>
|
<div>
|
||||||
<a href="<%= realEstate.url %>" class="kivi-color secondary-content">
|
<a href="<%= realEstate.url %>" class="estates-link">
|
||||||
|
<%= realEstate.title %>
|
||||||
|
<div class="kivi-color secondary-content">
|
||||||
<i class="material-icons">send</i>
|
<i class="material-icons">send</i>
|
||||||
</a>
|
</div>
|
||||||
</div>
|
</a>
|
||||||
</li>
|
</div>
|
||||||
<% } %>
|
</li>
|
||||||
</ul>
|
<% } %>
|
||||||
</div>
|
</ul>
|
||||||
|
</div>
|
||||||
|
|||||||
@@ -13,5 +13,5 @@ if (urlToScrape) {
|
|||||||
})();
|
})();
|
||||||
} else {
|
} else {
|
||||||
console.log("No URL to scrape. Use like this : ");
|
console.log("No URL to scrape. Use like this : ");
|
||||||
console.log("npm run test-olx-scraper -- URL_TO_SCRAPE");
|
console.log("npm run test-rental-scraper -- URL_TO_SCRAPE");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user