Skip to content

Commit 791b701

Browse files
authored
Update parking_cycle_hangar_allocation_update.py
Add opt-in review of emails
1 parent fcadd7d commit 791b701

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

scripts/jobs/parking/parking_cycle_hangar_allocation_update.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
26/09/2024 - add hangar location.
4040
04/10/2024 - add additional checks for the waiting list
4141
04/12/2024 - collect the interim cycle hangar waiting list
42-
08/01/2025 - Amend to remove records from the waiting list that have been unsuscribed
42+
06/01/2025 - Amend to remove records from the waiting list that have been unsuscribed
43+
13/01/2025 - add opt-in data
4344
******************************************************************************************************************/
4445
/*******************************************************************************
4546
Create a comparison between Toms Hangar list and EStreet
@@ -85,6 +86,18 @@
8586
WHERE import_date = (select max(import_date)
8687
from "parking-raw-zone".parking_parking_cycle_hangar_unsubscribed_emails)),
8788
89+
/*** 13/01/2025 added ***/
90+
opt_in_emails as (
91+
SELECT
92+
please_note_your_email_address_has_been_prefilled_based_on_your_account_registration_please_do_not_amend_this as email,
93+
please_select_one_of_the_options_below,
94+
ROW_NUMBER() OVER ( PARTITION BY please_note_your_email_address_has_been_prefilled_based_on_your_account_registration_please_do_not_amend_this
95+
ORDER BY please_note_your_email_address_has_been_prefilled_based_on_your_account_registration_please_do_not_amend_this
96+
DESC) row1
97+
FROM "parking-raw-zone".parking_parking_opt_in_form_responses
98+
WHERE import_date = (select max(import_date)
99+
from "parking-raw-zone".parking_parking_opt_in_form_responses)
100+
AND please_select_one_of_the_options_below like 'No.%'),
88101
/*******************************************************************************
89102
Obtain the latest Waiting List History
90103
*******************************************************************************/
@@ -116,14 +129,22 @@
116129
WHERE import_Date = format_datetime(current_date, 'yyyyMMdd')),
117130
/*******************************************************************************
118131
04/12/2024 - interim cycle hangar waiting list remove unsubscribed emails
132+
13/01/2025 - add review of opt in(OUT) email addresses
119133
*******************************************************************************/
120134
Interim_Wait as (
121-
SELECT A.*, E.email_address from "parking-raw-zone".interim_cycle_wait_list as A
122-
LEFT JOIN unsubscribed_emails as E ON upper(ltrim(rtrim(A.email))) =
123-
upper(ltrim(rtrim(E.email_address)))
124-
WHERE A.import_date = (select max(import_date)
135+
SELECT A.*,
136+
CASE
137+
When length(E.email_address) > 1 Then E.email_address
138+
When length(F.email)> 1 Then F.email
139+
END as email_address
140+
FROM "parking-raw-zone".interim_cycle_wait_list as A
141+
LEFT JOIN unsubscribed_emails as E ON upper(ltrim(rtrim(A.email))) =
142+
upper(ltrim(rtrim(E.email_address))) AND E.row1 = 1
143+
LEFT JOIN opt_in_emails as F ON upper(ltrim(rtrim(A.email))) =
144+
upper(ltrim(rtrim(F.email))) AND F.row1 = 1
145+
WHERE A.import_date = (select max(import_date)
125146
from "parking-raw-zone".interim_cycle_wait_list)),
126-
147+
127148
/*** count the number on the waiting list by hangar ***/
128149
Interim_Wait_summary as (
129150
SELECT hanger_id, count(*) as Interim_Wait_Total

0 commit comments

Comments
 (0)