Changed to send email only to some users.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
"use strict";
|
||||
const db = require("../../models/index");
|
||||
const sequelize = require("sequelize");
|
||||
const Op = sequelize.Op;
|
||||
const { CHECK_UP_DAYS } = require("../../config/appConfig");
|
||||
|
||||
const findRealEstatesForSearchRequest = async searchRequestId => {
|
||||
@@ -53,11 +55,18 @@ const findAllRequestsForCheckUp = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const excludedRequests = await db.SearchRequestMatch.findAll({
|
||||
const excludedMatches = await db.SearchRequestMatch.findAll({
|
||||
attributes: ["searchRequestId"],
|
||||
where: dateQuery
|
||||
where: dateQuery,
|
||||
order: [["searchRequestId", "ASC"]]
|
||||
});
|
||||
|
||||
const excludedRequestsAll = excludedMatches.map(match => {
|
||||
return match.dataValues.searchRequestId;
|
||||
});
|
||||
//Removing duplicate search request id-s for optimization
|
||||
const excludedRequests = [...new Set(excludedRequestsAll)];
|
||||
|
||||
const query = {
|
||||
subscribed: true,
|
||||
id: {
|
||||
|
||||
@@ -136,9 +136,6 @@ const generateCheckUpEmail = searchRequest => {
|
||||
? `<div><strong>Kvadratura okućnice: Od ${gardenSizeMin} do ${gardenSizeMax} m2</strong></div>`
|
||||
: ``;
|
||||
|
||||
const allRealEstatesLink = `${APP_URL}/nekretnine/${id}`;
|
||||
const moreRealEstates = `<div>Kompletan spisak do sada pronađenih nekretnina možete pogledati na <a href="${allRealEstatesLink}">listi nekretnina</a><div>`;
|
||||
|
||||
const emailFooter = generateEmailFooter(id);
|
||||
|
||||
return `<h3>Zdravo</h3>
|
||||
@@ -153,8 +150,6 @@ const generateCheckUpEmail = searchRequest => {
|
||||
<div><strong>Cijena:</strong> ${priceMin} do ${priceMax} KM</div>
|
||||
</div>
|
||||
<br/>
|
||||
${moreRealEstates}
|
||||
<br/>
|
||||
${emailFooter}`;
|
||||
};
|
||||
|
||||
|
||||
5
index.js
5
index.js
@@ -8,8 +8,7 @@ const forceSSL = require("./app/helpers/forceSSL");
|
||||
const {
|
||||
APP_PORT,
|
||||
CRAWLER_INTERVAL,
|
||||
STOP_CRAWLER,
|
||||
CHECK_UP_DAYS
|
||||
STOP_CRAWLER
|
||||
} = require("./app/config/appConfig");
|
||||
const routes = require("./app/routes");
|
||||
const { crawlAll } = require("./app/crawler/crawl");
|
||||
@@ -50,4 +49,4 @@ const crawl = () => {
|
||||
|
||||
setInterval(crawl, CRAWLER_INTERVAL * 1000);
|
||||
|
||||
setInterval(checkUpNotify, CHECK_UP_DAYS * 24 * 60 * 60 * 1000);
|
||||
setInterval(checkUpNotify, 1000 * 60 * 60 * 24);
|
||||
|
||||
Reference in New Issue
Block a user