From b3e167531314fa68f7c2158ca16e52b2a611ab1d Mon Sep 17 00:00:00 2001 From: Daniel Haselhan Date: Wed, 24 Jan 2024 15:12:46 -0800 Subject: [PATCH 1/7] Add missing phone masks * Format phone numbers to nice formats --- .../application-details.component.html | 2 +- .../application-details/parcel/parcel.component.html | 4 ++-- .../parcel-entry/parcel-entry.component.html | 2 +- .../primary-contact/primary-contact.component.html | 2 +- .../review-submit-fng/review-submit-fng.component.html | 4 ++-- .../review-submit/review-submit.component.html | 4 ++-- .../lfng-review/lfng-review.component.html | 8 ++++---- .../parcels/parcel-entry/parcel-entry.component.html | 2 +- .../primary-contact/primary-contact.component.html | 2 +- .../notice-of-intent-details.component.html | 2 +- .../notice-of-intent-details/parcel/parcel.component.html | 6 +++--- .../notification-details.component.html | 2 +- 12 files changed, 20 insertions(+), 20 deletions(-) diff --git a/portal-frontend/src/app/features/applications/application-details/application-details.component.html b/portal-frontend/src/app/features/applications/application-details/application-details.component.html index c5ab3c914e..0a4cd6716b 100644 --- a/portal-frontend/src/app/features/applications/application-details/application-details.component.html +++ b/portal-frontend/src/app/features/applications/application-details/application-details.component.html @@ -71,7 +71,7 @@

3. Primary Contact

