manage accepted appointments

This commit is contained in:
2022-10-16 23:41:20 +02:00
parent b27cf3c806
commit c79c45db8a
6 changed files with 49 additions and 13 deletions
+5
View File
@@ -112,3 +112,8 @@ adb -s c3ba032e shell am start -n com.android.chrome/com.google.android.apps.chr
adb -s 2140c70c shell pm clear com.android.chrome adb -s 2140c70c shell pm clear com.android.chrome
adb -s 2140c70c shell am set-debug-app --persistent com.android.chrome adb -s 2140c70c shell am set-debug-app --persistent com.android.chrome
adb -s 2140c70c shell am start -n com.android.chrome/com.google.android.apps.chrome.Main adb -s 2140c70c shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
#asus zenfone 3
adb -s G7AZCY07H415CT3 shell pm clear com.android.chrome
adb -s G7AZCY07H415CT3 shell am set-debug-app --persistent com.android.chrome
adb -s G7AZCY07H415CT3 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
+5
View File
@@ -92,3 +92,8 @@ adb -s 192.168.1.24:42397 shell am start -n com.android.chrome/com.google.androi
adb -s 2140c70c shell pm clear com.android.chrome adb -s 2140c70c shell pm clear com.android.chrome
adb -s 2140c70c shell am set-debug-app --persistent com.android.chrome adb -s 2140c70c shell am set-debug-app --persistent com.android.chrome
adb -s 2140c70c shell am start -n com.android.chrome/com.google.android.apps.chrome.Main adb -s 2140c70c shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
#asus zenfone 3
adb -s G7AZCY07H415CT3 shell pm clear com.android.chrome
adb -s G7AZCY07H415CT3 shell am set-debug-app --persistent com.android.chrome
adb -s G7AZCY07H415CT3 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
+21 -5
View File
@@ -6,6 +6,7 @@ const alert = require('alert');
const mongoManager = new MongoManager(); const mongoManager = new MongoManager();
const SEVEN_DAYS_IN_S = 3600 * 24 * 7; const SEVEN_DAYS_IN_S = 3600 * 24 * 7;
const THIRTY_DAYS_IN_S = 3600 * 24 * 30;
let excelUtil = new ExcelUtil(); let excelUtil = new ExcelUtil();
let collectionName = formatDate(new Date()) let collectionName = formatDate(new Date())
@@ -24,8 +25,10 @@ async function filterAlreadyBookedContacts(contactList) {
// Connect to the device. // Connect to the device.
async function needToBook(contact, mongoManager) { async function needToBook(contact, mongoManager) {
let alreadyBooked = await mongoManager.getAllSuccessfulItemsForDay(collectionName) console.log("check contact with email " + contact.mail)
let blackListItems = await mongoManager.getAllBlackedListItems() let alreadyBooked = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
let blackListItems = await mongoManager.getAllBlackedListItems();
let alreadyAcceptedItems = await mongoManager.getAllAcceptedAppointments();
let needToBook = true; let needToBook = true;
await alreadyBooked.forEach((bookedItem) => { await alreadyBooked.forEach((bookedItem) => {
if (bookedItem.email === contact.mail) { if (bookedItem.email === contact.mail) {
@@ -36,12 +39,25 @@ async function needToBook(contact, mongoManager) {
if (needToBook) { if (needToBook) {
await blackListItems.forEach((blackListItem) => { await blackListItems.forEach((blackListItem) => {
if (blackListItem.mail === contact.mail) { if (blackListItem.mail === contact.mail) {
console.log("=====handle blacklist item====") console.log("=====handle blacklist item====");
console.log("update_at_s is " + blackListItem.update_at_in_s) console.log("update_at_s is " + blackListItem.update_at_in_s)
console.log("email is " + blackListItem.mail) console.log("black list email is " + blackListItem.mail)
needToBook = blackListItem.update_at_in_s + SEVEN_DAYS_IN_S <= (new Date()) / 1000; needToBook = blackListItem.update_at_in_s + SEVEN_DAYS_IN_S <= (new Date()) / 1000;
if (!needToBook) { if (!needToBook) {
console.log("skip") console.log("contact in blacklist -->skip");
}
}
})
}
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 + THIRTY_DAYS_IN_S <= (new Date()) / 1000;
if (!needToBook) {
console.log("already accepted appointment --> skip");
} }
} }
}) })
+11 -5
View File
@@ -5,11 +5,17 @@ const mongoManager = new MongoManager();
mongoManager.connect().then(r => { mongoManager.connect().then(r => {
let contact = new ContactPojo("0649614591", "1234567890", "PAN", "Lei", "panleicim@gmail.com") // let contact = new ContactPojo("0649614591", "1234567890", "PAN", "Lei", "panleicim@gmail.com")
let commandPage = new CommandorPage(contact, null, mongoManager) // let commandPage = new CommandorPage(contact, null, mongoManager)
commandPage.deleteFromBlackList().then(r => { // commandPage.deleteFromBlackList().then(r => {
console.log("saved to db") // console.log("saved to db")
// })
mongoManager.getAllAcceptedAppointments().then(acceptedList => {
acceptedList.forEach((item) => {
console.log(item.email)
console.log(item.accepted_at)
}) })
}
)
} }
) )
+1 -1
View File
@@ -7,7 +7,7 @@ const {
shell shell
} = require('electron') } = require('electron')
const GeoCaptchaSolver = require("./GeoCaptchaSolver"); const GeoCaptchaSolver = require("./GeoCaptchaSolver");
// const RDV_URL = "http://192.168.0.44:8000/test_appointment.html" // const RDV_URL = "http://192.168.0.41:8000/test_appointment.html"
const RDV_URL = "https://rendezvousparis.hermes.com/client/register"; const RDV_URL = "https://rendezvousparis.hermes.com/client/register";
BLANK_URL = "about:blank" BLANK_URL = "about:blank"
const ERROR_CAPTCHA_UNSOLVABLE = "ERROR_CAPTCHA_UNSOLVABLE"; const ERROR_CAPTCHA_UNSOLVABLE = "ERROR_CAPTCHA_UNSOLVABLE";
+4
View File
@@ -41,6 +41,10 @@ class MongoManager {
return await this.db.collection(day).find().toArray() return await this.db.collection(day).find().toArray()
} }
async getAllAcceptedAppointments() {
return await this.db.collection(ACCEPTED_APPOINTMENT_LIST).find().toArray()
}
async saveReserveToDb(reservePojo) { async saveReserveToDb(reservePojo) {
let collectionName = formatDate(new Date()) let collectionName = formatDate(new Date())
return await this.db.collection(collectionName).replaceOne({'_id': reservePojo.id,}, reservePojo, {upsert: true}) return await this.db.collection(collectionName).replaceOne({'_id': reservePojo.id,}, reservePojo, {upsert: true})