add possibility to add to black list

This commit is contained in:
2024-09-26 22:02:57 +02:00
parent 842588d99e
commit ee8269e5cc
2 changed files with 20 additions and 10 deletions
+17 -4
View File
@@ -2,16 +2,16 @@ import datetime
import random import random
import xlsxwriter import xlsxwriter
from src.person_name.cython_extract_methods import filter_already_validated_contacts, read_pinyin_list_from_file
from src.db.mongo_manager import MONGO_STORE_MANAGER from src.db.mongo_manager import MONGO_STORE_MANAGER
from src.person_name.cython_extract_methods import filter_already_validated_contacts, read_pinyin_list_from_file
from src.pojo.contact_pojo import ContactPojo from src.pojo.contact_pojo import ContactPojo
from src.utils.contacts.generate_random_passport_id import get_random_passport_id_number from src.utils.contacts.generate_random_passport_id import get_random_passport_id_number
from src.utils.excel_reader import read_contacts, fr_phone_number_prefix, get_random_fr_phone_numbers, ExcelHelper 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/lpan/Desktop/contact_list_2024-09-16.xlsx") _contacts_to_book = read_contacts("/Users/lpan/Desktop/contact_list_2024-09-24.xlsx")
return _contacts_to_book return _contacts_to_book
@@ -138,15 +138,28 @@ def generate_all_contact_list():
write_new_contacts_to_excel(_all_contacts, file_name="all") write_new_contacts_to_excel(_all_contacts, file_name="all")
def write_to_black_list(contacts: list):
for contact in contacts:
MONGO_STORE_MANAGER.insert_blacklist_contact(contact)
def get_contact_list_not_received_mail():
_contact_list = MONGO_STORE_MANAGER.get_all_successful_items_for_day()
for _contact in _contact_list:
if not _contact.url_validated:
write_to_black_list([_contact])
# 把新的联系人存到网上 # 把新的联系人存到网上
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)
# print("start at {}".format(datetime.datetime.now())) # print("start at {}".format(datetime.datetime.now()))
# generate_valid_contact_list_for_day(segment_number=2) generate_valid_contact_list_for_day(segment_number=2)
# generate_contact_from_mail_list("/Users/lpan/Downloads/邮箱及密码.xlsx") # generate_contact_from_mail_list("/Users/lpan/Downloads/邮箱及密码.xlsx")
# print("end at {}".format(datetime.datetime.now())) # print("end at {}".format(datetime.datetime.now()))
generate_all_contact_list() # get_contact_list_not_received_mail()
# generate_all_contact_list()
# merge_contact_list_files( # merge_contact_list_files(
# ["/Users/lpan/Desktop/contact_list_all_old_not_used_contact.xlsx", # ["/Users/lpan/Desktop/contact_list_all_old_not_used_contact.xlsx",
# "/Users/lpan/Desktop/contact_list_2024-06-26.xlsx"]) # "/Users/lpan/Desktop/contact_list_2024-06-26.xlsx"])
+3 -6
View File
@@ -9,9 +9,8 @@ class BlackContactPojo(ContactPojo):
def __init__(self, phone_number: str, passport_number: str, last_name: str, first_name: str, mail: str, def __init__(self, phone_number: str, passport_number: str, last_name: str, first_name: str, mail: str,
update_at_in_s: Union[float, None] = None, update_at_in_s: Union[float, None] = None,
ccid: str = "", ):
position: int = 0, ): super().__init__(phone_number, passport_number, last_name, first_name, mail, store="random")
super().__init__(phone_number, passport_number, last_name, first_name, mail, ccid, position)
if update_at_in_s: if update_at_in_s:
self.update_at_in_s = update_at_in_s self.update_at_in_s = update_at_in_s
else: else:
@@ -24,15 +23,13 @@ class BlackContactPojo(ContactPojo):
@staticmethod @staticmethod
def from_firestore_dict(source): def from_firestore_dict(source):
ccid = source['ccid']
phone = source['phone'] phone = source['phone']
position = source['position']
passport = source['passport'] passport = source['passport']
email = source['mail'] email = source['mail']
last_name = source['last_name'] last_name = source['last_name']
first_name = source['first_name'] first_name = source['first_name']
update_at_in_s = source['update_at_in_s'] update_at_in_s = source['update_at_in_s']
result = BlackContactPojo(ccid=ccid, phone_number=phone, passport_number=passport, position=position, result = BlackContactPojo(phone_number=phone, passport_number=passport,
mail=email, update_at_in_s=update_at_in_s, mail=email, update_at_in_s=update_at_in_s,
last_name=last_name, first_name=first_name) last_name=last_name, first_name=first_name)
return result return result