Phone
- {{ primaryContact?.phoneNumber }} + {{ primaryContact?.phoneNumber ?? '' | mask : '(000) 000-0000' }} Invalid FormatGovernment
Phone
- {{ parcel.owners[0].phoneNumber }} + {{ parcel.owners[0].phoneNumber ?? '' | mask : '(000) 000-0000' }}
Email
@@ -170,7 +170,7 @@
Government {{ owner.organizationName }} -
{{ owner.phoneNumber }}
+
{{ owner.phoneNumber ?? '' | mask : '(000) 000-0000' }}
{{ owner.email }}
{{ diff --git a/portal-frontend/src/app/features/applications/edit-submission/parcel-details/parcel-entry/parcel-entry.component.html b/portal-frontend/src/app/features/applications/edit-submission/parcel-details/parcel-entry/parcel-entry.component.html index 8364019faa..0eed3e8597 100644 --- a/portal-frontend/src/app/features/applications/edit-submission/parcel-details/parcel-entry/parcel-entry.component.html +++ b/portal-frontend/src/app/features/applications/edit-submission/parcel-details/parcel-entry/parcel-entry.component.html @@ -338,7 +338,7 @@
OR
Phone Number:
-
{{ selectedOwner.phoneNumber }}
+
{{ selectedOwner.phoneNumber ?? '' | mask : '(000) 000-0000' }}
Email:
diff --git a/portal-frontend/src/app/features/applications/edit-submission/primary-contact/primary-contact.component.html b/portal-frontend/src/app/features/applications/edit-submission/primary-contact/primary-contact.component.html index 73e0f98faa..0b785f50e9 100644 --- a/portal-frontend/src/app/features/applications/edit-submission/primary-contact/primary-contact.component.html +++ b/portal-frontend/src/app/features/applications/edit-submission/primary-contact/primary-contact.component.html @@ -82,7 +82,7 @@

Primary Contact

Phone Number:
-
{{ phoneNumber.value }}
+
{{ phoneNumber.value ?? '' | mask : '(000) 000-0000' }}
Email:
diff --git a/portal-frontend/src/app/features/applications/review-submission/review-submit-fng/review-submit-fng.component.html b/portal-frontend/src/app/features/applications/review-submission/review-submit-fng/review-submit-fng.component.html index ed76f16450..b39216223a 100644 --- a/portal-frontend/src/app/features/applications/review-submission/review-submit-fng/review-submit-fng.component.html +++ b/portal-frontend/src/app/features/applications/review-submission/review-submit-fng/review-submit-fng.component.html @@ -46,7 +46,7 @@

1. Contact Information

Phone Number
- {{ _applicationReview.phoneNumber }} + {{ _applicationReview.phoneNumber ?? '' | mask : '(000) 000-0000' }}
@@ -153,7 +153,7 @@

1. Contact Information

Phone Number
- {{ _applicationReview.phoneNumber }} + {{ _applicationReview.phoneNumber ?? '' | mask : '(000) 000-0000' }}
diff --git a/portal-frontend/src/app/features/applications/review-submission/review-submit/review-submit.component.html b/portal-frontend/src/app/features/applications/review-submission/review-submit/review-submit.component.html index 5a06728df8..464bdc22db 100644 --- a/portal-frontend/src/app/features/applications/review-submission/review-submit/review-submit.component.html +++ b/portal-frontend/src/app/features/applications/review-submission/review-submit/review-submit.component.html @@ -46,7 +46,7 @@

1. Contact Information

Phone Number
- {{ _applicationReview.phoneNumber }} + {{ _applicationReview.phoneNumber ?? '' | mask : '(000) 000-0000' }}
@@ -297,7 +297,7 @@

1. Contact Information

Phone Number
- {{ _applicationReview.phoneNumber }} + {{ _applicationReview.phoneNumber ?? '' | mask : '(000) 000-0000' }}
diff --git a/portal-frontend/src/app/features/applications/view-submission/lfng-review/lfng-review.component.html b/portal-frontend/src/app/features/applications/view-submission/lfng-review/lfng-review.component.html index d6054e8245..4b275a4502 100644 --- a/portal-frontend/src/app/features/applications/view-submission/lfng-review/lfng-review.component.html +++ b/portal-frontend/src/app/features/applications/view-submission/lfng-review/lfng-review.component.html @@ -13,7 +13,7 @@

Local/First Nation Gov Review

> Download PDF -
-
{{ owner.phoneNumber }}
+
{{ owner.phoneNumber ?? '' | mask : '(000) 000-0000' }}
{{ owner.email }}
{{ @@ -179,7 +179,7 @@
Government
-
+
1
diff --git a/portal-frontend/src/app/features/notifications/notification-details/notification-details.component.html b/portal-frontend/src/app/features/notifications/notification-details/notification-details.component.html index b081124a7d..cbe773ddd1 100644 --- a/portal-frontend/src/app/features/notifications/notification-details/notification-details.component.html +++ b/portal-frontend/src/app/features/notifications/notification-details/notification-details.component.html @@ -60,7 +60,7 @@

3. Primary Contact

Phone
- {{ notificationSubmission.contactPhone }} + {{ notificationSubmission.contactPhone ?? '' | mask : '(000) 000-0000' }} Invalid Format Date: Wed, 24 Jan 2024 15:25:22 -0800 Subject: [PATCH 2/7] Clear confirmed flag when owners are updated --- .../parcel-entry/parcel-entry.component.html | 2 +- .../parcel-entry/parcel-entry.component.ts | 24 +++++++++++++++++++ .../parcel-entry/parcel-entry.component.html | 2 +- .../parcel-entry/parcel-entry.component.ts | 24 +++++++++++++++++++ 4 files changed, 50 insertions(+), 2 deletions(-) diff --git a/portal-frontend/src/app/features/applications/edit-submission/parcel-details/parcel-entry/parcel-entry.component.html b/portal-frontend/src/app/features/applications/edit-submission/parcel-details/parcel-entry/parcel-entry.component.html index 8364019faa..3fc8e2126d 100644 --- a/portal-frontend/src/app/features/applications/edit-submission/parcel-details/parcel-entry/parcel-entry.component.html +++ b/portal-frontend/src/app/features/applications/edit-submission/parcel-details/parcel-entry/parcel-entry.component.html @@ -236,7 +236,7 @@
Government Parcel Contact
[submissionUuid]="submissionUuid" [parcelUuid]="parcel.uuid" [owners]="parcel.owners" - (onOwnersUpdated)="onOwnersUpdated.emit()" + (onOwnersUpdated)="onEditOwner()" (onOwnerRemoved)="onRemoveOwner($event)" (onOwnersDeleted)="onDeleteOwner()" [documentService]="applicationDocumentService" diff --git a/portal-frontend/src/app/features/applications/edit-submission/parcel-details/parcel-entry/parcel-entry.component.ts b/portal-frontend/src/app/features/applications/edit-submission/parcel-details/parcel-entry/parcel-entry.component.ts index 3144eea5f5..18d869091b 100644 --- a/portal-frontend/src/app/features/applications/edit-submission/parcel-details/parcel-entry/parcel-entry.component.ts +++ b/portal-frontend/src/app/features/applications/edit-submission/parcel-details/parcel-entry/parcel-entry.component.ts @@ -411,6 +411,16 @@ export class ParcelEntryComponent implements OnInit { }); } + onEditOwner() { + this.parcelForm.patchValue( + { + isConfirmedByApplicant: false, + }, + { emitEvent: false } + ); + this.onOwnersUpdated.emit(); + } + onEditCrownOwner(owner: ApplicationOwnerDto) { let dialog; dialog = this.dialog.open(CrownOwnerDialogComponent, { @@ -424,6 +434,13 @@ export class ParcelEntryComponent implements OnInit { }); dialog.afterClosed().subscribe((result) => { if (result) { + this.parcelForm.patchValue( + { + isConfirmedByApplicant: false, + }, + { emitEvent: false } + ); + this.onOwnersUpdated.emit(); if (result.type === 'delete') { this.onRemoveOwner(result.uuid); @@ -584,6 +601,13 @@ export class ParcelEntryComponent implements OnInit { this.ownerInput.enable(); } + this.parcelForm.patchValue( + { + isConfirmedByApplicant: false, + }, + { emitEvent: false } + ); + this.parcel.owners = updatedArray; this.filteredOwners = this.mapOwners(this.owners); this.onFormGroupChange.emit({ diff --git a/portal-frontend/src/app/features/notice-of-intents/edit-submission/parcels/parcel-entry/parcel-entry.component.html b/portal-frontend/src/app/features/notice-of-intents/edit-submission/parcels/parcel-entry/parcel-entry.component.html index 57e4e09ec2..841a693669 100644 --- a/portal-frontend/src/app/features/notice-of-intents/edit-submission/parcels/parcel-entry/parcel-entry.component.html +++ b/portal-frontend/src/app/features/notice-of-intents/edit-submission/parcels/parcel-entry/parcel-entry.component.html @@ -232,7 +232,7 @@
Government Parcel Contact
[submissionUuid]="submissionUuid" [parcelUuid]="parcel.uuid" [owners]="parcel.owners" - (onOwnersUpdated)="onOwnersUpdated.emit()" + (onOwnersUpdated)="onEditOwner()" (onOwnerRemoved)="onOwnerRemoved($event)" (onOwnersDeleted)="onDeleteOwner()" [ownerService]="noticeOfIntentOwnerService" diff --git a/portal-frontend/src/app/features/notice-of-intents/edit-submission/parcels/parcel-entry/parcel-entry.component.ts b/portal-frontend/src/app/features/notice-of-intents/edit-submission/parcels/parcel-entry/parcel-entry.component.ts index 487c0c00c9..8669bc56ec 100644 --- a/portal-frontend/src/app/features/notice-of-intents/edit-submission/parcels/parcel-entry/parcel-entry.component.ts +++ b/portal-frontend/src/app/features/notice-of-intents/edit-submission/parcels/parcel-entry/parcel-entry.component.ts @@ -407,6 +407,13 @@ export class ParcelEntryComponent implements OnInit { }); dialog.afterClosed().subscribe((result) => { if (result) { + this.parcelForm.patchValue( + { + isConfirmedByApplicant: false, + }, + { emitEvent: false } + ); + if (result.type === 'delete') { this.onOwnersDeleted.emit(); } @@ -415,6 +422,16 @@ export class ParcelEntryComponent implements OnInit { }); } + onEditOwner() { + this.parcelForm.patchValue( + { + isConfirmedByApplicant: false, + }, + { emitEvent: false } + ); + this.onOwnersUpdated.emit(); + } + private isOwnerInParcel(owner: NoticeOfIntentOwnerDto): boolean { return this.parcel.owners.some((existingOwner) => existingOwner.uuid === owner.uuid); } @@ -566,6 +583,13 @@ export class ParcelEntryComponent implements OnInit { this.ownerInput.setErrors({ required: true }); } + this.parcelForm.patchValue( + { + isConfirmedByApplicant: false, + }, + { emitEvent: false } + ); + if (this.isCrownLand && updatedArray.length > 0) { this.ownerInput.disable(); } else { From d4af35a5470c94fc30625013641524a0bb4ac73a Mon Sep 17 00:00:00 2001 From: Daniel Haselhan Date: Wed, 24 Jan 2024 15:53:05 -0800 Subject: [PATCH 3/7] Hook up error messages to correct fields * Add debug messages to token refresh --- .../proposal/pofo-proposal/pofo-proposal.component.html | 4 ++-- .../proposal/pfrs/pfrs-proposal.component.html | 4 ++-- .../src/app/services/authentication/token-refresh.service.ts | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/portal-frontend/src/app/features/applications/edit-submission/proposal/pofo-proposal/pofo-proposal.component.html b/portal-frontend/src/app/features/applications/edit-submission/proposal/pofo-proposal/pofo-proposal.component.html index ed2e8b026d..7281c39d16 100644 --- a/portal-frontend/src/app/features/applications/edit-submission/proposal/pofo-proposal/pofo-proposal.component.html +++ b/portal-frontend/src/app/features/applications/edit-submission/proposal/pofo-proposal/pofo-proposal.component.html @@ -178,11 +178,11 @@

Proposal

>
warning -
This field is required
+
This field is required
Example: Project phasing, providing landscape screening, fencing, buffering, erosion and sediment control, diff --git a/portal-frontend/src/app/features/notice-of-intents/edit-submission/proposal/pfrs/pfrs-proposal.component.html b/portal-frontend/src/app/features/notice-of-intents/edit-submission/proposal/pfrs/pfrs-proposal.component.html index 1d94352aa9..63ec3032eb 100644 --- a/portal-frontend/src/app/features/notice-of-intents/edit-submission/proposal/pfrs/pfrs-proposal.component.html +++ b/portal-frontend/src/app/features/notice-of-intents/edit-submission/proposal/pfrs/pfrs-proposal.component.html @@ -104,9 +104,9 @@

Proposal

placeholder="Type comment" > -
+
warning -
This field is required
+
This field is required
Example: Aggregate, Extraction, Placer Mining, Peat Extraction, Soil etc.
Characters left: {{ 4000 - soilTypeRemovedText.textLength }}
diff --git a/portal-frontend/src/app/services/authentication/token-refresh.service.ts b/portal-frontend/src/app/services/authentication/token-refresh.service.ts index 96e420c40a..1e599221ac 100644 --- a/portal-frontend/src/app/services/authentication/token-refresh.service.ts +++ b/portal-frontend/src/app/services/authentication/token-refresh.service.ts @@ -15,9 +15,11 @@ export class TokenRefreshService { this.authenticationService.$currentTokenUser.subscribe((user) => { if (user) { if (this.interval) { + console.log('Refresh Interval Cleared'); clearInterval(this.interval); } this.interval = window.setInterval(() => { + console.log('Refresh Interval Fired'); this.authenticationService.refreshTokens(); }, refreshTokenTime); } From 4062f98c731b5cdd883ec0f5e423966af4880511 Mon Sep 17 00:00:00 2001 From: Daniel Haselhan Date: Wed, 24 Jan 2024 16:15:58 -0800 Subject: [PATCH 4/7] Add touch all flag to soil table to display errors * Set flag in all proposal steps using the soil table --- .../proposal/naru-proposal/naru-proposal.component.html | 3 ++- .../proposal/nfu-proposal/nfu-proposal.component.html | 3 ++- .../proposal/pfrs-proposal/pfrs-proposal.component.html | 6 ++++++ .../proposal/pofo-proposal/pofo-proposal.component.html | 2 ++ .../proposal/roso-proposal/roso-proposal.component.html | 2 ++ .../proposal/pfrs/pfrs-proposal.component.html | 6 ++++++ .../proposal/pofo/pofo-proposal.component.html | 2 ++ .../proposal/roso/roso-proposal.component.html | 2 ++ .../src/app/shared/soil-table/soil-table.component.ts | 5 +++++ 9 files changed, 29 insertions(+), 2 deletions(-) diff --git a/portal-frontend/src/app/features/applications/edit-submission/proposal/naru-proposal/naru-proposal.component.html b/portal-frontend/src/app/features/applications/edit-submission/proposal/naru-proposal/naru-proposal.component.html index 2d319ee6ca..97f2f28415 100644 --- a/portal-frontend/src/app/features/applications/edit-submission/proposal/naru-proposal/naru-proposal.component.html +++ b/portal-frontend/src/app/features/applications/edit-submission/proposal/naru-proposal/naru-proposal.component.html @@ -555,8 +555,9 @@

Soil & Fill Components

diff --git a/portal-frontend/src/app/features/applications/edit-submission/proposal/nfu-proposal/nfu-proposal.component.html b/portal-frontend/src/app/features/applications/edit-submission/proposal/nfu-proposal/nfu-proposal.component.html index 45a39b296a..3d1f77e8a8 100644 --- a/portal-frontend/src/app/features/applications/edit-submission/proposal/nfu-proposal/nfu-proposal.component.html +++ b/portal-frontend/src/app/features/applications/edit-submission/proposal/nfu-proposal/nfu-proposal.component.html @@ -217,8 +217,9 @@

Soil & Fill Components

diff --git a/portal-frontend/src/app/features/applications/edit-submission/proposal/pfrs-proposal/pfrs-proposal.component.html b/portal-frontend/src/app/features/applications/edit-submission/proposal/pfrs-proposal/pfrs-proposal.component.html index b0c2855a7f..b9fdf04b5a 100644 --- a/portal-frontend/src/app/features/applications/edit-submission/proposal/pfrs-proposal/pfrs-proposal.component.html +++ b/portal-frontend/src/app/features/applications/edit-submission/proposal/pfrs-proposal/pfrs-proposal.component.html @@ -155,6 +155,7 @@

Proposal

*ngIf="!isMobile" tableHeader="Soil to be Removed" tableHeader2="Fill to be Placed" + [touchAll]="showErrors" [(data)]="removalTableData" [(data2)]="fillTableData" (dataChange)="markDirty()" @@ -163,12 +164,14 @@

Proposal

@@ -182,6 +185,7 @@

Proposal

*ngIf="!isMobile" tableHeader="Soil already Removed" tableHeader2="Fill already Placed" + [touchAll]="showErrors" [(data)]="alreadyRemovedTableData" [(data2)]="alreadyFilledTableData" (dataChange)="markDirty()" @@ -190,12 +194,14 @@

Proposal

diff --git a/portal-frontend/src/app/features/applications/edit-submission/proposal/pofo-proposal/pofo-proposal.component.html b/portal-frontend/src/app/features/applications/edit-submission/proposal/pofo-proposal/pofo-proposal.component.html index ed2e8b026d..42fd936647 100644 --- a/portal-frontend/src/app/features/applications/edit-submission/proposal/pofo-proposal/pofo-proposal.component.html +++ b/portal-frontend/src/app/features/applications/edit-submission/proposal/pofo-proposal/pofo-proposal.component.html @@ -121,6 +121,7 @@

Proposal

@@ -132,6 +133,7 @@

Proposal

> diff --git a/portal-frontend/src/app/features/applications/edit-submission/proposal/roso-proposal/roso-proposal.component.html b/portal-frontend/src/app/features/applications/edit-submission/proposal/roso-proposal/roso-proposal.component.html index b81692a4d1..ac56aa73e8 100644 --- a/portal-frontend/src/app/features/applications/edit-submission/proposal/roso-proposal/roso-proposal.component.html +++ b/portal-frontend/src/app/features/applications/edit-submission/proposal/roso-proposal/roso-proposal.component.html @@ -122,6 +122,7 @@

Proposal

@@ -133,6 +134,7 @@

Proposal

> diff --git a/portal-frontend/src/app/features/notice-of-intents/edit-submission/proposal/pfrs/pfrs-proposal.component.html b/portal-frontend/src/app/features/notice-of-intents/edit-submission/proposal/pfrs/pfrs-proposal.component.html index 1d94352aa9..19f9274f8d 100644 --- a/portal-frontend/src/app/features/notice-of-intents/edit-submission/proposal/pfrs/pfrs-proposal.component.html +++ b/portal-frontend/src/app/features/notice-of-intents/edit-submission/proposal/pfrs/pfrs-proposal.component.html @@ -210,6 +210,7 @@

Proposal

*ngIf="!isMobile" tableHeader="Soil to be Removed" tableHeader2="Fill to be Placed" + [touchAll]="showErrors" [(data)]="removalTableData" [(data2)]="fillToPlaceTableData" (dataChange)="markDirty()" @@ -218,12 +219,14 @@

Proposal

@@ -237,6 +240,7 @@

Proposal

*ngIf="!isMobile" tableHeader="Soil already Removed" tableHeader2="Fill already Placed" + [touchAll]="showErrors" [(data)]="alreadyRemovedTableData" [(data2)]="fillAlreadyPlacedTableData" (dataChange)="markDirty()" @@ -245,12 +249,14 @@

Proposal

diff --git a/portal-frontend/src/app/features/notice-of-intents/edit-submission/proposal/pofo/pofo-proposal.component.html b/portal-frontend/src/app/features/notice-of-intents/edit-submission/proposal/pofo/pofo-proposal.component.html index 1398d15443..7570b7632c 100644 --- a/portal-frontend/src/app/features/notice-of-intents/edit-submission/proposal/pofo/pofo-proposal.component.html +++ b/portal-frontend/src/app/features/notice-of-intents/edit-submission/proposal/pofo/pofo-proposal.component.html @@ -160,6 +160,7 @@

Proposal

> @@ -170,6 +171,7 @@

Proposal

diff --git a/portal-frontend/src/app/features/notice-of-intents/edit-submission/proposal/roso/roso-proposal.component.html b/portal-frontend/src/app/features/notice-of-intents/edit-submission/proposal/roso/roso-proposal.component.html index 35b874c62b..9355b507bc 100644 --- a/portal-frontend/src/app/features/notice-of-intents/edit-submission/proposal/roso/roso-proposal.component.html +++ b/portal-frontend/src/app/features/notice-of-intents/edit-submission/proposal/roso/roso-proposal.component.html @@ -144,6 +144,7 @@

Proposal

> @@ -155,6 +156,7 @@

Proposal

> diff --git a/portal-frontend/src/app/shared/soil-table/soil-table.component.ts b/portal-frontend/src/app/shared/soil-table/soil-table.component.ts index 91365a6251..cc6895e9dd 100644 --- a/portal-frontend/src/app/shared/soil-table/soil-table.component.ts +++ b/portal-frontend/src/app/shared/soil-table/soil-table.component.ts @@ -19,6 +19,7 @@ export class SoilTableComponent implements OnInit, OnChanges { @Input() tableHeader2?: string | undefined; @Input() data2?: SoilTableData; @Input() disabled = false; + @Input() touchAll = false; @Output() dataChange = new EventEmitter(); @Output() data2Change = new EventEmitter(); @@ -78,6 +79,10 @@ export class SoilTableComponent implements OnInit, OnChanges { }); }); + if (this.touchAll) { + this.form.markAllAsTouched(); + } + this.idSuffix = '-' + this.tableHeader.replace(/\s/g, '-').toLowerCase(); this.idSuffix2 = '-' + this.tableHeader2?.replace(/\s/g, '-').toLowerCase(); } From 5eaee69bc99ff5d5178929e256fb595eb98d15c5 Mon Sep 17 00:00:00 2001 From: Liam Stoddard Date: Wed, 24 Jan 2024 17:09:19 -0800 Subject: [PATCH 5/7] updated created_at date for applications and nois --- .../applications/migrate_application.py | 3 +- .../sql/application_created_date_update.sql | 3 + .../application_created_date_update_count.sql | 3 + .../applications/update_app_created_date.py | 116 ++++++++++++++++++ .../noi/notice_of_intent_migration.py | 3 + .../__init__.py | 1 + .../update_notice_of_intent_created_date.py | 116 ++++++++++++++++++ .../notice_of_intent_created_date_update.sql | 3 + ...ce_of_intent_created_date_update_count.sql | 3 + .../notice-of-intent.entity.ts | 7 ++ .../1706132206829-add_noi_created_at.ts | 15 +++ 11 files changed, 272 insertions(+), 1 deletion(-) create mode 100644 bin/migrate-oats-data/applications/sql/application_created_date_update.sql create mode 100644 bin/migrate-oats-data/applications/sql/application_created_date_update_count.sql create mode 100644 bin/migrate-oats-data/applications/update_app_created_date.py create mode 100644 bin/migrate-oats-data/noi/oats_to_alcs_notice_of_intent_table_etl/update_notice_of_intent_created_date.py create mode 100644 bin/migrate-oats-data/noi/sql/notice_of_intent_base/notice_of_intent_created_date_update.sql create mode 100644 bin/migrate-oats-data/noi/sql/notice_of_intent_base/notice_of_intent_created_date_update_count.sql create mode 100644 services/apps/alcs/src/providers/typeorm/migrations/1706132206829-add_noi_created_at.ts diff --git a/bin/migrate-oats-data/applications/migrate_application.py b/bin/migrate-oats-data/applications/migrate_application.py index 03bca32b13..fa4e2c9513 100644 --- a/bin/migrate-oats-data/applications/migrate_application.py +++ b/bin/migrate-oats-data/applications/migrate_application.py @@ -50,11 +50,12 @@ ) from .set_application_visibility import set_application_visibility - +from .update_app_created_date import update_application_created_date def process_application_etl(batch_size): process_alcs_application_prep_fields(batch_size) update_application_date_rx_all_items(batch_size) + update_application_created_date(batch_size) process_alcs_app_submissions(batch_size) update_application_submissions() insert_application_submission_review(batch_size) diff --git a/bin/migrate-oats-data/applications/sql/application_created_date_update.sql b/bin/migrate-oats-data/applications/sql/application_created_date_update.sql new file mode 100644 index 0000000000..127fc11483 --- /dev/null +++ b/bin/migrate-oats-data/applications/sql/application_created_date_update.sql @@ -0,0 +1,3 @@ +SELECT oaa.created_date, oaa.alr_application_id, a.audit_created_by, oaa.when_created +FROM oats.oats_alr_applications oaa +JOIN alcs.application a ON a.file_number = oaa.alr_application_id::TEXT \ No newline at end of file diff --git a/bin/migrate-oats-data/applications/sql/application_created_date_update_count.sql b/bin/migrate-oats-data/applications/sql/application_created_date_update_count.sql new file mode 100644 index 0000000000..ec99bf1a9d --- /dev/null +++ b/bin/migrate-oats-data/applications/sql/application_created_date_update_count.sql @@ -0,0 +1,3 @@ +SELECT count(*) +FROM oats.oats_alr_applications oaa +JOIN alcs.application a ON a.file_number = oaa.alr_application_id::TEXT \ No newline at end of file diff --git a/bin/migrate-oats-data/applications/update_app_created_date.py b/bin/migrate-oats-data/applications/update_app_created_date.py new file mode 100644 index 0000000000..fcf11d6f58 --- /dev/null +++ b/bin/migrate-oats-data/applications/update_app_created_date.py @@ -0,0 +1,116 @@ +from common import ( + setup_and_get_logger, + add_timezone_and_keep_date_part, + BATCH_UPLOAD_SIZE +) +from db import inject_conn_pool +from psycopg2.extras import RealDictCursor, execute_batch + +etl_name = "update_application_created_date" +logger = setup_and_get_logger(etl_name) + + +@inject_conn_pool +def update_application_created_date(conn=None, batch_size=BATCH_UPLOAD_SIZE): + """ + This function is responsible for updating existing the application created_at_date in ALCS. + + Args: + conn (psycopg2.extensions.connection): PostgreSQL database connection. Provided by the decorator. + batch_size (int): The number of items to process at once. Defaults to BATCH_UPLOAD_SIZE. + """ + + logger.info(f"Start {etl_name}") + with conn.cursor(cursor_factory=RealDictCursor) as cursor: + with open( + "applications/sql/application_created_date_update_count.sql", + "r", + encoding="utf-8", + ) as sql_file: + count_query = sql_file.read() + cursor.execute(count_query) + count_total = dict(cursor.fetchone())["count"] + logger.info(f"Total Application data to be updated: {count_total}") + + failed_updates_count = 0 + successful_updates_count = 0 + last_application_id = 0 + + with open( + "applications/sql/application_created_date_update.sql", + "r", + encoding="utf-8", + ) as sql_file: + query = sql_file.read() + while True: + cursor.execute( + f"""{query} + WHERE oaa.alr_application_id > {last_application_id} ORDER BY oaa.alr_application_id;""" + ) + + rows = cursor.fetchmany(batch_size) + + if not rows: + break + try: + conditions_to_be_updated_count = len(rows) + + _update_application_created_at_date(conn, batch_size, cursor, rows) + + successful_updates_count = ( + successful_updates_count + conditions_to_be_updated_count + ) + last_application_id = dict(rows[-1])["alr_application_id"] + + logger.debug( + f"retrieved/updated items count: {conditions_to_be_updated_count}; total successfully updated applications so far {successful_updates_count}; last updated application: {last_application_id}" + ) + except Exception as err: + logger.exception(err) + conn.rollback() + failed_updates_count = count_total - successful_updates_count + last_application_id = last_application_id + 1 + + logger.info( + f"Finished {etl_name}: total amount of successful updates {successful_updates_count}, total failed updates {failed_updates_count}" + ) + + +def _update_application_created_at_date(conn, batch_size, cursor, rows): + data = _prepare_oats_alr_applications_data(rows) + + if len(data) > 0: + execute_batch( + cursor, + _get_update_query(), + data, + page_size=batch_size, + ) + + conn.commit() + + +def _get_update_query(): + query = f""" + UPDATE alcs.application + SET created_at = %(date_to_insert)s + WHERE alcs.application.file_number = %(alr_application_id)s::TEXT; + """ + return query + + +def _prepare_oats_alr_applications_data(row_data_list): + data_list = [] + date_to_insert = None + for row in row_data_list: + if row.get("created_date"): + date_to_insert = row.get("created_date") + else: + date_to_insert = row.get("when_created") + mapped_row = { + "date_to_insert": add_timezone_and_keep_date_part(date_to_insert), + "alr_application_id": row.get("alr_application_id"), + } + data_list.append(mapped_row) + + return data_list diff --git a/bin/migrate-oats-data/noi/notice_of_intent_migration.py b/bin/migrate-oats-data/noi/notice_of_intent_migration.py index 776e074801..d61a9f2e79 100644 --- a/bin/migrate-oats-data/noi/notice_of_intent_migration.py +++ b/bin/migrate-oats-data/noi/notice_of_intent_migration.py @@ -28,6 +28,7 @@ from .oats_to_alcs_notice_of_intent_table_etl.notice_of_intent_rx_all_items import ( update_notice_of_intent_date_rx_all_items, ) +from .oats_to_alcs_notice_of_intent_table_etl.update_notice_of_intent_created_date import update_noi_created_date from .notice_of_intent_submissions.parcels import ( init_notice_of_intent_parcels, @@ -131,6 +132,8 @@ def process_notice_of_intent(batch_size): update_notice_of_intent_date_rx_all_items(batch_size) + update_noi_created_date(batch_size) + process_alcs_notice_of_intent_decision_date(batch_size) init_notice_of_intent_submissions(batch_size) diff --git a/bin/migrate-oats-data/noi/oats_to_alcs_notice_of_intent_table_etl/__init__.py b/bin/migrate-oats-data/noi/oats_to_alcs_notice_of_intent_table_etl/__init__.py index 3de24653c3..cc728f40db 100644 --- a/bin/migrate-oats-data/noi/oats_to_alcs_notice_of_intent_table_etl/__init__.py +++ b/bin/migrate-oats-data/noi/oats_to_alcs_notice_of_intent_table_etl/__init__.py @@ -2,3 +2,4 @@ process_alcs_notice_of_intent_base_fields, ) from .notice_of_intent_rx_all_items import update_notice_of_intent_date_rx_all_items +from .update_notice_of_intent_created_date import update_noi_created_date \ No newline at end of file diff --git a/bin/migrate-oats-data/noi/oats_to_alcs_notice_of_intent_table_etl/update_notice_of_intent_created_date.py b/bin/migrate-oats-data/noi/oats_to_alcs_notice_of_intent_table_etl/update_notice_of_intent_created_date.py new file mode 100644 index 0000000000..4ebd6ab614 --- /dev/null +++ b/bin/migrate-oats-data/noi/oats_to_alcs_notice_of_intent_table_etl/update_notice_of_intent_created_date.py @@ -0,0 +1,116 @@ +from common import ( + setup_and_get_logger, + add_timezone_and_keep_date_part, + BATCH_UPLOAD_SIZE +) +from db import inject_conn_pool +from psycopg2.extras import RealDictCursor, execute_batch + +etl_name = "update_notice_of_intent_created_date" +logger = setup_and_get_logger(etl_name) + + +@inject_conn_pool +def update_noi_created_date(conn=None, batch_size=BATCH_UPLOAD_SIZE): + """ + This function is responsible for updating existing the notice_of_intent created_at_date in ALCS. + + Args: + conn (psycopg2.extensions.connection): PostgreSQL database connection. Provided by the decorator. + batch_size (int): The number of items to process at once. Defaults to BATCH_UPLOAD_SIZE. + """ + + logger.info(f"Start {etl_name}") + with conn.cursor(cursor_factory=RealDictCursor) as cursor: + with open( + "noi/sql/notice_of_intent_base/notice_of_intent_created_date_update_count.sql", + "r", + encoding="utf-8", + ) as sql_file: + count_query = sql_file.read() + cursor.execute(count_query) + count_total = dict(cursor.fetchone())["count"] + logger.info(f"Total Notice of Intent data to be updated: {count_total}") + + failed_updates_count = 0 + successful_updates_count = 0 + last_application_id = 0 + + with open( + "noi/sql/notice_of_intent_base/notice_of_intent_created_date_update.sql", + "r", + encoding="utf-8", + ) as sql_file: + query = sql_file.read() + while True: + cursor.execute( + f"""{query} + WHERE oaa.alr_application_id > {last_application_id} ORDER BY oaa.alr_application_id;""" + ) + + rows = cursor.fetchmany(batch_size) + + if not rows: + break + try: + conditions_to_be_updated_count = len(rows) + + _update_notice_of_intent_created_at_date(conn, batch_size, cursor, rows) + + successful_updates_count = ( + successful_updates_count + conditions_to_be_updated_count + ) + last_application_id = dict(rows[-1])["alr_application_id"] + + logger.debug( + f"retrieved/updated items count: {conditions_to_be_updated_count}; total successfully updated notice of intents so far {successful_updates_count}; last updated notice of intent: {last_application_id}" + ) + except Exception as err: + logger.exception(err) + conn.rollback() + failed_updates_count = count_total - successful_updates_count + last_application_id = last_application_id + 1 + + logger.info( + f"Finished {etl_name}: total amount of successful updates {successful_updates_count}, total failed updates {failed_updates_count}" + ) + + +def _update_notice_of_intent_created_at_date(conn, batch_size, cursor, rows): + data = _prepare_oats_alr_notice_of_intents_data(rows) + + if len(data) > 0: + execute_batch( + cursor, + _get_update_query(), + data, + page_size=batch_size, + ) + + conn.commit() + + +def _get_update_query(): + query = f""" + UPDATE alcs.notice_of_intent + SET created_at = %(date_to_insert)s + WHERE alcs.notice_of_intent.file_number = %(alr_application_id)s::TEXT; + """ + return query + + +def _prepare_oats_alr_notice_of_intents_data(row_data_list): + data_list = [] + date_to_insert = None + for row in row_data_list: + if row.get("created_date"): + date_to_insert = row.get("created_date") + else: + date_to_insert = row.get("when_created") + mapped_row = { + "date_to_insert": add_timezone_and_keep_date_part(date_to_insert), + "alr_application_id": row.get("alr_application_id"), + } + data_list.append(mapped_row) + + return data_list diff --git a/bin/migrate-oats-data/noi/sql/notice_of_intent_base/notice_of_intent_created_date_update.sql b/bin/migrate-oats-data/noi/sql/notice_of_intent_base/notice_of_intent_created_date_update.sql new file mode 100644 index 0000000000..761871311e --- /dev/null +++ b/bin/migrate-oats-data/noi/sql/notice_of_intent_base/notice_of_intent_created_date_update.sql @@ -0,0 +1,3 @@ +SELECT oaa.created_date, oaa.alr_application_id, oaa.when_created +FROM oats.oats_alr_applications oaa +JOIN alcs.notice_of_intent noi ON noi.file_number = oaa.alr_application_id::TEXT \ No newline at end of file diff --git a/bin/migrate-oats-data/noi/sql/notice_of_intent_base/notice_of_intent_created_date_update_count.sql b/bin/migrate-oats-data/noi/sql/notice_of_intent_base/notice_of_intent_created_date_update_count.sql new file mode 100644 index 0000000000..4ea5708d7e --- /dev/null +++ b/bin/migrate-oats-data/noi/sql/notice_of_intent_base/notice_of_intent_created_date_update_count.sql @@ -0,0 +1,3 @@ +SELECT count(*) +FROM oats.oats_alr_applications oaa +JOIN alcs.notice_of_intent noi ON noi.file_number = oaa.alr_application_id::TEXT \ No newline at end of file diff --git a/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent.entity.ts b/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent.entity.ts index c399a24e97..7ba5440fe5 100644 --- a/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent.entity.ts +++ b/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent.entity.ts @@ -227,6 +227,13 @@ export class NoticeOfIntent extends Base { }) proposalEndDate2?: Date | null; + @Column({ + type: 'timestamptz', + comment: 'The date at which the noi was created in OATS', + nullable: true, + }) + createdAt?: Date | null; + @ManyToOne(() => NoticeOfIntentType, { nullable: false, }) diff --git a/services/apps/alcs/src/providers/typeorm/migrations/1706132206829-add_noi_created_at.ts b/services/apps/alcs/src/providers/typeorm/migrations/1706132206829-add_noi_created_at.ts new file mode 100644 index 0000000000..fbccd25620 --- /dev/null +++ b/services/apps/alcs/src/providers/typeorm/migrations/1706132206829-add_noi_created_at.ts @@ -0,0 +1,15 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class AddNoiCreatedAt1706132206829 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "alcs"."notice_of_intent" ADD "created_at" TIMESTAMP WITH TIME ZONE`, + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "alcs"."notice_of_intent" DROP COLUMN "created_at"`, + ); + } +} From 08d1865c99c977213e9ae9c4d531373fecf9e307 Mon Sep 17 00:00:00 2001 From: Daniel Haselhan Date: Thu, 25 Jan 2024 10:03:38 -0800 Subject: [PATCH 6/7] Update Logic for OATS type Apps * Previously we only had ALCS and Applicant, now we have OATS * We want to show all V2 features for OATS applications --- .../app/features/application/decision/decision.component.html | 2 +- .../src/app/features/application/intake/intake.component.html | 4 ++-- .../app/features/application/proposal/proposal.component.html | 2 +- .../notice-of-intent/proposal/proposal.component.html | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/alcs-frontend/src/app/features/application/decision/decision.component.html b/alcs-frontend/src/app/features/application/decision/decision.component.html index 22436d8883..51c5de2e2c 100644 --- a/alcs-frontend/src/app/features/application/decision/decision.component.html +++ b/alcs-frontend/src/app/features/application/decision/decision.component.html @@ -1,6 +1,6 @@
- +
diff --git a/alcs-frontend/src/app/features/application/intake/intake.component.html b/alcs-frontend/src/app/features/application/intake/intake.component.html index 3d16d4982b..fda4559697 100644 --- a/alcs-frontend/src/app/features/application/intake/intake.component.html +++ b/alcs-frontend/src/app/features/application/intake/intake.component.html @@ -8,7 +8,7 @@
Submitted to ALC
[required]="true" > -
+
Payment
@@ -41,7 +41,7 @@
Payment
-
+
Payment Date
Application Prep
-
+
Proposal Components - {{ application?.type?.label }}
diff --git a/alcs-frontend/src/app/features/notice-of-intent/proposal/proposal.component.html b/alcs-frontend/src/app/features/notice-of-intent/proposal/proposal.component.html index aeed51b1ba..400f9c73a4 100644 --- a/alcs-frontend/src/app/features/notice-of-intent/proposal/proposal.component.html +++ b/alcs-frontend/src/app/features/notice-of-intent/proposal/proposal.component.html @@ -1,5 +1,5 @@

Notice of Intent Prep

-
+
Proposal Components - {{ noticeOfIntent?.type?.label }}
From 6ea0c48f042239df8ae5bdbf097498c3b007b42f Mon Sep 17 00:00:00 2001 From: mhuseinov <61513701+mhuseinov@users.noreply.github.com> Date: Thu, 25 Jan 2024 11:35:49 -0800 Subject: [PATCH 7/7] update mapping for chair review required and draft and was released flags (#1330) --- .../applications/decisions/application_decisions_init.py | 5 ++++- .../noi/noi_decisions/notice_of_intent_decisions_init.py | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/migrate-oats-data/applications/decisions/application_decisions_init.py b/bin/migrate-oats-data/applications/decisions/application_decisions_init.py index b9d2e86268..458e572d06 100644 --- a/bin/migrate-oats-data/applications/decisions/application_decisions_init.py +++ b/bin/migrate-oats-data/applications/decisions/application_decisions_init.py @@ -112,7 +112,7 @@ def _get_insert_query(): %(created_at)s, %(date)s, %(decision_description)s, - false, + true, false, %(outcome_code)s, %(rescinded_comment)s, @@ -133,6 +133,9 @@ def _get_insert_query(): rescinded_comment = COALESCE(EXCLUDED.rescinded_comment, alcs.application_decision.rescinded_comment), rescinded_date = COALESCE(EXCLUDED.rescinded_date, alcs.application_decision.rescinded_date), is_subject_to_conditions = COALESCE(EXCLUDED.is_subject_to_conditions, alcs.application_decision.is_subject_to_conditions), + was_released = True, + is_draft = False, + chair_review_required = COALESCE(EXCLUDED.chair_review_required, true), oats_alr_appl_decision_id = EXCLUDED.oats_alr_appl_decision_id; """ return query diff --git a/bin/migrate-oats-data/noi/noi_decisions/notice_of_intent_decisions_init.py b/bin/migrate-oats-data/noi/noi_decisions/notice_of_intent_decisions_init.py index f6252e78d6..81eb9d0646 100644 --- a/bin/migrate-oats-data/noi/noi_decisions/notice_of_intent_decisions_init.py +++ b/bin/migrate-oats-data/noi/noi_decisions/notice_of_intent_decisions_init.py @@ -2,7 +2,7 @@ OATS_ETL_USER, setup_and_get_logger, add_timezone_and_keep_date_part, - BATCH_UPLOAD_SIZE + BATCH_UPLOAD_SIZE, ) from db import inject_conn_pool from psycopg2.extras import RealDictCursor, execute_batch @@ -133,6 +133,8 @@ def _get_insert_query(): rescinded_comment = COALESCE(EXCLUDED.rescinded_comment, alcs.notice_of_intent_decision.rescinded_comment), rescinded_date = COALESCE(EXCLUDED.rescinded_date, alcs.notice_of_intent_decision.rescinded_date), is_subject_to_conditions = COALESCE(EXCLUDED.is_subject_to_conditions, alcs.notice_of_intent_decision.is_subject_to_conditions), + was_released = True, + is_draft = False, oats_alr_appl_decision_id = EXCLUDED.oats_alr_appl_decision_id; """ return query