remove playwright
This commit is contained in:
+8
-68
@@ -6,6 +6,7 @@ const alert = require('alert');
|
||||
const schedule = require("node-schedule");
|
||||
const DeviceExcludeMode = require("./models/DeviceExcludeMode");
|
||||
const {Sender} = require("./queue/Sender");
|
||||
const {devices} = require("./android/adb");
|
||||
const mongoManager = new MongoManager();
|
||||
const SEVEN_DAYS_IN_S = 3600 * 24 * 7;
|
||||
// const NINETY_DAYS_IN_S = 3600 * 24 * 30 * 3;
|
||||
@@ -36,58 +37,10 @@ async function filterAlreadyBookedContacts(contactList) {
|
||||
return contactsToBook;
|
||||
}
|
||||
|
||||
async function filterAlreadyAcceptedContacts(contactList) {
|
||||
let alreadyBookedContacts = await mongoManager.getAllAcceptedAppointments();
|
||||
let contactsToBook = [];
|
||||
contactList.forEach((contact) => {
|
||||
let needToBook = true;
|
||||
alreadyBookedContacts.forEach((acceptedItem) => {
|
||||
if (acceptedItem.email === contact.mail) {
|
||||
console.log("=====handle already accepted item before booking====");
|
||||
console.log("accepted_at is " + acceptedItem.accepted_at);
|
||||
console.log("accepted email is " + acceptedItem.email);
|
||||
needToBook = acceptedItem.accepted_at + NINETY_DAYS_IN_S <= (new Date()) / 1000;
|
||||
if (!needToBook) {
|
||||
console.log("already accepted appointment --> skip");
|
||||
}
|
||||
}
|
||||
})
|
||||
if (needToBook) {
|
||||
contactsToBook.push(contact)
|
||||
}
|
||||
})
|
||||
return contactsToBook;
|
||||
}
|
||||
|
||||
async function filterBlacklistedContacts(contactList) {
|
||||
let blackListedContacts = await mongoManager.getAllBlackedListItems();
|
||||
let contactsToBook = [];
|
||||
contactList.forEach((contact) => {
|
||||
let needToBook = true;
|
||||
blackListedContacts.forEach((blackListItem) => {
|
||||
if (blackListItem.mail === contact.mail) {
|
||||
console.log("=====handle blacklist item before booking=====");
|
||||
console.log("update_at_s is " + blackListItem.update_at_in_s)
|
||||
console.log("black list email is " + blackListItem.mail)
|
||||
needToBook = blackListItem.update_at_in_s + SEVEN_DAYS_IN_S <= (new Date()) / 1000;
|
||||
if (!needToBook) {
|
||||
console.log("contact in blacklist -->skip");
|
||||
}
|
||||
}
|
||||
})
|
||||
if (needToBook) {
|
||||
contactsToBook.push(contact)
|
||||
}
|
||||
})
|
||||
return contactsToBook;
|
||||
}
|
||||
|
||||
async function needToBook(contact, mongoManager, alreadyBooked) {
|
||||
console.log("check contact with email " + contact.mail)
|
||||
// let alreadyBooked = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
|
||||
// let blackListItems = await mongoManager.getAllBlackedListItems();
|
||||
let blackListItems = [];
|
||||
// let alreadyAcceptedItems = await mongoManager.getAllAcceptedAppointments();
|
||||
let needToBook = true;
|
||||
await alreadyBooked.forEach((bookedItem) => {
|
||||
if (bookedItem.email === contact.mail) {
|
||||
@@ -108,25 +61,12 @@ async function needToBook(contact, mongoManager, alreadyBooked) {
|
||||
}
|
||||
})
|
||||
}
|
||||
// if (needToBook) {
|
||||
// await alreadyAcceptedItems.forEach((acceptedItem) => {
|
||||
// if (acceptedItem.email === contact.mail) {
|
||||
// console.log("=====handle already accepted item====");
|
||||
// console.log("accepted_at is " + acceptedItem.accepted_at);
|
||||
// console.log("accepted email is " + acceptedItem.email);
|
||||
// needToBook = acceptedItem.accepted_at + NINETY_DAYS_IN_S <= (new Date()) / 1000;
|
||||
// if (!needToBook) {
|
||||
// console.log("already accepted appointment --> skip");
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
return needToBook
|
||||
}
|
||||
|
||||
async function startBook(contactPojo, device, sender, selectedStore, audioAnalyse, alertBeep, port) {
|
||||
console.log(`model: ${device.model()}`);
|
||||
console.log(`serial: ${device.serial()}`);
|
||||
console.log(`model: ${device.model}`);
|
||||
console.log(`serial: ${device.serial}`);
|
||||
let alreadyBooked = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
|
||||
const d = new Date();
|
||||
let hour = d.getHours();
|
||||
@@ -198,16 +138,16 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
||||
console.log("startForwordingForDevice() called")
|
||||
const execSync = require('child_process').execSync;
|
||||
// get attributed port
|
||||
let attributedPort = device_port_info[device.serial()]
|
||||
let attributedPort = device_port_info[device.serial]
|
||||
if (attributedPort) {
|
||||
let cmd = 'adb -s ' + device.serial() + " forward tcp:" + attributedPort + " localabstract:chrome_devtools_remote";
|
||||
let cmd = 'adb -s ' + device.serial + " forward tcp:" + attributedPort + " localabstract:chrome_devtools_remote";
|
||||
console.log("cmd is " + cmd);
|
||||
const output = execSync(cmd, {encoding: 'utf-8'}); // the default is 'buffer'
|
||||
console.log('Output was:\n', output);
|
||||
} else {
|
||||
attributedPort = startPort;
|
||||
startPort++;
|
||||
let cmd = 'adb -s ' + device.serial() + " forward tcp:" + attributedPort + " localabstract:chrome_devtools_remote";
|
||||
let cmd = 'adb -s ' + device.serial + " forward tcp:" + attributedPort + " localabstract:chrome_devtools_remote";
|
||||
console.log("cmd is " + cmd);
|
||||
const output = execSync(cmd, {encoding: 'utf-8'}); // the default is 'buffer'
|
||||
console.log('Output was:\n', output);
|
||||
@@ -226,7 +166,7 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
||||
filterAlreadyBookedContacts(contactList).then((listWithoutBlackContact) => {
|
||||
console.log("will call filterAlreadyAcceptedContacts")
|
||||
console.log("number of contacts to book:" + listWithoutBlackContact.length)
|
||||
android.devices().then((devices) => {
|
||||
devices().then((devices) => {
|
||||
if (devices.length === 0) {
|
||||
alert("未找到连接的设备");
|
||||
return
|
||||
@@ -245,7 +185,7 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
||||
} else if (excludeMode === DeviceExcludeMode.ZERO) {
|
||||
device_to_excludes = []
|
||||
}
|
||||
filteredDeviceList = devices.filter(device => !device_to_excludes.includes(device.serial()))
|
||||
filteredDeviceList = devices.filter(device => !device_to_excludes.includes(device.serial))
|
||||
let segmentNumber = listWithoutBlackContact.length / filteredDeviceList.length;
|
||||
console.log("connected device number:" + filteredDeviceList.length)
|
||||
console.log("segmentNumber:" + segmentNumber)
|
||||
|
||||
Reference in New Issue
Block a user