filter blacklisted items before booking
This commit is contained in:
+30
-17
@@ -13,6 +13,17 @@ let collectionName = formatDate(new Date())
|
|||||||
async function filterAlreadyBookedContacts(contactList) {
|
async function filterAlreadyBookedContacts(contactList) {
|
||||||
let alreadyBookedContacts = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
|
let alreadyBookedContacts = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
|
||||||
let contactsToBook = [];
|
let contactsToBook = [];
|
||||||
|
contactList.forEach((contact) => {
|
||||||
|
if (alreadyBookedContacts.find((bookedContact) => bookedContact.email === contact.mail) === undefined) {
|
||||||
|
contactsToBook.push(contact)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return contactsToBook;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function filterAlreadyAccepteddContacts(contactList) {
|
||||||
|
let alreadyBookedContacts = await mongoManager.getAllAcceptedAppointments();
|
||||||
|
let contactsToBook = [];
|
||||||
contactList.forEach((contact) => {
|
contactList.forEach((contact) => {
|
||||||
let needToBook = true;
|
let needToBook = true;
|
||||||
alreadyBookedContacts.forEach((acceptedItem) => {
|
alreadyBookedContacts.forEach((acceptedItem) => {
|
||||||
@@ -134,24 +145,26 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
mongoManager.connect().then(r => {
|
mongoManager.connect().then(r => {
|
||||||
filterBlacklistedContacts(contactList).then(listWithoutBlackContact => {
|
filterAlreadyAccepteddContacts(contactList).then(notAcceptedContacts => {
|
||||||
filterAlreadyBookedContacts(listWithoutBlackContact).then(listToBook => {
|
filterBlacklistedContacts(notAcceptedContacts).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:" + devices.length)
|
let segmentNumber = listToBook.length / devices.length;
|
||||||
console.log("segmentNumber:" + segmentNumber)
|
console.log("connected device number:" + devices.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