optimize the check_results.py
This commit is contained in:
+13
-8
@@ -14,6 +14,7 @@ from pojo.ReserveResultPojo import ReserveResultPojo, PublishType
|
||||
SORRY_SENTENCE = "nous sommes sincèrement désolés de n'avoir pu vous satisfaire cette fois-ci"
|
||||
NOT_AVAILABLE_CONTENT = "For more than 130 years, our House has offered its full expertise to satisfy"
|
||||
PENDING_SENTENCE = "Ce soir, entre 20:00 et 20:30, vous obtiendrez une réponse par e-mail."
|
||||
PENDING_SENTENCE_EN = "This evening between 20:00 and 20:30 you will receive a response by email."
|
||||
|
||||
|
||||
class ResultEnum(Enum):
|
||||
@@ -93,6 +94,9 @@ class ResultChecker:
|
||||
elif PENDING_SENTENCE in content:
|
||||
print("status is PENDING")
|
||||
status = ResultEnum.PENDING
|
||||
elif PENDING_SENTENCE_EN in content:
|
||||
print("status is PENDING")
|
||||
status = ResultEnum.PENDING
|
||||
elif NOT_AVAILABLE_CONTENT in content:
|
||||
print("status is REFUSED")
|
||||
status = ResultEnum.REFUSED
|
||||
@@ -107,22 +111,23 @@ if __name__ == '__main__':
|
||||
# get the list
|
||||
params.oracle_log_sender.send_log(msg="开始检查约会结果", subject=LOG_SUBJECT_EVENT, type=TYPE_EVENT_CHECK_RESULTS)
|
||||
db_manager = params.firebase_store_manager
|
||||
collection = db_manager.get_all_successful_items_for_day("2022-05-14", "landd")
|
||||
# collection = db_manager.get_all_successful_items_for_day("2022-05-14", "landd")
|
||||
collection = db_manager.get_all_successful_items()
|
||||
count = 0
|
||||
result_pojo = ReserveResultPojo(type=PublishType.SUCCESS, phone="0649614591", email="panleicim@gmail.com",
|
||||
message="SUCCESS", firstName="Lei", lastName="PAN", url='https://api.ipify.org')
|
||||
# result_pojo = ReserveResultPojo(type=PublishType.SUCCESS, phone="0649614591", email="panleicim@gmail.com",
|
||||
# message="SUCCESS", firstName="Lei", lastName="PAN", url='https://api.ipify.org')
|
||||
result_list = []
|
||||
# for appointment in collection.stream():
|
||||
# reserve_pojo = ReserveResultPojo.from_firestore_dict(appointment.to_dict())
|
||||
# result_list.append(reserve_pojo)
|
||||
result_list.append(result_pojo)
|
||||
for appointment in collection.stream():
|
||||
reserve_pojo = ReserveResultPojo.from_firestore_dict(appointment.to_dict())
|
||||
result_list.append(reserve_pojo)
|
||||
# result_list.append(result_pojo)
|
||||
# for result in result_list:
|
||||
# if result.accepted is None or ResultEnum.PENDING.value == result.accepted:
|
||||
# ResultChecker().run(result, collection)
|
||||
# else:
|
||||
# print("status is " + result.accepted)
|
||||
|
||||
with ThreadPoolExecutor(max_workers=1) as executor:
|
||||
with ThreadPoolExecutor(max_workers=5) as executor:
|
||||
for reserve in result_list:
|
||||
count = count + 1
|
||||
if reserve.accepted is None or ResultEnum.PENDING.value == reserve.accepted:
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ class DataManager:
|
||||
return sim_info_collection
|
||||
|
||||
def get_all_successful_items(self):
|
||||
return self.get_all_successful_items_for_day(str(datetime.date.today()))
|
||||
return self.get_all_successful_items_for_day(str(datetime.date.today()), None)
|
||||
|
||||
def get_all_successful_items_for_day(self, day, source_from: Union[str, None]):
|
||||
doc_ref = self._db.collection(day)
|
||||
|
||||
Reference in New Issue
Block a user