diff --git a/appointment.js b/appointment.js index 854b804..e7d68c1 100644 --- a/appointment.js +++ b/appointment.js @@ -6,7 +6,6 @@ const {MongoManager, formatDate} = require("./src/workers/mongo_manager"); const mongoManager = new MongoManager(); let excelUtil = new ExcelUtil(); -let contactList = excelUtil.readContacts() let collectionName = formatDate(new Date()) async function filterAlreadyBookedContacts(contactList) { @@ -20,18 +19,6 @@ async function filterAlreadyBookedContacts(contactList) { 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(listToBook.slice(i * segmentNumber, segmentNumber * (i + 1)), devices[i]); - } - }) - }) - } -) // Connect to the device. @@ -59,7 +46,6 @@ async function startBook(contactPojo, device) { } } - async function startWithList(contacts, device) { await contacts.reduce(async (promise, contactPojo) => { // This line will wait for the last async function to finish. @@ -69,4 +55,22 @@ async function startWithList(contacts, device) { const contents = await startBook(contactPojo, device); console.log(contents); }, Promise.resolve()); -} \ No newline at end of file +} + +async function startBookWithNumbers(startNumber, endNumber) { + let contactList = excelUtil.readContacts(); + 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(listToBook.slice(i * segmentNumber, segmentNumber * (i + 1)), devices[i]); + } + }) + }) + } + ) +} + +module.exports = startBookWithNumbers \ No newline at end of file diff --git a/index.html b/index.html index bab93d5..4e5e039 100644 --- a/index.html +++ b/index.html @@ -5,20 +5,31 @@