diff --git a/app/src/frontend/building/data-components/planning-data-entry.tsx b/app/src/frontend/building/data-components/planning-data-entry.tsx index e96ca3c0..47cecc79 100644 --- a/app/src/frontend/building/data-components/planning-data-entry.tsx +++ b/app/src/frontend/building/data-components/planning-data-entry.tsx @@ -8,6 +8,7 @@ interface PlanningDataOfficialDataEntryProps { uprn: string; building_id: number; status?: string, + status_before_aliasing?: string, description?: string; planning_application_link?: string; registered_with_local_authority_date?: string; @@ -61,6 +62,16 @@ const LinkIfAvailable = (link) => { return <>{link ? {link.toString()} : MissingData } } +const StatusInfo = ({status, statusBeforeAliasing}) => { + if(status == null) { + return
Current planning application status for this site: {LinkIfAvailable(null)}
+ } + if(status != statusBeforeAliasing) { + return
Current planning application status for this site: {status} - status in raw data was: {statusBeforeAliasing}
+ } + return
Current planning application status for this site: {status}
+} + const PlanningDataOfficialDataEntry: React.FC = (props) => { const data = props.shownData || []; if(data.length == 0) { @@ -88,7 +99,10 @@ const PlanningDataOfficialDataEntry: React.FC
Planning application status is streamed using live data uploaded by local authorities to the {item["data_source_link"] ? {item["data_source"]} : item["data_source"] }.

-
Current planning application status for this site: {ShowIfAvailable(item["status"])}
+
Current planning application status for this site:
Planning application ID: {ShowIfAvailable(item["planning_application_id"])}
Date registered by the planning authority (validation date): {ShowIfAvailable(item["registered_with_local_authority_date"])}
Decision date: {ShowIfAvailable(item["decision_date"])}
diff --git a/app/src/frontend/config/data-fields-config.ts b/app/src/frontend/config/data-fields-config.ts index 21c5b9ea..eb741100 100644 --- a/app/src/frontend/config/data-fields-config.ts +++ b/app/src/frontend/config/data-fields-config.ts @@ -177,7 +177,7 @@ export const dataFields = { /* eslint-disable @typescript-eslint/camelcase */ title: "PLANNING DATA", tooltip: "PLANNING DATA", example: [{uprn: "", building_id: 1, data_source: ""}, - {uprn: "", building_id: 1, data_source: "", status: "", decision_date: "", description: "", planning_application_link: "", registered_with_local_authority_date: "", last_synced_date: "", data_source_link: ""}, + {uprn: "", building_id: 1, data_source: "", status: "", status_before_aliasing: "", decision_date: "", description: "", planning_application_link: "", registered_with_local_authority_date: "", last_synced_date: "", data_source_link: ""}, ], }, diff --git a/app/src/tiles/dataDefinition.ts b/app/src/tiles/dataDefinition.ts index 57b502e6..5e81c83e 100644 --- a/app/src/tiles/dataDefinition.ts +++ b/app/src/tiles/dataDefinition.ts @@ -137,7 +137,7 @@ const LAYER_QUERIES = { community_public_ownership IS NOT NULL `, planning_applications_status_all: `SELECT - buildings.geometry_id, building_properties.uprn, building_properties.building_id, planning_data.status AS status, planning_data.uprn, + buildings.geometry_id, building_properties.uprn, building_properties.building_id, planning_data.status AS status, planning_data.uprn FROM building_properties INNER JOIN planning_data ON building_properties.uprn = planning_data.uprn INNER JOIN buildings ON building_properties.building_id = buildings.building_id`, diff --git a/etl/planning_data/obtain_livestream_data_and_load_into_database.py b/etl/planning_data/obtain_livestream_data_and_load_into_database.py index 044e5d29..4d829c60 100644 --- a/etl/planning_data/obtain_livestream_data_and_load_into_database.py +++ b/etl/planning_data/obtain_livestream_data_and_load_into_database.py @@ -44,7 +44,8 @@ def load_data_into_database(cursor, data): decision_date = parse_date_string_into_datestring(entry['_source']['decision_date']) last_synced_date = parse_date_string_into_datestring(entry['_source']['last_synced']) uprn = entry['_source']['uprn'] - status = process_status(entry['_source']['status'], decision_date) + status_before_aliasing = entry['_source']['status'] + status = process_status(status_before_aliasing, decision_date) if uprn == None: continue try: @@ -61,6 +62,7 @@ def load_data_into_database(cursor, data): "registered_with_local_authority_date": parse_date_string_into_datestring(entry['_source']['valid_date']), "uprn": uprn, "status": status, + "status_before_aliasing": status_before_aliasing, "data_source": "Greater London Authority's Planning London DataHub", "data_source_link": None } @@ -137,10 +139,10 @@ def insert_entry(cursor, e): if e["application_url"] != None: application_url = e["application_url"] cursor.execute('''INSERT INTO - planning_data (planning_application_id, planning_application_link, description, registered_with_local_authority_date, decision_date, last_synced_date, status, data_source, data_source_link, uprn) + planning_data (planning_application_id, planning_application_link, description, registered_with_local_authority_date, decision_date, last_synced_date, status, status_before_aliasing, data_source, data_source_link, uprn) VALUES - (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s) - ''', (e["application_id"], application_url, e["description"], e["registered_with_local_authority_date"], e["decision_date"], e["last_synced_date"], e["status"], e["data_source"], e["data_source_link"], e["uprn"])) + (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) + ''', (e["application_id"], application_url, e["description"], e["registered_with_local_authority_date"], e["decision_date"], e["last_synced_date"], e["status"], e["status_before_aliasing"], e["data_source"], e["data_source_link"], e["uprn"])) def parse_date_string_into_datestring(incoming): if incoming == None: diff --git a/migrations/034.planning_livestream_data.up.sql b/migrations/034.planning_livestream_data.up.sql index 940b5e11..5e023255 100644 --- a/migrations/034.planning_livestream_data.up.sql +++ b/migrations/034.planning_livestream_data.up.sql @@ -10,6 +10,7 @@ CREATE TABLE IF NOT EXISTS planning_data ( decision_date date, last_synced_date date, status VARCHAR(50), + status_before_aliasing VARCHAR(50), data_source VARCHAR(70), data_source_link VARCHAR(150), uprn bigint