do not duplicate contacts

This commit is contained in:
Lei PAN
2023-04-11 16:23:44 +02:00
parent 46af10ceac
commit db21a69926
3 changed files with 56 additions and 41 deletions
+4 -2
View File
@@ -10,7 +10,8 @@ const SEVEN_DAYS_IN_S = 3600 * 24 * 7;
const NINETY_DAYS_IN_S = 3600 * 24 * 30 * 3;
let excelUtil = new ExcelUtil();
let collectionName = formatDate(new Date())
device_to_excludes = ["47e7e36b", "e30eb015"]
// device_to_excludes = ["47e7e36b", "e30eb015"]
device_to_excludes = ["47e7e36b"]
async function filterAlreadyBookedContacts(contactList) {
let alreadyBookedContacts = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
@@ -123,7 +124,8 @@ async function startBook(contactPojo, device, selectedStore, audioAnalyse, alert
}
async function startWithList(contacts, device, selectedStore, audioAnalyse, alertBeep) {
let duplicatedList = [].concat(contacts).concat(contacts).concat(contacts)
// let duplicatedList = [].concat(contacts).concat(contacts).concat(contacts)
let duplicatedList = [].concat(contacts)
await duplicatedList.reduce(async (promise, contactPojo) => {
// This line will wait for the last async function to finish.
// The first iteration uses an already resolved Promise