From 3f1a9c0e07e80acea600b0c94f341bf7506c2b63 Mon Sep 17 00:00:00 2001 From: mhuseinov <61513701+mhuseinov@users.noreply.github.com> Date: Fri, 2 Feb 2024 09:06:38 -0800 Subject: [PATCH] attach alias name to organization name (#1375) --- .../submissions/parcels/owners/application_owners.py | 8 +++++++- .../primary_contact/application_primary_contact.py | 7 ++++++- .../submissions/sql/parcels/owners/application_owner.sql | 1 + .../primary_contact/application_primary_contact.sql | 2 ++ .../parcels/owners/notice_of_intent_owners.py | 8 +++++++- .../primary_contacts/notice_of_intent_primary_contact.py | 8 +++++++- .../parcels/owners/notice_of_intent_owner.sql | 1 + .../primary_contact/notice_of_intent_primary_contact.sql | 2 ++ 8 files changed, 33 insertions(+), 4 deletions(-) diff --git a/bin/migrate-oats-data/applications/submissions/parcels/owners/application_owners.py b/bin/migrate-oats-data/applications/submissions/parcels/owners/application_owners.py index 02f8dc8d50..70012337cc 100644 --- a/bin/migrate-oats-data/applications/submissions/parcels/owners/application_owners.py +++ b/bin/migrate-oats-data/applications/submissions/parcels/owners/application_owners.py @@ -120,7 +120,7 @@ def _map_data(row, insert_index): return { "first_name": _get_name(row), "last_name": row["last_name"], - "organization_name": row["organization_name"], + "organization_name": _get_organization_name(row), "application_submission_uuid": row["application_submission_uuid"], "email": row["email_address"], "phone_number": row.get("phone_number", "cell_phone_number"), @@ -132,6 +132,12 @@ def _map_data(row, insert_index): } +def _get_organization_name(row): + return ( + f"{row.get('organization_name','')} {row.get('alias_name', '')}".strip() or None + ) + + def _get_name(row): first_name = row.get("first_name", None) middle_name = row.get("middle_name", None) diff --git a/bin/migrate-oats-data/applications/submissions/parcels/primary_contact/application_primary_contact.py b/bin/migrate-oats-data/applications/submissions/parcels/primary_contact/application_primary_contact.py index baa278a368..38360e81b1 100644 --- a/bin/migrate-oats-data/applications/submissions/parcels/primary_contact/application_primary_contact.py +++ b/bin/migrate-oats-data/applications/submissions/parcels/primary_contact/application_primary_contact.py @@ -111,7 +111,7 @@ def _map_data(row): return { "first_name": _get_name(row), "last_name": row["last_name"], - "organization_name": row["organization_name"], + "organization_name": _get_organization_name(row), "application_submission_uuid": row["application_submission_uuid"], "email": row["email_address"], "phone_number": row.get("phone_number", "cell_phone_number"), @@ -120,6 +120,11 @@ def _map_data(row): "audit_created_by": OATS_ETL_USER, } +def _get_organization_name(row): + return ( + f"{row.get('organization_name','')} {row.get('alias_name', '')}".strip() or None + ) + def _get_name(row): first_name = row.get("first_name", "") diff --git a/bin/migrate-oats-data/applications/submissions/sql/parcels/owners/application_owner.sql b/bin/migrate-oats-data/applications/submissions/sql/parcels/owners/application_owner.sql index 00d57d26cb..b729ddd595 100644 --- a/bin/migrate-oats-data/applications/submissions/sql/parcels/owners/application_owner.sql +++ b/bin/migrate-oats-data/applications/submissions/sql/parcels/owners/application_owner.sql @@ -8,6 +8,7 @@ SELECT osp.subject_property_id, op.middle_name, oo.organization_id, oo.organization_name, + oo.alias_name, opo.phone_number, opo.cell_phone_number, opo.email_address, diff --git a/bin/migrate-oats-data/applications/submissions/sql/parcels/primary_contact/application_primary_contact.sql b/bin/migrate-oats-data/applications/submissions/sql/parcels/primary_contact/application_primary_contact.sql index b9231edc4e..04d70fa860 100644 --- a/bin/migrate-oats-data/applications/submissions/sql/parcels/primary_contact/application_primary_contact.sql +++ b/bin/migrate-oats-data/applications/submissions/sql/parcels/primary_contact/application_primary_contact.sql @@ -6,6 +6,7 @@ WITH ordered_parties AS ( op.last_name, oo.organization_id, oo.organization_name, + oo.alias_name, opo.phone_number, opo.cell_phone_number, opo.email_address, @@ -43,6 +44,7 @@ parties_with_submission_uuid as ( last_name, organization_id, organization_name, + alias_name, phone_number, cell_phone_number, email_address, diff --git a/bin/migrate-oats-data/noi/notice_of_intent_submissions/parcels/owners/notice_of_intent_owners.py b/bin/migrate-oats-data/noi/notice_of_intent_submissions/parcels/owners/notice_of_intent_owners.py index 3a4e460d5d..eb587ae179 100644 --- a/bin/migrate-oats-data/noi/notice_of_intent_submissions/parcels/owners/notice_of_intent_owners.py +++ b/bin/migrate-oats-data/noi/notice_of_intent_submissions/parcels/owners/notice_of_intent_owners.py @@ -120,7 +120,7 @@ def _map_data(row, insert_index): return { "first_name": _get_name(row), "last_name": row["last_name"], - "organization_name": row["organization_name"], + "organization_name": _get_organization_name(row), "notice_of_intent_submission_uuid": row["notice_of_intent_submission_uuid"], "email": row["email_address"], "phone_number": row.get("phone_number", "cell_phone_number"), @@ -132,6 +132,12 @@ def _map_data(row, insert_index): } +def _get_organization_name(row): + return ( + f"{row.get('organization_name','')} {row.get('alias_name', '')}".strip() or None + ) + + def _get_name(row): first_name = row.get("first_name", None) middle_name = row.get("middle_name", None) diff --git a/bin/migrate-oats-data/noi/notice_of_intent_submissions/parcels/primary_contacts/notice_of_intent_primary_contact.py b/bin/migrate-oats-data/noi/notice_of_intent_submissions/parcels/primary_contacts/notice_of_intent_primary_contact.py index 7c01f85ebd..57c845f655 100644 --- a/bin/migrate-oats-data/noi/notice_of_intent_submissions/parcels/primary_contacts/notice_of_intent_primary_contact.py +++ b/bin/migrate-oats-data/noi/notice_of_intent_submissions/parcels/primary_contacts/notice_of_intent_primary_contact.py @@ -111,7 +111,7 @@ def _map_data(row): return { "first_name": _get_name(row), "last_name": row["last_name"], - "organization_name": row["organization_name"], + "organization_name": _get_organization_name(row), "notice_of_intent_submission_uuid": row["notice_of_intent_submission_uuid"], "email": row["email_address"], "phone_number": row.get("phone_number", "cell_phone_number"), @@ -121,6 +121,12 @@ def _map_data(row): } +def _get_organization_name(row): + return ( + f"{row.get('organization_name','')} {row.get('alias_name', '')}".strip() or None + ) + + def _get_name(row): first_name = row.get("first_name", "") middle_name = row.get("middle_name", "") diff --git a/bin/migrate-oats-data/noi/sql/notice_of_intent_submission/parcels/owners/notice_of_intent_owner.sql b/bin/migrate-oats-data/noi/sql/notice_of_intent_submission/parcels/owners/notice_of_intent_owner.sql index 500af26313..31156e7895 100644 --- a/bin/migrate-oats-data/noi/sql/notice_of_intent_submission/parcels/owners/notice_of_intent_owner.sql +++ b/bin/migrate-oats-data/noi/sql/notice_of_intent_submission/parcels/owners/notice_of_intent_owner.sql @@ -7,6 +7,7 @@ SELECT osp.subject_property_id, op.middle_name, oo.organization_id, oo.organization_name, + oo.alias_name, opo.phone_number, opo.cell_phone_number, opo.email_address, diff --git a/bin/migrate-oats-data/noi/sql/notice_of_intent_submission/primary_contact/notice_of_intent_primary_contact.sql b/bin/migrate-oats-data/noi/sql/notice_of_intent_submission/primary_contact/notice_of_intent_primary_contact.sql index d35bdbb168..bf3efe2077 100644 --- a/bin/migrate-oats-data/noi/sql/notice_of_intent_submission/primary_contact/notice_of_intent_primary_contact.sql +++ b/bin/migrate-oats-data/noi/sql/notice_of_intent_submission/primary_contact/notice_of_intent_primary_contact.sql @@ -6,6 +6,7 @@ WITH ordered_parties AS ( op.last_name, oo.organization_id, oo.organization_name, + oo.alias_name, opo.phone_number, opo.cell_phone_number, opo.email_address, @@ -43,6 +44,7 @@ parties_with_submission_uuid as ( last_name, organization_id, organization_name, + alias_name, phone_number, cell_phone_number, email_address,