test check blacklist

This commit is contained in:
2022-10-13 16:41:48 +02:00
parent de2fa6f518
commit becea669ac
4 changed files with 26 additions and 2 deletions
+11 -1
View File
@@ -5,7 +5,7 @@ const {MongoManager, formatDate} = require("./workers/mongo_manager");
const alert = require('alert');
const mongoManager = new MongoManager();
const SEVEN_DAYS_IN_S = 3600 * 24 * 7;
let excelUtil = new ExcelUtil();
let collectionName = formatDate(new Date())
@@ -25,6 +25,7 @@ async function filterAlreadyBookedContacts(contactList) {
async function needToBook(contact, mongoManager) {
let alreadyBooked = await mongoManager.getAllSuccessfulItemsForDay(collectionName)
let blackListItems = await mongoManager.getAllBlackedListItems()
let toReturn = true;
await alreadyBooked.forEach((bookedItem) => {
if (bookedItem.email === contact.mail) {
@@ -32,6 +33,15 @@ async function needToBook(contact, mongoManager) {
}
}
)
await blackListItems.forEach((blackListItem) => {
console.log("=====handle blacklist item====")
console.log("update_at_s is " + blackListItem.update_at_in_s)
console.log("email is " + blackListItem.mail)
toReturn = blackListItem.update_at_in_s <= (new Date()) + SEVEN_DAYS_IN_S;
if (!toReturn) {
console.log("skip")
}
})
return toReturn
}