Merge branch 'feature/check_exist_before_booking' into feature/gui
This commit is contained in:
+25
-9
@@ -7,22 +7,38 @@ const mongoManager = new MongoManager();
|
|||||||
|
|
||||||
let excelUtil = new ExcelUtil();
|
let excelUtil = new ExcelUtil();
|
||||||
let contactList = excelUtil.readContacts()
|
let contactList = excelUtil.readContacts()
|
||||||
mongoManager.connect().then(r =>
|
let collectionName = formatDate(new Date())
|
||||||
|
|
||||||
android.devices().then((devices) => {
|
async function filterAlreadyBookedContacts(contactList) {
|
||||||
let segmentNumber = contactList.length / devices.length;
|
let alreadyBookedContacts = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
|
||||||
for (let i = 0; i < devices.length; i++) {
|
let contactsToBook = [];
|
||||||
startWithList(contactList.slice(i * segmentNumber, segmentNumber * (i + 1)), devices[i]);
|
contactList.forEach((contact) => {
|
||||||
|
if (alreadyBookedContacts.find((bookedContact) => bookedContact.email === contact.mail) === undefined) {
|
||||||
|
contactsToBook.push(contact)
|
||||||
}
|
}
|
||||||
}))
|
})
|
||||||
|
return contactsToBook;
|
||||||
|
}
|
||||||
|
|
||||||
|
mongoManager.connect().then(r => {
|
||||||
|
filterAlreadyBookedContacts(contactList).then(listToBook => {
|
||||||
|
console.log(listToBook.length)
|
||||||
|
android.devices().then((devices) => {
|
||||||
|
let segmentNumber = listToBook.length / devices.length;
|
||||||
|
for (let i = 0; i < devices.length; i++) {
|
||||||
|
startWithList(contactList.slice(i * segmentNumber, segmentNumber * (i + 1)), devices[i]);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
// Connect to the device.
|
// Connect to the device.
|
||||||
|
|
||||||
async function needToBook(contact, mongoManager) {
|
async function needToBook(contact, mongoManager) {
|
||||||
let collectionName = formatDate(new Date())
|
let alreadyBooked = await mongoManager.getAllSuccessfulItemsForDay(collectionName)
|
||||||
let alreadBooked = await mongoManager.getAllSuccessfulItemsForDay(collectionName)
|
|
||||||
let toReturn = true;
|
let toReturn = true;
|
||||||
await alreadBooked.forEach((bookedItem) => {
|
await alreadyBooked.forEach((bookedItem) => {
|
||||||
if (bookedItem.email === contact.mail) {
|
if (bookedItem.email === contact.mail) {
|
||||||
toReturn = false;
|
toReturn = false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user