optimzation
This commit is contained in:
@@ -10,8 +10,9 @@ class ReserveResultPojo {
|
||||
this.lastName = lastName;
|
||||
this.storeType = storeType;
|
||||
this.url = url;
|
||||
this.mail = mail;
|
||||
this.email = mail;
|
||||
this.type = type;
|
||||
this.source_from = ""
|
||||
}
|
||||
|
||||
to_mongo_dict() {
|
||||
@@ -20,10 +21,11 @@ class ReserveResultPojo {
|
||||
phone: this.phoneNumber,
|
||||
firstName: this.firstName,
|
||||
lastName: this.lastName,
|
||||
email: this.mail,
|
||||
email: this.email,
|
||||
passport: this.passportNumber,
|
||||
url: this.url,
|
||||
store_type: this.storeType
|
||||
store_type: this.storeType,
|
||||
source_from: this.source_from
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
const {_android: android} = require("playwright");
|
||||
const {_android: android, devices} = require("playwright");
|
||||
|
||||
const SolveCaptcha = require("./SolveCaptcha");
|
||||
const ReserveResultPojo = require("../models/ReserveResultPojo");
|
||||
const PublishType = require("../models/PublishType");
|
||||
|
||||
const RDV_URL = "http://192.168.0.44:8000/test_appointment.html"
|
||||
// const RDV_URL = "https://rendezvousparis.hermes.com/client/register";
|
||||
// const RDV_URL = "http://192.168.0.44:8000/test_appointment.html"
|
||||
const RDV_URL = "https://rendezvousparis.hermes.com/client/register";
|
||||
|
||||
const COUNTRY_ID = "#phone_country"
|
||||
const PHONE_NUMBER = "#phone_number"
|
||||
@@ -59,6 +59,7 @@ class CommandorPage {
|
||||
console.log("loadPage() called");
|
||||
await this.device.shell('am force-stop com.android.chrome');
|
||||
const context = await this.device.launchBrowser({command: '--incognito'});
|
||||
// await context.clearCookies()
|
||||
|
||||
// Use BrowserContext as usual.
|
||||
this.page = await context.newPage();
|
||||
@@ -144,6 +145,7 @@ class CommandorPage {
|
||||
|
||||
|
||||
async fillFields(page) {
|
||||
console.log("fillFields called")
|
||||
if (!this.isFillingFields) {
|
||||
this.isFillingFields = true;
|
||||
await this.chooseStore(page);
|
||||
@@ -155,7 +157,7 @@ class CommandorPage {
|
||||
await this.inputPassportId(page)
|
||||
await this.checkCGU(page)
|
||||
await this.resolveCaptcha(page)
|
||||
await delay(100 * 1000)
|
||||
await delay(10 * 1000)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +178,7 @@ class CommandorPage {
|
||||
|
||||
async resolveCaptcha(page) {
|
||||
if (RDV_URL.includes("192")) {
|
||||
this.isTerminated = true;
|
||||
await this.push_message_to_queue(PublishType.SUCCESS)
|
||||
return
|
||||
}
|
||||
this.captchaSolver = new SolveCaptcha(page);
|
||||
@@ -208,13 +210,17 @@ class CommandorPage {
|
||||
}
|
||||
|
||||
async push_message_to_queue(publishType) {
|
||||
let url = this.page.url()
|
||||
let url = this.page.url();
|
||||
let splitedUrl = url.split("/");
|
||||
let id = splitedUrl[splitedUrl.length - 1];
|
||||
if (url === "https://rendezvousparis.hermes.com/client/welcome") {
|
||||
return
|
||||
}
|
||||
// save to mongoDb
|
||||
let reserve = ReserveResultPojo.create_from_contact(this.contact, this.page.url(), 1, publishType)
|
||||
await this.mongoManager.saveReserveToDb(reserve)
|
||||
let reserve = ReserveResultPojo.create_from_contact(this.contact, id, this.page.url(), 1, publishType);
|
||||
reserve.source_from = this.device.model();
|
||||
await this.mongoManager.saveReserveToDb(reserve.to_mongo_dict())
|
||||
this.isTerminated = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ const DESTINATION_EMAIL_LIST = "DESTINATION_EMAIL_LIST"
|
||||
|
||||
const {MongoClient} = require('mongodb');
|
||||
const ReserveResultPojo = require("../models/ReserveResultPojo");
|
||||
const ContactPojo = require("../models/ContactPojo");
|
||||
require("../models/ContactPojo");
|
||||
|
||||
function formatDate(date) {
|
||||
let d = new Date(date),
|
||||
@@ -37,7 +37,7 @@ class MongoManager {
|
||||
this.db = this.client.db("appointment")
|
||||
}
|
||||
|
||||
async getAllSuccessfulItemsForDay(day) {
|
||||
async getAllSuccessfulItemsForDay(day) {
|
||||
return await this.db.collection(day).find().toArray()
|
||||
}
|
||||
|
||||
@@ -48,4 +48,4 @@ class MongoManager {
|
||||
}
|
||||
|
||||
|
||||
module.exports = MongoManager
|
||||
module.exports = {MongoManager, formatDate}
|
||||
Reference in New Issue
Block a user