Skip to content

Commit

Permalink
Bugfix/alcs 1550 duplicated parcels (#1342)
Browse files Browse the repository at this point in the history
Instead of using application_id (file_number) use application_component_id (submission_id)
  • Loading branch information
mhuseinov authored Jan 26, 2024
1 parent 3eaca90 commit 8b063fd
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
WITH appl_components_grouped AS (
SELECT oaa.alr_application_id
SELECT *
FROM oats.alcs_etl_applications_nois oaa
WHERE oaa.application_class_code IN ('LOA', 'BLK', 'SCH', 'NAN')
and oaa.alr_change_code <> 'SRW'
Expand All @@ -26,5 +26,5 @@ SELECT oaa.alr_application_id,
oaa.legacy_application_nbr,
oaa.submitted_to_alc_date
FROM appl_components_grouped acg
JOIN oats.oats_alr_appl_components oaac ON oaac.alr_application_id = acg.alr_application_id
JOIN oats.oats_alr_appl_components oaac ON oaac.alr_appl_component_id = acg.alr_appl_component_id
JOIN oats.oats_alr_applications oaa ON oaa.alr_application_id = acg.alr_application_id
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def init_application_parcels(conn=None, batch_size=BATCH_UPLOAD_SIZE):
last_subject_property_id = 0

with open(
"applications/submissions/sql/parcels/application_parcels_insert.sql",
"applications/submissions/sql/parcels/application_parcels_insert.sql",
"r",
encoding="utf-8",
) as sql_file:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
WITH appl_components_grouped AS (
SELECT oaa.alr_application_id
SELECT *
FROM oats.alcs_etl_applications_nois oaa
WHERE oaa.application_class_code IN ('LOA', 'BLK', 'SCH', 'NAN')
and oaa.alr_change_code <> 'SRW'
Expand Down Expand Up @@ -36,7 +36,7 @@ SELECT aa.file_number,
oa.ministry_notice_ind
FROM appl_components_grouped acg
LEFT JOIN alcs.application aa ON aa.file_number = acg.alr_application_id::TEXT
JOIN oats.oats_alr_appl_components oc ON acg.alr_application_id = oc.alr_application_id
JOIN oats.oats_alr_appl_components oc ON acg.alr_appl_component_id = oc.alr_appl_component_id
JOIN oats.oats_alr_applications oa ON acg.alr_application_id = oa.alr_application_id
LEFT JOIN alcs."user" au ON oa.created_guid = au.bceid_guid
WHERE aa.type_code <> 'SRW'
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- this script selects difference between fields that do not require mapping
WITH apps_with_one_or_zero_component_only AS (
SELECT oaa.alr_application_id
SELECT *
FROM oats.alcs_etl_applications_nois oaa
WHERE oaa.application_class_code IN ('LOA', 'BLK', 'SCH', 'NAN')
and oaa.alr_change_code <> 'SRW'
Expand Down Expand Up @@ -30,7 +30,7 @@ oats_app_data AS (
JOIN oats.oats_alr_applications oaa ON oaa.alr_application_id = oats_asub.alr_application_id
AND oaa.application_class_code in ('LOA', 'BLK', 'SCH', 'NAN')
AND oaac.alr_change_code <> 'SRW'
JOIN oats.oats_alr_appl_components oaac ON oaac.alr_application_id = oats_asub.alr_application_id
JOIN oats.oats_alr_appl_components oaac ON oaac.alr_appl_component_id = oats_asub.alr_appl_component_id
)
SELECT oats_app.alr_application_id,
as2.purpose,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
WITH nois_with_one_or_zero_component_only AS (
SELECT oaa.alr_application_id
SELECT *
FROM oats.alcs_etl_applications_nois oaa
WHERE oaa.application_class_code = 'NOI'
and oaa.alr_change_code <> 'SRW'
Expand All @@ -9,4 +9,4 @@ FROM alcs.notice_of_intent noi
JOIN nois_with_one_or_zero_component_only oats_noi ON oats_noi.alr_application_id::TEXT = noi.file_number
JOIN oats.oats_alr_applications oaa ON oaa.alr_application_id = oats_noi.alr_application_id
AND oaa.application_class_code = 'NOI'
JOIN oats.oats_alr_appl_components oaac ON oaac.alr_application_id = oats_noi.alr_application_id;
JOIN oats.oats_alr_appl_components oaac ON oaac.alr_appl_component_id = oats_noi.alr_appl_component_id;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
WITH nois_with_one_or_zero_component_only AS (
SELECT oaa.alr_application_id
SELECT *
FROM oats.alcs_etl_applications_nois oaa
WHERE oaa.application_class_code = 'NOI'
and oaa.alr_change_code <> 'SRW'
Expand All @@ -25,4 +25,4 @@ FROM alcs.notice_of_intent noi
JOIN nois_with_one_or_zero_component_only oats_noi ON oats_noi.alr_application_id::TEXT = noi.file_number
JOIN oats.oats_alr_applications oaa ON oaa.alr_application_id = oats_noi.alr_application_id
AND oaa.application_class_code = 'NOI'
JOIN oats.oats_alr_appl_components oaac ON oaac.alr_application_id = oats_noi.alr_application_id
JOIN oats.oats_alr_appl_components oaac ON oaac.alr_appl_component_id = oats_noi.alr_appl_component_id
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- this script selects difference between fields that do not require mapping
WITH nois_with_one_or_zero_component_only AS (
SELECT oaa.alr_application_id
SELECT *
FROM oats.alcs_etl_applications_nois oaa
WHERE oaa.application_class_code = 'NOI'
and oaa.alr_change_code <> 'SRW'
Expand All @@ -23,7 +23,7 @@ oats_noi_data AS (
JOIN nois_with_one_or_zero_component_only oats_noi ON oats_noi.alr_application_id::TEXT = noi.file_number
JOIN oats.oats_alr_applications oaa ON oaa.alr_application_id = oats_noi.alr_application_id
AND oaa.application_class_code = 'NOI'
JOIN oats.oats_alr_appl_components oaac ON oaac.alr_application_id = oats_noi.alr_application_id
JOIN oats.oats_alr_appl_components oaac ON oaac.alr_appl_component_id = oats_noi.alr_appl_component_id
)
SELECT oats_noi.alr_application_id,
noi.alr_area,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
WITH noi_components_grouped AS (
SELECT oaa.alr_application_id
SELECT *
FROM oats.alcs_etl_applications_nois oaa
WHERE oaa.application_class_code = 'NOI'
and oaa.alr_change_code <> 'SRW'
Expand All @@ -14,4 +14,4 @@ SELECT noi.file_number,
oc.alr_appl_component_id
FROM noi_components_grouped noig
LEFT JOIN alcs.notice_of_intent noi ON noi.file_number = noig.alr_application_id::TEXT
JOIN oats.oats_alr_appl_components oc ON noig.alr_application_id = oc.alr_application_id
JOIN oats.oats_alr_appl_components oc ON noig.alr_appl_component_id = oc.alr_appl_component_id

0 comments on commit 8b063fd

Please sign in to comment.