Compare commits

..

3 Commits

Author SHA1 Message Date
Naida Vatric
d23ddf849f Results title text made into link. 2020-01-07 01:06:22 +01:00
Naida Vatric
38bd0343f5 Merge branch 'results-link' of gitlab.com:saburly/marketalarm/web into no-all-results-email 2020-01-07 01:01:57 +01:00
Naida Vatric
fa4e0d64de Changed email content to show number of all matching real estates. 2020-01-06 23:59:56 +01:00
5 changed files with 51 additions and 108 deletions

View File

@@ -7,42 +7,7 @@ const PRICE_SLIDER_OPTIONS_SALE = {
step: 1000, step: 1000,
connect: true connect: true
}; };
const FLAT_PRICE_SLIDER_OPTIONS_SALE = {
start: [50000, 150000],
range: {
min: [0],
max: [800000]
},
step: 5000,
connect: true
};
const HOUSE_PRICE_SLIDER_OPTIONS_SALE = {
start: [50000, 150000],
range: {
min: [0],
max: [1500000]
},
step: 10000,
connect: true
};
const OFFICE_PRICE_SLIDER_OPTIONS_SALE = {
start: [15000, 50000],
range: {
min: [0],
max: [2000000]
},
step: 2000,
connect: true
};
const LAND_PRICE_SLIDER_OPTIONS_SALE = {
start: [40000, 80000],
range: {
min: [0],
max: [2000000]
},
step: 10000,
connect: true
};
const PRICE_SLIDER_OPTIONS_RENT = { const PRICE_SLIDER_OPTIONS_RENT = {
start: [300, 500], start: [300, 500],
range: { range: {
@@ -52,62 +17,18 @@ const PRICE_SLIDER_OPTIONS_RENT = {
step: 50, step: 50,
connect: true connect: true
}; };
const FLAT_PRICE_SLIDER_OPTIONS_RENT = {
start: [300, 600],
range: {
min: [0],
max: [4000]
},
step: 100,
connect: true
};
const HOUSE_PRICE_SLIDER_OPTIONS_RENT = {
start: [500, 1000],
range: {
min: [0],
max: [10000]
},
step: 100,
connect: true
};
const OFFICE_PRICE_SLIDER_OPTIONS_RENT = {
start: [200, 1000],
range: {
min: [0],
max: [20000]
},
step: 100,
connect: true
};
const LAND_PRICE_SLIDER_OPTIONS_RENT = {
start: [500, 1000],
range: {
min: [0],
max: [20000]
},
step: 100,
connect: true
};
//This will be used for Flats, Apartments, Houses //This will be used for Flats, Apartments, Houses
const HOME_SIZE_SLIDER_OPTIONS = { const HOME_SIZE_SLIDER_OPTIONS = {
start: [30, 75], start: [30, 75],
range: { range: {
min: [0], min: [0],
max: [500] max: [400]
}, },
step: 5, step: 5,
connect: true connect: true
}; };
const OFFICE_SIZE_SLIDER_OPTIONS = {
start: [30, 150],
range: {
min: [0],
max: [1200]
},
step: 10,
connect: true
};
const GARDEN_SIZE_SLIDER_OPTIONS = { const GARDEN_SIZE_SLIDER_OPTIONS = {
start: [100, 1000], start: [100, 1000],
range: { range: {
@@ -190,8 +111,8 @@ const AD_CATEGORY = {
hasNumberOfRoom: true, hasNumberOfRoom: true,
hasNumberOfFloors: false, hasNumberOfFloors: false,
hasFloorProp: true, hasFloorProp: true,
priceSliderOptionsSale: FLAT_PRICE_SLIDER_OPTIONS_SALE, priceSliderOptionsSale: PRICE_SLIDER_OPTIONS_SALE,
priceSliderOptionsRent: FLAT_PRICE_SLIDER_OPTIONS_RENT, priceSliderOptionsRent: PRICE_SLIDER_OPTIONS_RENT,
sizeSliderOptions: HOME_SIZE_SLIDER_OPTIONS sizeSliderOptions: HOME_SIZE_SLIDER_OPTIONS
}, },
HOUSE: { HOUSE: {
@@ -205,8 +126,8 @@ const AD_CATEGORY = {
hasNumberOfRoom: true, hasNumberOfRoom: true,
hasNumberOfFloors: true, hasNumberOfFloors: true,
hasFloorProp: false, hasFloorProp: false,
priceSliderOptionsSale: HOUSE_PRICE_SLIDER_OPTIONS_SALE, priceSliderOptionsSale: PRICE_SLIDER_OPTIONS_SALE,
priceSliderOptionsRent: HOUSE_PRICE_SLIDER_OPTIONS_RENT, priceSliderOptionsRent: PRICE_SLIDER_OPTIONS_RENT,
sizeSliderOptions: HOME_SIZE_SLIDER_OPTIONS, sizeSliderOptions: HOME_SIZE_SLIDER_OPTIONS,
gardenSizeSliderOptions: GARDEN_SIZE_SLIDER_OPTIONS gardenSizeSliderOptions: GARDEN_SIZE_SLIDER_OPTIONS
}, },
@@ -221,9 +142,9 @@ const AD_CATEGORY = {
hasNumberOfRoom: true, hasNumberOfRoom: true,
hasNumberOfFloors: false, hasNumberOfFloors: false,
hasFloorProp: true, hasFloorProp: true,
priceSliderOptionsSale: OFFICE_PRICE_SLIDER_OPTIONS_SALE, priceSliderOptionsSale: PRICE_SLIDER_OPTIONS_SALE,
priceSliderOptionsRent: OFFICE_PRICE_SLIDER_OPTIONS_RENT, priceSliderOptionsRent: PRICE_SLIDER_OPTIONS_RENT,
sizeSliderOptions: OFFICE_SIZE_SLIDER_OPTIONS sizeSliderOptions: HOME_SIZE_SLIDER_OPTIONS
}, },
LAND: { LAND: {
id: "LAND", id: "LAND",
@@ -236,8 +157,8 @@ const AD_CATEGORY = {
hasNumberOfRoom: false, hasNumberOfRoom: false,
hasNumberOfFloors: false, hasNumberOfFloors: false,
hasFloorProp: false, hasFloorProp: false,
priceSliderOptionsSale: LAND_PRICE_SLIDER_OPTIONS_SALE, priceSliderOptionsSale: PRICE_SLIDER_OPTIONS_SALE,
priceSliderOptionsRent: LAND_PRICE_SLIDER_OPTIONS_RENT, priceSliderOptionsRent: PRICE_SLIDER_OPTIONS_RENT,
sizeSliderOptions: LAND_SIZE_SLIDER_OPTIONS sizeSliderOptions: LAND_SIZE_SLIDER_OPTIONS
}, },
APARTMENT: { APARTMENT: {
@@ -251,8 +172,8 @@ const AD_CATEGORY = {
hasNumberOfRoom: true, hasNumberOfRoom: true,
hasNumberOfFloors: false, hasNumberOfFloors: false,
hasFloorProp: true, hasFloorProp: true,
priceSliderOptionsSale: FLAT_PRICE_SLIDER_OPTIONS_SALE, priceSliderOptionsSale: PRICE_SLIDER_OPTIONS_SALE,
priceSliderOptionsRent: FLAT_PRICE_SLIDER_OPTIONS_RENT, priceSliderOptionsRent: PRICE_SLIDER_OPTIONS_RENT,
sizeSliderOptions: HOME_SIZE_SLIDER_OPTIONS sizeSliderOptions: HOME_SIZE_SLIDER_OPTIONS
}, },
GARAGE: { GARAGE: {
@@ -281,8 +202,8 @@ const AD_CATEGORY = {
hasNumberOfRoom: true, hasNumberOfRoom: true,
hasNumberOfFloors: true, hasNumberOfFloors: true,
hasFloorProp: false, hasFloorProp: false,
priceSliderOptionsSale: HOUSE_PRICE_SLIDER_OPTIONS_SALE, priceSliderOptionsSale: PRICE_SLIDER_OPTIONS_SALE,
priceSliderOptionsRent: HOUSE_PRICE_SLIDER_OPTIONS_RENT, priceSliderOptionsRent: PRICE_SLIDER_OPTIONS_RENT,
sizeSliderOptions: HOME_SIZE_SLIDER_OPTIONS, sizeSliderOptions: HOME_SIZE_SLIDER_OPTIONS,
gardenSizeSliderOptions: GARDEN_SIZE_SLIDER_OPTIONS gardenSizeSliderOptions: GARDEN_SIZE_SLIDER_OPTIONS
} }

View File

@@ -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/>

View File

@@ -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);
}

View File

@@ -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(

View File

@@ -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>