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"
|
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"
|
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 = "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):
|
class ResultEnum(Enum):
|
||||||
@@ -93,6 +94,9 @@ class ResultChecker:
|
|||||||
elif PENDING_SENTENCE in content:
|
elif PENDING_SENTENCE in content:
|
||||||
print("status is PENDING")
|
print("status is PENDING")
|
||||||
status = ResultEnum.PENDING
|
status = ResultEnum.PENDING
|
||||||
|
elif PENDING_SENTENCE_EN in content:
|
||||||
|
print("status is PENDING")
|
||||||
|
status = ResultEnum.PENDING
|
||||||
elif NOT_AVAILABLE_CONTENT in content:
|
elif NOT_AVAILABLE_CONTENT in content:
|
||||||
print("status is REFUSED")
|
print("status is REFUSED")
|
||||||
status = ResultEnum.REFUSED
|
status = ResultEnum.REFUSED
|
||||||
@@ -107,22 +111,23 @@ 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
|
||||||
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
|
count = 0
|
||||||
result_pojo = ReserveResultPojo(type=PublishType.SUCCESS, phone="0649614591", email="panleicim@gmail.com",
|
# result_pojo = ReserveResultPojo(type=PublishType.SUCCESS, phone="0649614591", email="panleicim@gmail.com",
|
||||||
message="SUCCESS", firstName="Lei", lastName="PAN", url='https://api.ipify.org')
|
# message="SUCCESS", firstName="Lei", lastName="PAN", url='https://api.ipify.org')
|
||||||
result_list = []
|
result_list = []
|
||||||
# for appointment in collection.stream():
|
for appointment in collection.stream():
|
||||||
# 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)
|
||||||
result_list.append(result_pojo)
|
# result_list.append(result_pojo)
|
||||||
# for result in result_list:
|
# for result in result_list:
|
||||||
# if result.accepted is None or ResultEnum.PENDING.value == result.accepted:
|
# if result.accepted is None or ResultEnum.PENDING.value == result.accepted:
|
||||||
# ResultChecker().run(result, collection)
|
# ResultChecker().run(result, collection)
|
||||||
# else:
|
# else:
|
||||||
# print("status is " + result.accepted)
|
# print("status is " + result.accepted)
|
||||||
|
|
||||||
with ThreadPoolExecutor(max_workers=1) as executor:
|
with ThreadPoolExecutor(max_workers=5) 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.PENDING.value == reserve.accepted:
|
if reserve.accepted is None or ResultEnum.PENDING.value == reserve.accepted:
|
||||||
|
|||||||
+1
-1
@@ -30,7 +30,7 @@ class DataManager:
|
|||||||
return sim_info_collection
|
return sim_info_collection
|
||||||
|
|
||||||
def get_all_successful_items(self):
|
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]):
|
def get_all_successful_items_for_day(self, day, source_from: Union[str, None]):
|
||||||
doc_ref = self._db.collection(day)
|
doc_ref = self._db.collection(day)
|
||||||
|
|||||||
Reference in New Issue
Block a user