record and show raw status from data
This commit is contained in:
parent
15be5cce40
commit
5d3f374cf7
@ -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 ? <a href={link.toString()}>{link.toString()}</a> : MissingData }</>
|
||||
}
|
||||
|
||||
const StatusInfo = ({status, statusBeforeAliasing}) => {
|
||||
if(status == null) {
|
||||
return <div><b>Current planning application status for this site</b>: {LinkIfAvailable(null)}</div>
|
||||
}
|
||||
if(status != statusBeforeAliasing) {
|
||||
return <div><b>Current planning application status for this site:</b> {status} - status in raw data was: {statusBeforeAliasing}</div>
|
||||
}
|
||||
return <div><b>Current planning application status for this site:</b> {status}</div>
|
||||
}
|
||||
|
||||
const PlanningDataOfficialDataEntry: React.FC<PlanningDataOfficialDataEntryProps> = (props) => {
|
||||
const data = props.shownData || [];
|
||||
if(data.length == 0) {
|
||||
@ -88,7 +99,10 @@ const PlanningDataOfficialDataEntry: React.FC<PlanningDataOfficialDataEntryProps
|
||||
<Fragment>
|
||||
<div><i>Planning application status is streamed using live data uploaded by local authorities to the {item["data_source_link"] ? <a href={item["data_source_link"]}>{item["data_source"]}</a> : item["data_source"] }.</i></div>
|
||||
<br/>
|
||||
<div><b>Current planning application status for this site:</b> {ShowIfAvailable(item["status"])}</div>
|
||||
<div><b>Current planning application status for this site:</b> <StatusInfo
|
||||
statusBeforeAliasing={item["status_before_aliasing"]}
|
||||
status={item["status"]}
|
||||
/></div>
|
||||
<div><b>Planning application ID:</b> {ShowIfAvailable(item["planning_application_id"])}</div>
|
||||
<div><b>Date registered by the planning authority (validation date)</b>: {ShowIfAvailable(item["registered_with_local_authority_date"])}</div>
|
||||
<div><b>Decision date</b>: {ShowIfAvailable(item["decision_date"])}</div>
|
||||
|
@ -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: ""},
|
||||
],
|
||||
},
|
||||
|
||||
|
@ -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`,
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user