Skip to content

Commit d5a1def

Browse files
authored
Update parking_cycle_hangar_allocation_update.py
Change code to use the interim waiting list from the google sheet
1 parent 70d2568 commit d5a1def

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

scripts/jobs/parking/parking_cycle_hangar_allocation_update.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
28/04/2024 - refine the 'hangar_can_be_filled' field case statement
3939
26/09/2024 - add hangar location.
4040
04/10/2024 - add additional checks for the waiting list
41+
04/12/2024 - collect the interim cycle hangar waiting list
4142
******************************************************************************************************************/
4243
/*******************************************************************************
4344
Create a comparison between Toms Hangar list and EStreet
@@ -105,6 +106,19 @@
105106
FROM "dataplatform-stg-liberator-raw-zone".liberator_permit_llpg
106107
WHERE import_Date = format_datetime(current_date, 'yyyyMMdd')),
107108
/*******************************************************************************
109+
04/12/2024 - interim cycle hangar waiting list
110+
*******************************************************************************/
111+
Interim_Wait as (
112+
SELECT * from "parking-raw-zone".interim_cycle_wait_list
113+
WHERE import_date = (select max(import_date)
114+
from "parking-raw-zone".interim_cycle_wait_list)),
115+
116+
/*** count the number on the waiting list by hangar ***/
117+
Interim_Wait_summary as (
118+
SELECT hanger_id, count(*) as Interim_Wait_Total
119+
FROM Interim_Wait
120+
GROUP BY hanger_id),
121+
/*******************************************************************************
108122
Cycle Hangar allocation details
109123
*******************************************************************************/
110124
Cycle_Hangar_allocation as (
@@ -222,14 +236,15 @@
222236
LEFT JOIN Alloc_Total as B ON A.hanger_id = B.hanger_id
223237
WHERE H1 = 1),
224238
239+
/*** 04/12/2024 - change to use the interim waiting list totals ***/
225240
Full_Hangar_Data as (
226241
SELECT
227242
A.hanger_id, A.hangar_location,
228243
CASE
229244
When A.hanger_id = 'new_only' Then 0
230245
ELSE Total_Allocated
231246
END as Total_Allocated,
232-
Wait_Total,
247+
Interim_Wait_Total as Wait_Total, /*** remove Wait_Total,***/
233248
CASE
234249
When A.hanger_id = 'new_only' Then 0
235250
ELSE ( 6 - Total_Allocated)
@@ -238,7 +253,8 @@
238253
Max_Date as Latest_Registration_Date
239254
FROM allocated_Total as A
240255
LEFT JOIN Wait_total as B ON A.hanger_id = B.hanger_id
241-
LEFT JOIN Wait_List_Earlist_Latest as C ON A.hanger_id = C.hanger_id),
256+
LEFT JOIN Wait_List_Earlist_Latest as C ON A.hanger_id = C.hanger_id
257+
LEFT JOIN Interim_Wait_summary as D ON A.hanger_id = D.hanger_id),
242258
243259
/** 20-08-2024 Use the de-dupe data NOT TomHangar **/
244260
Hangar_WAit_List as (

0 commit comments

Comments
 (0)