add check_results to scheduler
This commit is contained in:
+8
-4
@@ -18,6 +18,7 @@ PENDING_SENTENCE = "Ce soir, entre 20:00 et 20:30, vous obtiendrez une réponse
|
|||||||
PENDING_SENTENCE_EN = "This evening between 20:00 and 20:30 you will receive a response by email."
|
PENDING_SENTENCE_EN = "This evening between 20:00 and 20:30 you will receive a response by email."
|
||||||
BLANK_URL = "about:blank"
|
BLANK_URL = "about:blank"
|
||||||
|
|
||||||
|
|
||||||
class TlsPlaywright(threading.local):
|
class TlsPlaywright(threading.local):
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.playwright = sync_playwright().start()
|
self.playwright = sync_playwright().start()
|
||||||
@@ -103,8 +104,7 @@ class ResultChecker:
|
|||||||
collection.document(reserve_pojo.id).update({u'accepted': status.name})
|
collection.document(reserve_pojo.id).update({u'accepted': status.name})
|
||||||
|
|
||||||
|
|
||||||
# need to start at 21h00
|
def check_results():
|
||||||
if __name__ == '__main__':
|
|
||||||
# get the list
|
# get the list
|
||||||
params.oracle_log_sender.send_log(msg="开始检查约会结果", subject=LOG_SUBJECT_EVENT, type=TYPE_EVENT_CHECK_RESULTS)
|
params.oracle_log_sender.send_log(msg="开始检查约会结果", subject=LOG_SUBJECT_EVENT, type=TYPE_EVENT_CHECK_RESULTS)
|
||||||
db_manager = params.firebase_store_manager
|
db_manager = params.firebase_store_manager
|
||||||
@@ -116,8 +116,7 @@ if __name__ == '__main__':
|
|||||||
reserve_pojo = ReserveResultPojo.from_firestore_dict(appointment.to_dict())
|
reserve_pojo = ReserveResultPojo.from_firestore_dict(appointment.to_dict())
|
||||||
result_list.append(reserve_pojo)
|
result_list.append(reserve_pojo)
|
||||||
|
|
||||||
|
with ThreadPoolExecutor(max_workers=15) as executor:
|
||||||
with ThreadPoolExecutor(max_workers=25) as executor:
|
|
||||||
for reserve in result_list:
|
for reserve in result_list:
|
||||||
count = count + 1
|
count = count + 1
|
||||||
if reserve.accepted is None or ResultEnum.ACCEPTED.value == reserve.accepted:
|
if reserve.accepted is None or ResultEnum.ACCEPTED.value == reserve.accepted:
|
||||||
@@ -126,3 +125,8 @@ if __name__ == '__main__':
|
|||||||
print("status is " + reserve.accepted)
|
print("status is " + reserve.accepted)
|
||||||
|
|
||||||
print(count)
|
print(count)
|
||||||
|
|
||||||
|
|
||||||
|
# need to start at 21h00
|
||||||
|
if __name__ == '__main__':
|
||||||
|
check_results()
|
||||||
|
|||||||
+20
-3
@@ -1,6 +1,7 @@
|
|||||||
from apscheduler.executors.pool import ThreadPoolExecutor, ProcessPoolExecutor
|
from apscheduler.executors.pool import ThreadPoolExecutor, ProcessPoolExecutor
|
||||||
from apscheduler.schedulers.blocking import BlockingScheduler
|
from apscheduler.schedulers.blocking import BlockingScheduler
|
||||||
|
|
||||||
|
from check_results import check_results
|
||||||
from main import start_book
|
from main import start_book
|
||||||
from wait_for_sms import start_waiting_sms
|
from wait_for_sms import start_waiting_sms
|
||||||
|
|
||||||
@@ -9,6 +10,10 @@ def waiting_for_sms_job():
|
|||||||
start_waiting_sms(1, 32)
|
start_waiting_sms(1, 32)
|
||||||
|
|
||||||
|
|
||||||
|
def check_results_job():
|
||||||
|
check_results()
|
||||||
|
|
||||||
|
|
||||||
def start_book_appointment():
|
def start_book_appointment():
|
||||||
start_book(1, 31)
|
start_book(1, 31)
|
||||||
|
|
||||||
@@ -18,8 +23,19 @@ def start_waiting_sms_job(sched):
|
|||||||
# minute='30',
|
# minute='30',
|
||||||
# misfire_grace_time=10,
|
# misfire_grace_time=10,
|
||||||
# second='0', timezone='Europe/Paris', max_instances=1)
|
# second='0', timezone='Europe/Paris', max_instances=1)
|
||||||
sched.add_job(waiting_for_sms_job, 'cron', day_of_week='mon-sat', hour='20',
|
sched.add_job(waiting_for_sms_job, 'cron', day_of_week='mon-sat', hour='21',
|
||||||
minute='40',
|
minute='15',
|
||||||
|
misfire_grace_time=10,
|
||||||
|
second='0', timezone='Europe/Paris', max_instances=1)
|
||||||
|
|
||||||
|
|
||||||
|
def start_check_results_job(sched):
|
||||||
|
# sched.add_job(start_book_appointment, 'cron', day_of_week='mon-sat', hour='10',
|
||||||
|
# minute='30',
|
||||||
|
# misfire_grace_time=10,
|
||||||
|
# second='0', timezone='Europe/Paris', max_instances=1)
|
||||||
|
sched.add_job(check_results(), 'cron', day_of_week='mon-sat', hour='21',
|
||||||
|
minute='15',
|
||||||
misfire_grace_time=10,
|
misfire_grace_time=10,
|
||||||
second='0', timezone='Europe/Paris', max_instances=1)
|
second='0', timezone='Europe/Paris', max_instances=1)
|
||||||
|
|
||||||
@@ -30,7 +46,8 @@ def config_and_start_jobs():
|
|||||||
'processpool': ProcessPoolExecutor(12)
|
'processpool': ProcessPoolExecutor(12)
|
||||||
}
|
}
|
||||||
sched = BlockingScheduler(executors=executors)
|
sched = BlockingScheduler(executors=executors)
|
||||||
start_waiting_sms_job(sched)
|
# start_waiting_sms_job(sched)
|
||||||
|
start_check_results_job(sched)
|
||||||
sched.print_jobs()
|
sched.print_jobs()
|
||||||
sched.start()
|
sched.start()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user