Skip to content

Commit e3bf8a3

Browse files
Merge pull request #2003 from LBHackney-IT/daclarkelbh-patch-3
Update parking_correspondence_performance_records_with_pcn_downtime.py
2 parents 9f6ff66 + a80197f commit e3bf8a3

File tree

2 files changed

+43
-35
lines changed

2 files changed

+43
-35
lines changed

scripts/jobs/parking/parking_correspondence_performance_records_with_pcn_downtime.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ def sparkSqlQuery(glueContext, query, mapping, transformation_ctx) -> DynamicFra
6262
21/04/2023 - added teams data from google spreadsheet load - https://docs.google.com/spreadsheets/d/1zxZXX1_qU9NW93Ug1JUy7aXsnTz45qIj7Zftmi9trbI/edit?usp=sharing
6363
02/10/2023 - modified to union data into one output for Downtime data gathered from Google form https://forms.gle/bB53jAayiZ2Ykwjk6
6464
06/11/2024 - updated date formats in downtime data as source google sheet changed to yyyy-mm-dd HH:MM:ss from d/m/y
65+
28/11/2024 - updated downtime records for t_team details to pull from parking_correspondence_performance_teams instead on leaving blank
6566
*/
67+
6668
/*Teams data from google spreadsheet load - https://docs.google.com/spreadsheets/d/1zxZXX1_qU9NW93Ug1JUy7aXsnTz45qIj7Zftmi9trbI/edit?usp=sharing*/
6769
With team as (
6870
select distinct start_date as t_start_date
@@ -337,8 +339,8 @@ def sparkSqlQuery(glueContext, query, mapping, transformation_ctx) -> DynamicFra
337339
Select
338340
cast(parking_officer_downtime.timestamp as string) as downtime_timestamp
339341
,email_address as downtime_email_address
340-
,officer_s_first_name
341-
,officer_s_last_name
342+
,TRIM(officer_s_first_name) as officer_s_first_name
343+
,TRIM(officer_s_last_name) as officer_s_last_name
342344
,liberator_system_username
343345
,liberator_system_id
344346
,cast(import_datetime as string) import_datetime
@@ -409,7 +411,7 @@ def sparkSqlQuery(glueContext, query, mapping, transformation_ctx) -> DynamicFra
409411
,'Downtime' as Type
410412
,parking_officer_downtime.Downtime as Serviceable -- downtime
411413
,'' as Service_category
412-
,concat(officer_s_first_name,' ',officer_s_last_name) as Response_written_by --downtime officer full name
414+
,concat(TRIM(officer_s_first_name),' ',TRIM(officer_s_last_name)) as Response_written_by --downtime officer full name
413415
,'' as Letter_template
414416
,'' as Action_taken
415417
,'' as Related_to_PCN
@@ -535,21 +537,23 @@ def sparkSqlQuery(glueContext, query, mapping, transformation_ctx) -> DynamicFra
535537
,'' as pcn_import_date
536538
537539
/*Teams data*/
538-
,'' as t_start_date
539-
,'' as t_end_date
540-
,'' as t_team
541-
,'' as t_team_name
542-
,'' as t_role
543-
,'' as t_forename
544-
,'' as t_surname
545-
,'' as t_full_name
546-
,'' as t_qa_doc_created_by
547-
,'' as t_qa_doc_full_name
548-
,'' as t_post_title
549-
,'' as t_notes
550-
,'' as t_import_date
540+
,t_start_date
541+
,t_end_date
542+
,t_team
543+
,t_team_name
544+
,t_role
545+
,t_forename
546+
,t_surname
547+
,t_full_name
548+
,t_qa_doc_created_by
549+
,t_qa_doc_full_name
550+
,t_post_title
551+
,t_notes
552+
,t_import_date
551553
552-
from parking_officer_downtime where import_date = (select max(import_date) from parking_officer_downtime) and timestamp not like '' and timestamp not like '#REF!'
554+
from parking_officer_downtime
555+
left join team on upper(team.t_full_name) = upper(concat(TRIM(officer_s_first_name),' ',TRIM(officer_s_last_name))) --as Response_written_by --downtime officer full name
556+
where import_date = (select max(import_date) from parking_officer_downtime) and timestamp not like '' and timestamp not like '#REF!'
553557
AND cast(Substr( cast(parking_officer_downtime.timestamp as string) ,1,10) as date) > current_date - interval '13' month --Last 13 months from todays date
554558
--order by timestamp desc
555559
"""

scripts/jobs/parking/parking_correspondence_performance_records_with_pcn_downtime_gds.py

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ def sparkSqlQuery(glueContext, query, mapping, transformation_ctx) -> DynamicFra
6363
02/10/2023 - modified to union data into one output for Downtime data gathered from Google form https://forms.gle/bB53jAayiZ2Ykwjk6
6464
08/11/2023 - modified to add monthly officer totals from original gds job
6565
06/11/2024 - updated date formats in downtime data as source google sheet changed to yyyy-mm-dd HH:MM:ss from d/m/y
66+
28/11/2024 - updated downtime records for t_team details to pull from parking_correspondence_performance_teams instead on leaving blank
6667
6768
*/
69+
6870
/*Teams data from google spreadsheet load - https://docs.google.com/spreadsheets/d/1zxZXX1_qU9NW93Ug1JUy7aXsnTz45qIj7Zftmi9trbI/edit?usp=sharing*/
6971
With officer_total_rep_dates as(
7072
select
@@ -414,8 +416,8 @@ def sparkSqlQuery(glueContext, query, mapping, transformation_ctx) -> DynamicFra
414416
Select
415417
cast(parking_officer_downtime.timestamp as string) as downtime_timestamp
416418
,email_address as downtime_email_address
417-
,officer_s_first_name
418-
,officer_s_last_name
419+
,TRIM(officer_s_first_name) as officer_s_first_name
420+
,TRIM(officer_s_last_name) as officer_s_last_name
419421
,liberator_system_username
420422
,liberator_system_id
421423
,cast(import_datetime as string) import_datetime
@@ -486,7 +488,7 @@ def sparkSqlQuery(glueContext, query, mapping, transformation_ctx) -> DynamicFra
486488
,'Downtime' as Type
487489
,parking_officer_downtime.Downtime as Serviceable -- downtime
488490
,'' as Service_category
489-
,concat(officer_s_first_name,' ',officer_s_last_name) as Response_written_by --downtime officer full name
491+
,concat(TRIM(officer_s_first_name),' ',TRIM(officer_s_last_name)) as Response_written_by --downtime officer full name
490492
,'' as Letter_template
491493
,'' as Action_taken
492494
,'' as Related_to_PCN
@@ -626,21 +628,23 @@ def sparkSqlQuery(glueContext, query, mapping, transformation_ctx) -> DynamicFra
626628
,'' as tot_rep_records
627629
628630
/*Teams data*/
629-
,'' as t_start_date
630-
,'' as t_end_date
631-
,'' as t_team
632-
,'' as t_team_name
633-
,'' as t_role
634-
,'' as t_forename
635-
,'' as t_surname
636-
,'' as t_full_name
637-
,'' as t_qa_doc_created_by
638-
,'' as t_qa_doc_full_name
639-
,'' as t_post_title
640-
,'' as t_notes
641-
,'' as t_import_date
642-
643-
from parking_officer_downtime where import_date = (select max(import_date) from parking_officer_downtime) and timestamp not like '' and timestamp not like '#REF!'
631+
,t_start_date
632+
,t_end_date
633+
,t_team
634+
,t_team_name
635+
,t_role
636+
,t_forename
637+
,t_surname
638+
,t_full_name
639+
,t_qa_doc_created_by
640+
,t_qa_doc_full_name
641+
,t_post_title
642+
,t_notes
643+
,t_import_date
644+
645+
from parking_officer_downtime
646+
left join team on upper(team.t_full_name) = upper(concat(TRIM(officer_s_first_name),' ',TRIM(officer_s_last_name))) --as Response_written_by --downtime officer full name
647+
where import_date = (select max(import_date) from parking_officer_downtime) and timestamp not like '' and timestamp not like '#REF!'
644648
AND cast(Substr( cast(parking_officer_downtime.timestamp as string) ,1,10) as date) > current_date - interval '13' month --Last 13 months from todays date
645649
--order by timestamp desc
646650
"""

0 commit comments

Comments
 (0)