Changed logic for checkup.For testing.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"use strict";
|
||||
const db = require("../../models/index");
|
||||
const { CHECK_UP_DAYS } = require("../../config/appConfig");
|
||||
|
||||
const findRealEstatesForSearchRequest = async searchRequestId => {
|
||||
const query = {
|
||||
@@ -41,8 +42,27 @@ const findNotNotifiedMatches = async () => {
|
||||
return matchingRecords;
|
||||
};
|
||||
const findAllRequestsForCheckUp = async () => {
|
||||
//First we find IDs of search request that don't need to be emailed for check up - to EXCLUDE
|
||||
//The ones that received notification for real estate CHECK_UP_DAYS days from now
|
||||
const date = new Date();
|
||||
const checkUpDate = date.getDate() - CHECK_UP_DAYS;
|
||||
date.setDate(checkUpDate);
|
||||
const dateQuery = {
|
||||
createdAt: {
|
||||
[Op.gte]: date
|
||||
}
|
||||
};
|
||||
|
||||
const excludedRequests = await db.SearchRequestMatch.findAll({
|
||||
attributes: ["searchRequestId"],
|
||||
where: dateQuery
|
||||
});
|
||||
|
||||
const query = {
|
||||
subscribed: true
|
||||
subscribed: true,
|
||||
id: {
|
||||
[Op.notIn]: excludedRequests
|
||||
}
|
||||
};
|
||||
const allRequestsForCheckUp = await db.SearchRequest.findAll({
|
||||
where: query
|
||||
|
||||
Reference in New Issue
Block a user