From 4215966350b831444c547588fe2b8f7c66ffaff9 Mon Sep 17 00:00:00 2001 From: JazzarKarim Date: Mon, 12 Aug 2024 15:56:06 -0700 Subject: [PATCH 1/4] 22203 - Added furnishings logging --- .../src/furnishings/stage_processors/stage_one.py | 8 ++++++++ .../src/furnishings/stage_processors/stage_three.py | 1 + .../src/furnishings/stage_processors/stage_two.py | 1 + jobs/furnishings/src/furnishings/worker.py | 6 ++++++ 4 files changed, 16 insertions(+) diff --git a/jobs/furnishings/src/furnishings/stage_processors/stage_one.py b/jobs/furnishings/src/furnishings/stage_processors/stage_one.py index d5b217546..9b588d034 100644 --- a/jobs/furnishings/src/furnishings/stage_processors/stage_one.py +++ b/jobs/furnishings/src/furnishings/stage_processors/stage_one.py @@ -92,22 +92,28 @@ async def _send_first_round_notification(self, batch_processing: BatchProcessing business.legal_name, email ) + self._app.logger.debug(f'New furnishing has been created with ID (first round): {new_furnishing.id}') + mailing_address = business.mailing_address.one_or_none() if mailing_address: self._create_furnishing_address(mailing_address, new_furnishing.id) + self._app.logger.debug(f'Created furnishing address (first round)') if email: # send email letter await self._send_email(new_furnishing) + self._app.logger.debug(f'Successfully put email message on the queue for furnishing entry with ID: {new_furnishing.id}') else: # send paper letter if business doesn't have email address new_furnishing.furnishing_type = Furnishing.FurnishingType.MAIL new_furnishing.save() + self._app.logger.debug(f'Changed furnishing type to MAIL for funishing with ID: {new_furnishing.id}') # TODO: create and add letter to either AR or transition pdf # TODO: send AR and transition pdf to BCMail+ new_furnishing.status = Furnishing.FurnishingStatus.PROCESSED new_furnishing.processed_date = datetime.utcnow() new_furnishing.save() + self._app.logger.debug(f'Changed furnishing status to PROCESSED for funishing with ID: {new_furnishing.id}') async def _send_second_round_notification(self, batch_processing: BatchProcessing): """Send paper letter if business is still not in good standing after 5 days of email letter sent out.""" @@ -127,10 +133,12 @@ async def _send_second_round_notification(self, batch_processing: BatchProcessin business.last_ar_date if business.last_ar_date else business.founding_date, business.legal_name ) + self._app.logger.debug(f'New furnishing has been created with ID (second round): {new_furnishing.id}') mailing_address = business.mailing_address.one_or_none() if mailing_address: self._create_furnishing_address(mailing_address, new_furnishing.id) + self._app.logger.debug(f'Created furnishing address (second round)') # TODO: create and add letter to either AR or transition pdf # TODO: send AR and transition pdf to BCMail+ diff --git a/jobs/furnishings/src/furnishings/stage_processors/stage_three.py b/jobs/furnishings/src/furnishings/stage_processors/stage_three.py index f5ddbef71..f5d176729 100644 --- a/jobs/furnishings/src/furnishings/stage_processors/stage_three.py +++ b/jobs/furnishings/src/furnishings/stage_processors/stage_three.py @@ -62,6 +62,7 @@ def process(app: Flask): business_name=business.legal_name ) new_furnishing.save() + app.logger.debug(f'Created corp dissolved furnishing entry with ID: {new_furnishing.id}') # TODO: create data files and SFTPing to BC Laws # TODO: mark furnishings entry processed diff --git a/jobs/furnishings/src/furnishings/stage_processors/stage_two.py b/jobs/furnishings/src/furnishings/stage_processors/stage_two.py index f66265775..a7b8756f7 100644 --- a/jobs/furnishings/src/furnishings/stage_processors/stage_two.py +++ b/jobs/furnishings/src/furnishings/stage_processors/stage_two.py @@ -61,6 +61,7 @@ def process(app: Flask, xml_furnishings: dict): business_name=business.legal_name ) new_furnishing.save() + app.logger.debug(f'Created intent to dissolve furnishing entry with ID: {new_furnishing.id}') if business != Business.LegalTypes.EXTRA_PRO_A.value: bc_furnishings.append(new_furnishing) diff --git a/jobs/furnishings/src/furnishings/worker.py b/jobs/furnishings/src/furnishings/worker.py index b4f245dae..7b58c5204 100644 --- a/jobs/furnishings/src/furnishings/worker.py +++ b/jobs/furnishings/src/furnishings/worker.py @@ -117,10 +117,16 @@ async def run(application: Flask, qsm: QueueService): # pylint: disable=redefin xml_furnishings_dict = {} if stage_1_valid: + application.logger.debug('Entering stage 1 of furnishings job.') await stage_one.process(application, qsm) + application.logger.debug('Exiting stage 1 of furnishings job.') if stage_2_valid: + application.logger.debug('Entering stage 2 of furnishings job.') stage_two.process(application, xml_furnishings_dict) + application.logger.debug('Exiting stage 2 of furnishings job.') if stage_3_valid: + application.logger.debug('Entering stage 3 of furnishings job.') stage_three.process(application) + application.logger.debug('Exiting stage 3 of furnishings job.') post_processor.process(application, xml_furnishings_dict) From 51e63f1fc9728c60e8c8b981bf7cd8a4e5750030 Mon Sep 17 00:00:00 2001 From: JazzarKarim Date: Tue, 13 Aug 2024 11:50:13 -0700 Subject: [PATCH 2/4] fixed lint issue --- .../furnishings/src/furnishings/stage_processors/stage_one.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jobs/furnishings/src/furnishings/stage_processors/stage_one.py b/jobs/furnishings/src/furnishings/stage_processors/stage_one.py index 9b588d034..5bd347cae 100644 --- a/jobs/furnishings/src/furnishings/stage_processors/stage_one.py +++ b/jobs/furnishings/src/furnishings/stage_processors/stage_one.py @@ -97,7 +97,7 @@ async def _send_first_round_notification(self, batch_processing: BatchProcessing mailing_address = business.mailing_address.one_or_none() if mailing_address: self._create_furnishing_address(mailing_address, new_furnishing.id) - self._app.logger.debug(f'Created furnishing address (first round)') + self._app.logger.debug('Created furnishing address (first round)') if email: # send email letter await self._send_email(new_furnishing) @@ -138,7 +138,7 @@ async def _send_second_round_notification(self, batch_processing: BatchProcessin mailing_address = business.mailing_address.one_or_none() if mailing_address: self._create_furnishing_address(mailing_address, new_furnishing.id) - self._app.logger.debug(f'Created furnishing address (second round)') + self._app.logger.debug('Created furnishing address (second round)') # TODO: create and add letter to either AR or transition pdf # TODO: send AR and transition pdf to BCMail+ From 70c6d34bced1b3d27fb49133494a65138e632c50 Mon Sep 17 00:00:00 2001 From: JazzarKarim Date: Tue, 13 Aug 2024 11:55:57 -0700 Subject: [PATCH 3/4] fixed flake8 issue --- jobs/furnishings/src/furnishings/stage_processors/stage_one.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jobs/furnishings/src/furnishings/stage_processors/stage_one.py b/jobs/furnishings/src/furnishings/stage_processors/stage_one.py index 5bd347cae..d85a18205 100644 --- a/jobs/furnishings/src/furnishings/stage_processors/stage_one.py +++ b/jobs/furnishings/src/furnishings/stage_processors/stage_one.py @@ -101,7 +101,8 @@ async def _send_first_round_notification(self, batch_processing: BatchProcessing if email: # send email letter await self._send_email(new_furnishing) - self._app.logger.debug(f'Successfully put email message on the queue for furnishing entry with ID: {new_furnishing.id}') + self._app.logger.debug( + f'Successfully put email message on the queue for furnishing entry with ID: {new_furnishing.id}') else: # send paper letter if business doesn't have email address new_furnishing.furnishing_type = Furnishing.FurnishingType.MAIL From a12de6873495486ee2e9cf61b06c6e198dae729d Mon Sep 17 00:00:00 2001 From: JazzarKarim Date: Wed, 14 Aug 2024 09:57:56 -0700 Subject: [PATCH 4/4] added some logging in post processor of furnishing job --- .../src/furnishings/stage_processors/post_processor.py | 4 ++++ .../furnishings/src/furnishings/stage_processors/stage_one.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/jobs/furnishings/src/furnishings/stage_processors/post_processor.py b/jobs/furnishings/src/furnishings/stage_processors/post_processor.py index 7332a4458..aac46a168 100644 --- a/jobs/furnishings/src/furnishings/stage_processors/post_processor.py +++ b/jobs/furnishings/src/furnishings/stage_processors/post_processor.py @@ -79,13 +79,17 @@ def _update_furnishings_status(self, furnishing_group_id): def process(self): """Postprocess to generate and upload file to external resources(BC Laws).""" self._format_furnishings() + self._app.logger.debug('Formatted furnishing details presented in XML file') self._set_meta_info() payload = self._build_xml_data(self._xml_data) furnishing_group, _ = self._save_xml_payload(payload) + self._app.logger.debug('Saved XML payload') # TODO: SFTP to BC Laws # mark furnishing records processed self._update_furnishings_status(furnishing_group.id) + self._app.logger.debug( + f'furnishing records with group id: {furnishing_group.id} marked as processed') class XmlMeta: diff --git a/jobs/furnishings/src/furnishings/stage_processors/stage_one.py b/jobs/furnishings/src/furnishings/stage_processors/stage_one.py index d85a18205..ed121f5a3 100644 --- a/jobs/furnishings/src/furnishings/stage_processors/stage_one.py +++ b/jobs/furnishings/src/furnishings/stage_processors/stage_one.py @@ -97,7 +97,7 @@ async def _send_first_round_notification(self, batch_processing: BatchProcessing mailing_address = business.mailing_address.one_or_none() if mailing_address: self._create_furnishing_address(mailing_address, new_furnishing.id) - self._app.logger.debug('Created furnishing address (first round)') + self._app.logger.debug(f'Created address (first round) with furnishing ID: {new_furnishing.id}') if email: # send email letter await self._send_email(new_furnishing) @@ -139,7 +139,7 @@ async def _send_second_round_notification(self, batch_processing: BatchProcessin mailing_address = business.mailing_address.one_or_none() if mailing_address: self._create_furnishing_address(mailing_address, new_furnishing.id) - self._app.logger.debug('Created furnishing address (second round)') + self._app.logger.debug(f'Created address (second round) with furnishing ID: {new_furnishing.id}') # TODO: create and add letter to either AR or transition pdf # TODO: send AR and transition pdf to BCMail+