diff --git a/check_results.py b/check_results.py index 586a715..884a2a7 100644 --- a/check_results.py +++ b/check_results.py @@ -3,7 +3,6 @@ from enum import Enum from playwright.sync_api import sync_playwright import params -from db.DbManager import DataManager from logs.LogSender import TYPE_EVENT_CHECK_RESULTS, LOG_SUBJECT_EVENT from pojo.ReserveResultPojo import ReserveResultPojo diff --git a/db/DbManager.py b/db/DbManager.py index 9bb0740..bf60153 100644 --- a/db/DbManager.py +++ b/db/DbManager.py @@ -39,7 +39,10 @@ class DataManager: return sim_info_collection def get_all_successful_items(self): - doc_ref = self._db.collection(str(datetime.date.today())) + return self.get_all_successful_items_for_day(str(datetime.date.today())) + + def get_all_successful_items_for_day(self, day): + doc_ref = self._db.collection(day) return doc_ref def save_sim_info(self, simInfoPojo: SimInfoPojo): diff --git a/export_valid_profiles.py b/export_valid_profiles.py new file mode 100644 index 0000000..13b8650 --- /dev/null +++ b/export_valid_profiles.py @@ -0,0 +1,57 @@ +import xlsxwriter + +import params +from pojo.ReserveResultPojo import ReserveResultPojo +from pojo.contact_pojo import ContactPojo +from utils.excel_reader import ExcelHelper + + +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', + '2022-03-15', '2022-03-16'] + collection = [] + for day in day_list: + collection.extend(params.firebase_store_manager.get_all_successful_items_for_day(day).stream()) + + valid_contacts = [] + exist_contacts = ExcelHelper().read_contacts() + for valid_appointment in collection: + reserve_pojo = ReserveResultPojo.from_firestore_dict(valid_appointment.to_dict()) + # check whether the contact exists already + exist = [contact for contact in valid_contacts if contact.mail == reserve_pojo.email] + if len(exist) == 0: + contact = ContactPojo(reserve_pojo.phone, passport_number=reserve_pojo.passport, + last_name=reserve_pojo.lastName, first_name=reserve_pojo.firstName, ccid="", + mail=reserve_pojo.email, position=0) + if contact.passport == None or len(contact.passport) == 0: + old_contact = [item for item in exist_contacts if item.mail == contact.mail] + if len(old_contact) > 0: + contact.passport = old_contact[0].passport + + print(contact) + valid_contacts.append(contact) + + row = 0 + col = 0 + # Create a workbook and add a worksheet. + workbook = xlsxwriter.Workbook('valid_profile.xlsx') + header_data = ['name', 'phone', 'passport', 'email', 'ccid', 'position'] + worksheet = workbook.add_worksheet() + header_format = workbook.add_format({'bold': True}) + + for col_num, data in enumerate(header_data): + worksheet.write(row, col_num, data, header_format) + row = row + 1 + for info in valid_contacts: + # Iterate over the data and write it out row by row. + worksheet.write(row, col, "{} {}".format(info.last_name, info.first_name)) + worksheet.write(row, col + 1, info.phone) + worksheet.write(row, col + 2, info.passport) + worksheet.write(row, col + 3, info.mail) + worksheet.write(row, col + 4, info.ccid) + row += 1 + workbook.close() + + +if __name__ == '__main__': + write_the_valid_profiles_to_excel() diff --git a/main.py b/main.py index 029ec77..2303ef1 100644 --- a/main.py +++ b/main.py @@ -8,8 +8,8 @@ from typing import Union from gsmmodem import GsmModem import params -from ModemPool import ModemPool -from card_pool import CardPool +from modems.ModemPool import ModemPool +from modems.card_pool import CardPool from commandor import Commandor from logs.LogSender import LOG_APPOINTMENT_TIMEOUT, LOG_SUBJECT_EVENT, TYPE_EVENT_RESET_ALL_SIM_CARDS from params import MODEM_POOL_PORTS, CARD_POOL_PORT, firebase_store_manager, oracle_log_sender diff --git a/ModemPool.py b/modems/ModemPool.py similarity index 100% rename from ModemPool.py rename to modems/ModemPool.py diff --git a/card_pool.py b/modems/card_pool.py similarity index 100% rename from card_pool.py rename to modems/card_pool.py diff --git a/reset_all_sim_card.py b/reset_all_sim_card.py index ca9320a..aa40c6a 100644 --- a/reset_all_sim_card.py +++ b/reset_all_sim_card.py @@ -1,7 +1,7 @@ import logging import params -from ModemPool import ModemPool +from modems.ModemPool import ModemPool from logs.AppLogging import init_logger from logs.LogSender import LOG_SUBJECT_EVENT, TYPE_EVENT_RESET_ALL_SIM_CARDS from main import card_pool, get_devices_ports diff --git a/valid_profile.xlsx b/valid_profile.xlsx new file mode 100644 index 0000000..45e7b9d Binary files /dev/null and b/valid_profile.xlsx differ