add method to extract contact list with serial
This commit is contained in:
@@ -88,6 +88,17 @@ class MongoDbManager:
|
||||
except Exception as Error:
|
||||
self.logger.info(Error)
|
||||
|
||||
def upload_contact_list_to_collection(self, contact_list: list, collection_name):
|
||||
|
||||
try:
|
||||
collection_to_use = self.db[collection_name]
|
||||
for contact in contact_list:
|
||||
# collection_to_use.insert_one(contact.to_firestore_dict())
|
||||
collection_to_use.replace_one(filter={'_id': contact.mail, }, replacement=contact.to_firestore_dict(),
|
||||
upsert=True)
|
||||
except Exception as Error:
|
||||
self.logger.info(Error)
|
||||
|
||||
def get_all_accepted_appointments(self) -> list:
|
||||
collection_name = ACCEPTED_APPOINTMENT_LIST
|
||||
appointment_list_contacts = []
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user