radmon id number
This commit is contained in:
Binary file not shown.
+5
-5
@@ -25,11 +25,11 @@ class DataManager:
|
|||||||
cred = credentials.Certificate(definitions.ROOT_DIR + "/appointment.json")
|
cred = credentials.Certificate(definitions.ROOT_DIR + "/appointment.json")
|
||||||
self._app = firebase_admin.initialize_app(cred)
|
self._app = firebase_admin.initialize_app(cred)
|
||||||
self._db = firestore.client()
|
self._db = firestore.client()
|
||||||
contact_collection = self._db.collection(CONTACT_COLLECTION_NAME)
|
# contact_collection = self._db.collection(CONTACT_COLLECTION_NAME)
|
||||||
self._contact_list = []
|
# self._contact_list = []
|
||||||
for contact in contact_collection.stream():
|
# for contact in contact_collection.stream():
|
||||||
contact_pojo = ContactPojo.from_firestore_dict(contact.to_dict())
|
# contact_pojo = ContactPojo.from_firestore_dict(contact.to_dict())
|
||||||
self._contact_list.append(contact_pojo)
|
# self._contact_list.append(contact_pojo)
|
||||||
|
|
||||||
def get_all_error_items(self):
|
def get_all_error_items(self):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import random
|
||||||
|
import string
|
||||||
|
|
||||||
import xlsxwriter
|
import xlsxwriter
|
||||||
|
|
||||||
import params
|
import params
|
||||||
@@ -5,28 +8,39 @@ from pojo.ReserveResultPojo import ReserveResultPojo
|
|||||||
from pojo.contact_pojo import ContactPojo
|
from pojo.contact_pojo import ContactPojo
|
||||||
from utils.excel_reader import ExcelHelper
|
from utils.excel_reader import ExcelHelper
|
||||||
|
|
||||||
|
def get_random_id_number ()-> str:
|
||||||
|
# write_the_valid_profiles_to_excel()
|
||||||
|
S = 7 # number of characters in the string.
|
||||||
|
# call random.choices() string module to find the string in Uppercase + numeric data.
|
||||||
|
ran = ''.join(random.choices(string.digits, k = S))
|
||||||
|
id_number = "94"+str(ran)
|
||||||
|
print("The randomly generated string is : 94" + str(ran)) # print the random data
|
||||||
|
return id_number
|
||||||
|
|
||||||
|
|
||||||
def write_the_valid_profiles_to_excel():
|
def write_the_valid_profiles_to_excel():
|
||||||
day_list = ['2022-03-04', '2022-03-07', '2022-03-08', '2022-03-09', '2022-03-10', '2022-03-11', '2022-03-14',
|
day_list = ['2022-03-04', '2022-03-07', '2022-03-08', '2022-03-09', '2022-03-10', '2022-03-11', '2022-03-14',
|
||||||
'2022-03-15', '2022-03-16']
|
'2022-03-15', '2022-03-16']
|
||||||
|
|
||||||
collection = []
|
collection = []
|
||||||
for day in day_list:
|
for day in day_list:
|
||||||
collection.extend(params.firebase_store_manager.get_all_successful_items_for_day(day).stream())
|
collection.extend(params.firebase_store_manager.get_all_successful_items_for_day(day).stream())
|
||||||
|
|
||||||
valid_contacts = []
|
valid_contacts = []
|
||||||
exist_contacts = ExcelHelper().read_contacts()
|
# exist_contacts = ExcelHelper().read_contacts()
|
||||||
for valid_appointment in collection:
|
for valid_appointment in collection:
|
||||||
reserve_pojo = ReserveResultPojo.from_firestore_dict(valid_appointment.to_dict())
|
reserve_pojo = ReserveResultPojo.from_firestore_dict(valid_appointment.to_dict())
|
||||||
# check whether the contact exists already
|
# check whether the contact exists already
|
||||||
exist = [contact for contact in valid_contacts if contact.mail == reserve_pojo.email]
|
exist = [contact for contact in valid_contacts if contact.mail == reserve_pojo.email]
|
||||||
if len(exist) == 0:
|
if len(exist) == 0:
|
||||||
contact = ContactPojo(reserve_pojo.phone, passport_number=reserve_pojo.passport,
|
contact = ContactPojo(reserve_pojo.phone, passport_number=get_random_id_number(),
|
||||||
last_name=reserve_pojo.lastName, first_name=reserve_pojo.firstName, ccid="",
|
last_name=reserve_pojo.lastName, first_name=reserve_pojo.firstName, ccid="",
|
||||||
mail=reserve_pojo.email, position=0)
|
mail=reserve_pojo.email, position=0)
|
||||||
if contact.passport == None or len(contact.passport) == 0:
|
# contact.passport = get_random_id_number()
|
||||||
old_contact = [item for item in exist_contacts if item.mail == contact.mail]
|
# if contact.passport == None or len(contact.passport) == 0:
|
||||||
if len(old_contact) > 0:
|
# old_contact = [item for item in exist_contacts if item.mail == contact.mail]
|
||||||
contact.passport = old_contact[0].passport
|
# if len(old_contact) > 0:
|
||||||
|
# contact.passport = old_contact[0].passport
|
||||||
|
|
||||||
print(contact)
|
print(contact)
|
||||||
valid_contacts.append(contact)
|
valid_contacts.append(contact)
|
||||||
@@ -53,5 +67,7 @@ def write_the_valid_profiles_to_excel():
|
|||||||
workbook.close()
|
workbook.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
# get_random_id_number()
|
||||||
write_the_valid_profiles_to_excel()
|
write_the_valid_profiles_to_excel()
|
||||||
Binary file not shown.
Reference in New Issue
Block a user