add method to extract contact list with serial

This commit is contained in:
2024-12-12 23:32:41 +01:00
parent d884782cd8
commit 15286494d1
2 changed files with 33 additions and 5 deletions
+22 -5
View File
@@ -1,6 +1,8 @@
from pathlib import Path
from src.db.mongo_manager import MONGO_STORE_MANAGER
from src.person_name.contact_manager import write_new_contacts_to_excel
from src.pojo.contact_pojo import ContactPojo
from src.utils.excel_reader import read_contacts
DOMAIN_TO_INCLUDE = ["aol.com", "yahoo.com", "gmx.de", "gmx.net", "inbox.lv"]
@@ -32,11 +34,11 @@ def get_all_not_used_mails():
return not_used_emails
def get_all_old_contact_set():
def get_all_old_contact_set(start_with="2024"):
all_collection_list = get_all_collections()
collection_to_check = []
for col in all_collection_list:
if col.startswith('20'):
if col.startswith(start_with):
collection_to_check.append(col)
items_set = set()
for collection in collection_to_check:
@@ -45,6 +47,15 @@ def get_all_old_contact_set():
return items_set
def get_all_contact_with_source_from():
_list_to_check = get_all_old_contact_set()
_to_return = []
for contact in _list_to_check:
if contact.serial is not None and len(contact.serial) > 0:
_to_return.append(contact)
return _to_return
def generate_not_used_contact_list():
not_used_mail_list = get_all_not_used_mails()
all_old_contact_set = get_all_old_contact_set()
@@ -63,6 +74,12 @@ def generate_not_used_contact_list():
return contact_list
def upload_to_collection():
_contacts = read_contacts(str(Path.home()) + "/Desktop/contact_list_contacts_with_source.xlsx")
MONGO_STORE_MANAGER.upload_contact_list_to_collection(_contacts,"CONTACT_LIST_SERIAL_MAP")
if __name__ == '__main__':
contact_to_save = generate_not_used_contact_list()
write_new_contacts_to_excel(valid_contacts=contact_to_save, file_name="all_old_not_used_contact")
upload_to_collection()
# contact_to_save = get_all_contact_with_source_from()
# write_new_contacts_to_excel(valid_contacts=contact_to_save, file_name="contacts_with_source")