add method to merge contacts

This commit is contained in:
2024-03-31 18:10:01 +02:00
parent 283bbb9a74
commit bf13860b40
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():
_all_mail_list = MONGO_STORE_MANAGER.get_destination_emails()
_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 = []
for _item in _all_appointments_today:
for _mail in _all_mail_list:
+26 -6
View File
@@ -4,11 +4,11 @@ import random
import xlsxwriter
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():
_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
@@ -19,7 +19,7 @@ def fix_phone_number_format(file_path):
if _contact.phone[0:2] not in fr_phone_number_prefix:
print(_contact)
_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())):
@@ -66,6 +66,18 @@ def generate_valid_contact_list_for_day():
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():
_all_contacts = MONGO_STORE_MANAGER.get_all_contacts_to_book()
random.shuffle(_all_contacts)
@@ -76,8 +88,16 @@ def generate_all_contact_list():
# 把新的联系人存到网上
if __name__ == '__main__':
contacts_to_book = upload_contacts_list()
MONGO_STORE_MANAGER.upload_contact_list(contacts_to_book)
# contacts_to_book = upload_contacts_list()
# MONGO_STORE_MANAGER.upload_contact_list(contacts_to_book)
# generate_valid_contact_list_for_day()
# 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")
+5 -1
View File
@@ -18,7 +18,7 @@ class ContactPojo:
def __repr__(self):
return "phone:{}, passport:{}, last_name:{}, first_name:{}, mail:{}, store:{}, ip_country:{},isp:{}".format(
self.phone, self.passport, self.last_name, self.first_name, self.mail, self.store, self.ip_country,
self.isp)
self.isp)
def __init__(self, phone_number: str, passport_number: str, last_name: str, first_name: str, mail: str, store: str,
ip_country="FR"):
@@ -29,6 +29,10 @@ class ContactPojo:
self.mail = mail
self.store = store
self.ip_country = ip_country
self.ip_address = ""
def __hash__(self):
return hash(self.mail)
def to_firestore_dict(self):
dest = {