Skip to content

Commit 1a74a0f

Browse files
Update parking_cycle_hangar_allocation_update.py (#2049)
* Update parking_cycle_hangar_allocation_update.py add check for unsubscribed emails * add parking prefix back to the tables --------- Co-authored-by: Tian Chen <[email protected]>
1 parent 00b3809 commit 1a74a0f

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

scripts/jobs/parking/parking_cycle_hangar_allocation_update.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
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
4243
******************************************************************************************************************/
4344
/*******************************************************************************
4445
Create a comparison between Toms Hangar list and EStreet
@@ -76,6 +77,14 @@
7677
UNION ALL
7778
SELECT 'new_only','new_only','new_only'),
7879
80+
/*** 08-01-2025 collect the unsubscribed_emails ***/
81+
unsubscribed_emails as (
82+
SELECT *,
83+
ROW_NUMBER() OVER ( PARTITION BY email_address ORDER BY email_address DESC) row1
84+
FROM "parking-raw-zone".parking_parking_cycle_hangar_unsubscribed_emails
85+
WHERE import_date = (select max(import_date)
86+
from "parking-raw-zone".parking_cycle_hangar_unsubscribed_emails)),
87+
7988
/*******************************************************************************
8089
Obtain the latest Waiting List History
8190
*******************************************************************************/
@@ -106,17 +115,20 @@
106115
FROM "dataplatform-stg-liberator-raw-zone".liberator_permit_llpg
107116
WHERE import_Date = format_datetime(current_date, 'yyyyMMdd')),
108117
/*******************************************************************************
109-
04/12/2024 - interim cycle hangar waiting list
118+
04/12/2024 - interim cycle hangar waiting list remove unsubscribed emails
110119
*******************************************************************************/
111120
Interim_Wait as (
112-
SELECT * from "parking-raw-zone".interim_cycle_wait_list
113-
WHERE import_date = (select max(import_date)
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)
114125
from "parking-raw-zone".interim_cycle_wait_list)),
115-
126+
116127
/*** count the number on the waiting list by hangar ***/
117128
Interim_Wait_summary as (
118129
SELECT hanger_id, count(*) as Interim_Wait_Total
119130
FROM Interim_Wait
131+
WHERE email_address is NULL
120132
GROUP BY hanger_id),
121133
/*******************************************************************************
122134
Cycle Hangar allocation details

0 commit comments

Comments
 (0)