From 33b426778791facc81bf3329d8d063db7ee778f5 Mon Sep 17 00:00:00 2001 From: barnesm707 <87021322+barnesm707@users.noreply.github.com> Date: Thu, 9 Jan 2025 15:29:58 +0000 Subject: [PATCH 1/2] Update parking_cycle_hangar_allocation_update.py add check for unsubscribed emails --- .../parking_cycle_hangar_allocation_update.py | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/scripts/jobs/parking/parking_cycle_hangar_allocation_update.py b/scripts/jobs/parking/parking_cycle_hangar_allocation_update.py index c9131cec6..00f4795f3 100644 --- a/scripts/jobs/parking/parking_cycle_hangar_allocation_update.py +++ b/scripts/jobs/parking/parking_cycle_hangar_allocation_update.py @@ -39,6 +39,7 @@ 26/09/2024 - add hangar location. 04/10/2024 - add additional checks for the waiting list 04/12/2024 - collect the interim cycle hangar waiting list +08/01/2025 - Amend to remove records from the waiting list that have been unsuscribed ******************************************************************************************************************/ /******************************************************************************* Create a comparison between Toms Hangar list and EStreet @@ -54,7 +55,7 @@ When asset_no like '%Bikehangar_1435%' Then 'Bikehangar_H1435' ELSE replace(asset_no, ' ','_') END as HangarID - from "parking-raw-zone".parking_parking_ops_cycle_hangar_list + from "parking-raw-zone".parking_ops_cycle_hangar_list WHERE import_Date = format_datetime(current_date, 'yyyyMMdd') AND asset_type = 'Hangar' AND lower(status) IN ('active', 'estate locked gate issue') /** 20-08-2024 add check for blank records **/ @@ -76,6 +77,14 @@ UNION ALL SELECT 'new_only','new_only','new_only'), +/*** 08-01-2025 collect the unsubscribed_emails ***/ +unsubscribed_emails as ( + SELECT *, + ROW_NUMBER() OVER ( PARTITION BY email_address ORDER BY email_address DESC) row1 + FROM "parking-raw-zone".parking_cycle_hangar_unsubscribed_emails + WHERE import_date = (select max(import_date) + from "parking-raw-zone".parking_cycle_hangar_unsubscribed_emails)), + /******************************************************************************* Obtain the latest Waiting List History *******************************************************************************/ @@ -106,17 +115,20 @@ FROM "dataplatform-stg-liberator-raw-zone".liberator_permit_llpg WHERE import_Date = format_datetime(current_date, 'yyyyMMdd')), /******************************************************************************* -04/12/2024 - interim cycle hangar waiting list +04/12/2024 - interim cycle hangar waiting list remove unsubscribed emails *******************************************************************************/ Interim_Wait as ( - SELECT * from "parking-raw-zone".interim_cycle_wait_list - WHERE import_date = (select max(import_date) + SELECT A.*, E.email_address from "parking-raw-zone".interim_cycle_wait_list as A + LEFT JOIN unsubscribed_emails as E ON upper(ltrim(rtrim(A.email))) = + upper(ltrim(rtrim(E.email_address))) + WHERE A.import_date = (select max(import_date) from "parking-raw-zone".interim_cycle_wait_list)), - + /*** count the number on the waiting list by hangar ***/ Interim_Wait_summary as ( SELECT hanger_id, count(*) as Interim_Wait_Total FROM Interim_Wait + WHERE email_address is NULL GROUP BY hanger_id), /******************************************************************************* Cycle Hangar allocation details From 42f74fedb4c705bdbcdcd498eda6aad4422613a4 Mon Sep 17 00:00:00 2001 From: Tian Chen <38001883+Tian-2017@users.noreply.github.com> Date: Thu, 9 Jan 2025 16:03:54 +0000 Subject: [PATCH 2/2] add parking prefix back to the tables --- .../jobs/parking/parking_cycle_hangar_allocation_update.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/jobs/parking/parking_cycle_hangar_allocation_update.py b/scripts/jobs/parking/parking_cycle_hangar_allocation_update.py index 00f4795f3..ec833e0a5 100644 --- a/scripts/jobs/parking/parking_cycle_hangar_allocation_update.py +++ b/scripts/jobs/parking/parking_cycle_hangar_allocation_update.py @@ -55,7 +55,7 @@ When asset_no like '%Bikehangar_1435%' Then 'Bikehangar_H1435' ELSE replace(asset_no, ' ','_') END as HangarID - from "parking-raw-zone".parking_ops_cycle_hangar_list + from "parking-raw-zone".parking_parking_ops_cycle_hangar_list WHERE import_Date = format_datetime(current_date, 'yyyyMMdd') AND asset_type = 'Hangar' AND lower(status) IN ('active', 'estate locked gate issue') /** 20-08-2024 add check for blank records **/ @@ -81,7 +81,7 @@ unsubscribed_emails as ( SELECT *, ROW_NUMBER() OVER ( PARTITION BY email_address ORDER BY email_address DESC) row1 - FROM "parking-raw-zone".parking_cycle_hangar_unsubscribed_emails + FROM "parking-raw-zone".parking_parking_cycle_hangar_unsubscribed_emails WHERE import_date = (select max(import_date) from "parking-raw-zone".parking_cycle_hangar_unsubscribed_emails)),