Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add granular Listed Building grades to GIS responses #2746

Merged
merged 3 commits into from
Feb 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions api.planx.uk/modules/gis/service/digitalLand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@
const res = await fetch(url)
.then((response: { json: () => any }) => response.json())
.catch((error: any) => console.log(error));

Check warning on line 75 in api.planx.uk/modules/gis/service/digitalLand.ts

View workflow job for this annotation

GitHub Actions / Run API Tests

Unexpected any. Specify a different type
// if analytics are "on", store an audit record of the raw response

Check warning on line 76 in api.planx.uk/modules/gis/service/digitalLand.ts

View workflow job for this annotation

GitHub Actions / Run API Tests

Unexpected any. Specify a different type
if (extras?.analytics !== "false") {
const _auditRecord = await $api.client.request(
gql`
Expand Down Expand Up @@ -107,7 +107,7 @@
if (res && res.count > 0 && res.entities) {
res.entities.forEach((entity: { dataset: any }) => {
// get the planx variable that corresponds to this entity's 'dataset', should never be null because our initial request is filtered on 'dataset'
const key = Object.keys(baseSchema).find((key) =>

Check warning on line 110 in api.planx.uk/modules/gis/service/digitalLand.ts

View workflow job for this annotation

GitHub Actions / Run API Tests

Unexpected any. Specify a different type
baseSchema[key]["digital-land-datasets"]?.includes(entity.dataset),
);
// because there can be many digital land datasets per planx variable, check if this key is already in our result
Expand Down Expand Up @@ -155,7 +155,7 @@
) {
formattedResult["designated.nationalPark"]?.data?.forEach((entity: any) => {
if (
baseSchema[broads]["digital-land-entities"]?.includes(entity.entity)

Check warning on line 158 in api.planx.uk/modules/gis/service/digitalLand.ts

View workflow job for this annotation

GitHub Actions / Run API Tests

Unexpected any. Specify a different type
) {
formattedResult[broads] = {
fn: broads,
Expand All @@ -170,7 +170,7 @@
formattedResult[broads] = { fn: broads, value: false };
}

// FLOODING
// --- FLOODING ---
if (formattedResult["flood"] && formattedResult["flood"].value) {
["flood.zone.1", "flood.zone.2", "flood.zone.3"].forEach(
(zone) =>
Expand All @@ -186,7 +186,20 @@
}

// --- LISTED BUILDINGS ---
// TODO add granular variables to reflect grade (eg `listed.grade1`), not reflected in content yet though
if (formattedResult["listed"] && formattedResult["listed"].value) {
["listed.grade.I", "listed.grade.II", "listed.grade.II*"].forEach(
(grade) =>
(formattedResult[grade] = {
fn: grade,
value: Boolean(
formattedResult["listed"].data?.filter(
(entity) =>
entity["listed-building-grade"] === grade.split(".").pop(),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My preferred granular passport variable names here were listed.gradeI rather than listed.grade.I - but then we can't check for a direct match against how Planning Data publishes "grades" - and "endsWith" doesn't work with I & II.

We hit a similar thing with introducing specific flood zone variables above - so at least the many segments is consistent.

Will update the ODP Schema PR to match !

).length,
),
}),
);
}

// --- ARTICLE 4S ---
// only attempt to set granular a4s if we have metadata for this local authority; proceed with non-granular a4 queries under "opensystemslab" team etc
Expand Down
Loading