filter blacklisted items before booking
This commit is contained in:
+15
-1
@@ -21,6 +21,17 @@ async function filterAlreadyBookedContacts(contactList) {
|
||||
return contactsToBook;
|
||||
}
|
||||
|
||||
async function filterBlacklistedContacts(contactList) {
|
||||
let blackListedContacts = await mongoManager.getAllBlackedListItems(collectionName);
|
||||
let contactsToBook = [];
|
||||
contactList.forEach((contact) => {
|
||||
if (blackListedContacts.find((bookedContact) => bookedContact.email === contact.mail) === undefined) {
|
||||
contactsToBook.push(contact)
|
||||
}
|
||||
})
|
||||
return contactsToBook;
|
||||
}
|
||||
|
||||
async function needToBook(contact, mongoManager) {
|
||||
console.log("check contact with email " + contact.mail)
|
||||
let alreadyBooked = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
|
||||
@@ -99,7 +110,8 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
||||
return
|
||||
}
|
||||
mongoManager.connect().then(r => {
|
||||
filterAlreadyBookedContacts(contactList).then(listToBook => {
|
||||
filterBlacklistedContacts(contactList).then(listWithoutBlackContact => {
|
||||
filterAlreadyBookedContacts(listWithoutBlackContact).then(listToBook => {
|
||||
console.log("number of contacts to book:" + listToBook.length)
|
||||
android.devices().then((devices) => {
|
||||
if (devices.length === 0) {
|
||||
@@ -117,5 +129,7 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
module.exports = startBookWithNumbers
|
||||
Reference in New Issue
Block a user