Merge branch 'master' of bitbucket.org:panleicim/appointment_tool

This commit is contained in:
2024-04-01 23:03:20 +02:00
3 changed files with 33 additions and 7 deletions
+2
View File
@@ -162,6 +162,8 @@ def accept_appointment_found(accepted_result_list: list):
def find_confirmation_contacts_for_today(): def find_confirmation_contacts_for_today():
_all_mail_list = MONGO_STORE_MANAGER.get_destination_emails() _all_mail_list = MONGO_STORE_MANAGER.get_destination_emails()
_all_appointments_today = MONGO_STORE_MANAGER.get_all_successful_items_for_day() _all_appointments_today = MONGO_STORE_MANAGER.get_all_successful_items_for_day()
if len(_all_appointments_today) == 0:
_all_appointments_today = MONGO_STORE_MANAGER.get_all_successful_items_for_yesterday()
_mail_list_to_scan = [] _mail_list_to_scan = []
for _item in _all_appointments_today: for _item in _all_appointments_today:
for _mail in _all_mail_list: for _mail in _all_mail_list:
+26 -6
View File
@@ -4,11 +4,11 @@ import random
import xlsxwriter import xlsxwriter
from src.db.mongo_manager import MONGO_STORE_MANAGER from src.db.mongo_manager import MONGO_STORE_MANAGER
from src.utils.excel_reader import read_contacts, fr_phone_number_prefix, get_random_fr_phone_numbers from src.utils.excel_reader import read_contacts, fr_phone_number_prefix, get_random_fr_phone_numbers, ExcelHelper
def upload_contacts_list(): def upload_contacts_list():
_contacts_to_book = read_contacts("/Users/panlei/Desktop/contact_list_2024-03-23.xlsx") _contacts_to_book = read_contacts("/Users/panlei/Desktop/contact_list_2024-03-30.xlsx")
return _contacts_to_book return _contacts_to_book
@@ -19,7 +19,7 @@ def fix_phone_number_format(file_path):
if _contact.phone[0:2] not in fr_phone_number_prefix: if _contact.phone[0:2] not in fr_phone_number_prefix:
print(_contact) print(_contact)
_contact.phone = get_random_fr_phone_numbers() _contact.phone = get_random_fr_phone_numbers()
write_new_contacts_to_excel(_contact_list, file_name="23_03_to_test") write_new_contacts_to_excel(_contact_list, file_name="25_03_to_test")
def write_new_contacts_to_excel(valid_contacts: list, file_name=str(datetime.date.today())): def write_new_contacts_to_excel(valid_contacts: list, file_name=str(datetime.date.today())):
@@ -66,6 +66,18 @@ def generate_valid_contact_list_for_day():
write_new_contacts_to_excel(_contact_to_save) write_new_contacts_to_excel(_contact_to_save)
def merge_contact_list_files(file_list: list, final_file_name="merged_contact_list"):
_all_contact_list = []
for file in file_list:
_all_contact_list.extend(read_contacts(file))
for _con in _all_contact_list:
_con.store = "random"
print(len(_all_contact_list))
_list_without_duplicate = list(set(_all_contact_list))
print(len(_list_without_duplicate))
write_new_contacts_to_excel(_list_without_duplicate, file_name=final_file_name)
def generate_all_contact_list(): def generate_all_contact_list():
_all_contacts = MONGO_STORE_MANAGER.get_all_contacts_to_book() _all_contacts = MONGO_STORE_MANAGER.get_all_contacts_to_book()
random.shuffle(_all_contacts) random.shuffle(_all_contacts)
@@ -76,8 +88,16 @@ def generate_all_contact_list():
# 把新的联系人存到网上 # 把新的联系人存到网上
if __name__ == '__main__': if __name__ == '__main__':
contacts_to_book = upload_contacts_list() # contacts_to_book = upload_contacts_list()
MONGO_STORE_MANAGER.upload_contact_list(contacts_to_book) # MONGO_STORE_MANAGER.upload_contact_list(contacts_to_book)
# generate_valid_contact_list_for_day() # generate_valid_contact_list_for_day()
# generate_all_contact_list() # generate_all_contact_list()
# fix_phone_number_format("/Users/panlei/Desktop/23_03_to_test.xlsx") merge_contact_list_files(
["/Users/panlei/Desktop/contact_list_2024-03-29.xlsx",
"/Users/panlei/Desktop/contact_list_2024-03-27.xlsx",
"/Users/panlei/Desktop/contact_list_2024-03-28.xlsx",
"/Users/panlei/Desktop/contact_list_2024-03-26.xlsx",
"/Users/panlei/Desktop/contact_list_2024-03-25.xlsx",
"/Users/panlei/Desktop/contact_list_2024-03-23.xlsx",
"/Users/panlei/Desktop/contact_list_2024-03-22.xlsx"])
# fix_phone_number_format("/Users/panlei/Desktop/25_03_to_test.xlsx")
+4
View File
@@ -29,6 +29,10 @@ class ContactPojo:
self.mail = mail self.mail = mail
self.store = store self.store = store
self.ip_country = ip_country self.ip_country = ip_country
self.ip_address = ""
def __hash__(self):
return hash(self.mail)
def to_firestore_dict(self): def to_firestore_dict(self):
dest = { dest = {