filter blacklisted items before booking
This commit is contained in:
+29
-15
@@ -21,6 +21,17 @@ async function filterAlreadyBookedContacts(contactList) {
|
|||||||
return contactsToBook;
|
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) {
|
async function needToBook(contact, mongoManager) {
|
||||||
console.log("check contact with email " + contact.mail)
|
console.log("check contact with email " + contact.mail)
|
||||||
let alreadyBooked = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
|
let alreadyBooked = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
|
||||||
@@ -99,21 +110,24 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
mongoManager.connect().then(r => {
|
mongoManager.connect().then(r => {
|
||||||
filterAlreadyBookedContacts(contactList).then(listToBook => {
|
filterBlacklistedContacts(contactList).then(listWithoutBlackContact => {
|
||||||
console.log("number of contacts to book:" + listToBook.length)
|
filterAlreadyBookedContacts(listWithoutBlackContact).then(listToBook => {
|
||||||
android.devices().then((devices) => {
|
console.log("number of contacts to book:" + listToBook.length)
|
||||||
if (devices.length === 0) {
|
android.devices().then((devices) => {
|
||||||
alert("未找到连接的设备");
|
if (devices.length === 0) {
|
||||||
return
|
alert("未找到连接的设备");
|
||||||
}
|
return
|
||||||
let segmentNumber = listToBook.length / devices.length;
|
}
|
||||||
console.log("connected device number:" + listToBook.length)
|
let segmentNumber = listToBook.length / devices.length;
|
||||||
console.log("segmentNumber:" + segmentNumber)
|
console.log("connected device number:" + listToBook.length)
|
||||||
for (let i = 0; i < devices.length; i++) {
|
console.log("segmentNumber:" + segmentNumber)
|
||||||
startWithList(listToBook.slice(i * segmentNumber, segmentNumber * (i + 1)), devices[i], selectedStore, audioAnalyse, alertBeep);
|
for (let i = 0; i < devices.length; i++) {
|
||||||
}
|
startWithList(listToBook.slice(i * segmentNumber, segmentNumber * (i + 1)), devices[i], selectedStore, audioAnalyse, alertBeep);
|
||||||
})
|
}
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user