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

Production deploy #2747

Merged
merged 22 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9d933e0
fix: don't link to locked or sanitised sessions in resume emails (#2713)
jessicamcinchak Jan 31, 2024
a3d3710
chore: update default `DrawBoundary` content (#2719)
jessicamcinchak Jan 31, 2024
2661739
chore: Sync new `staging_bops_secret` column (#2721)
DafyddLlyr Feb 1, 2024
0448da2
fix: Unrecognised 'Icon' prop passed to MUI button (#2722)
DafyddLlyr Feb 1, 2024
354dd78
[skip pizza] bump dotenv from 16.3.1 to 16.4.1 in /hasura.planx.uk/te…
dependabot[bot] Feb 1, 2024
2e863e0
chore(deps): bump jsdom from 23.0.0 to 24.0.0 in /sharedb.planx.uk (#…
dependabot[bot] Feb 1, 2024
7f2e0ae
chore(deps-dev): bump jest-axe from 6.0.1 to 8.0.0 in /editor.planx.u…
dependabot[bot] Feb 1, 2024
b62d3e1
chore(deps-dev): bump @types/node from 18.18.1 to 18.19.13 in /api.pl…
dependabot[bot] Feb 1, 2024
11e0899
[skip pizza] bump prettier from 3.1.0 to 3.2.4 in /e2e (#2729)
dependabot[bot] Feb 1, 2024
8a80e17
chore(deps): bump date-fns from 2.29.3 to 3.3.1 in /api.planx.uk (#2730)
dependabot[bot] Feb 1, 2024
3d4eb64
chore(deps): bump @tiptap/extension-bullet-list from 2.0.3 to 2.2.1 i…
dependabot[bot] Feb 1, 2024
372043a
chore(deps): bump @tiptap/extension-placeholder from 2.0.3 to 2.2.1 i…
dependabot[bot] Feb 1, 2024
79b18df
chore(deps-dev): bump prettier from 3.1.1 to 3.2.4 in /api.planx.uk (…
dependabot[bot] Feb 1, 2024
5ea9dc7
fix: Set serial on data sync for `team_integrations` [skip pizza] (#2…
DafyddLlyr Feb 1, 2024
0c3caf9
chore(deps-dev): bump esbuild from 0.19.2 to 0.20.0 in /api.planx.uk …
dependabot[bot] Feb 1, 2024
2a1fa6a
chore: Update `planx-core` (#2720)
DafyddLlyr Feb 1, 2024
4b94faf
fix: Don't forward `showArrow` prop to MUI button (#2743)
DafyddLlyr Feb 2, 2024
17f6a6d
fix(e2e): Update `setupMockBopsSubmissionUrl()` (#2744)
DafyddLlyr Feb 2, 2024
06a9691
feat: wire up feedback forms (#2701)
Mike-Heneghan Feb 2, 2024
439edc5
feat: hook up granular Article 4 GIS variables for Barking & Dagenham…
jessicamcinchak Feb 2, 2024
12b78fd
feat: scroll to feedback view on view change (#2716)
Mike-Heneghan Feb 2, 2024
b180df9
fix: Update Pulumi encryption keys (#2748)
DafyddLlyr Feb 2, 2024
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
14 changes: 6 additions & 8 deletions api.planx.uk/modules/gis/service/digitalLand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
};
}

/** When a team publishes their granular Article 4 data, add them to this list */
const localAuthorityMetadata: Record<string, LocalAuthorityMetadata> = {
barkingAndDagenham: require("./local_authorities/metadata/barkingAndDagenham"),
barnet: require("./local_authorities/metadata/barnet"),
birmingham: require("./local_authorities/metadata/birmingham"),
buckinghamshire: require("./local_authorities/metadata/buckinghamshire"),
Expand Down Expand Up @@ -70,8 +72,8 @@
options,
)}${datasets}`;
const res = await fetch(url)
.then((response: { json: () => any }) => response.json())

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

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

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
.catch((error: any) => console.log(error));

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

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

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 analytics are "on", store an audit record of the raw response
if (extras?.analytics !== "false") {
Expand Down Expand Up @@ -105,11 +107,10 @@
// check for & add any 'positive' constraints to the formattedResult
let formattedResult: Record<string, Constraint> = {};
if (res && res.count > 0 && res.entities) {
res.entities.forEach((entity: { dataset: any }) => {

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

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

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
// 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) =>
baseSchema[key]["digital-land-datasets"]?.includes(entity.dataset),
const key = Object.keys(baseSchema).find((key) =>
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
if (key && Object.keys(formattedResult).includes(key)) {
Expand Down Expand Up @@ -154,7 +155,7 @@
formattedResult["designated.nationalPark"] &&
formattedResult["designated.nationalPark"].value
) {
formattedResult["designated.nationalPark"]?.data?.forEach((entity: any) => {

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

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

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
if (
baseSchema[broads]["digital-land-entities"]?.includes(entity.entity)
) {
Expand Down Expand Up @@ -255,11 +256,8 @@
.then((responses) => {
responses.forEach((response: any) => {
// get the planx variable that corresponds to this 'dataset', should never be null because we only requested known datasets
const key = Object.keys(baseSchema).find(
(key) =>
baseSchema[key]["digital-land-datasets"]?.includes(
response.dataset,
),
const key = Object.keys(baseSchema).find((key) =>
baseSchema[key]["digital-land-datasets"]?.includes(response.dataset),
);
if (key) metadata[key] = response;
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
LAD20CD: E09000002
LAD20NM: Barking and Dagenham
LAD20NMW:
FID:

https://www.planning.data.gov.uk/entity/?dataset=article-4-direction-area&geometry_curie=statistical-geography%3AE09000002&entry_date_day=&entry_date_month=&entry_date_year=
https://docs.google.com/spreadsheets/d/1UmxQ95SjU72j0KaVIIkrIfhdE_k_lcFNhUWBc53GEIA/edit#gid=0
*/

import { LocalAuthorityMetadata } from "../../digitalLand";

const planningConstraints: LocalAuthorityMetadata["planningConstraints"] = {
article4: {
// Planx granular values link to entity.reference on Planning Data
records: {
"article4.barkingAndDagenham.additionalStoreys.dagenhamVillage": "A4D01",
"article4.barkingAndDagenham.additionalStoreys.lymington": "A4D02",
"article4.barkingAndDagenham.becontree":
"Proposed Becontree Design Guide Article 4",
// "article4.barkingAndDagenham.becontree.corners": "TBD",
"article4.barkingAndDagenham.hmo": "A4D03",
},
},
};

export { planningConstraints };
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe("buildContentFromSessions function", () => {
},
},
id: "123",
created_at: "2022-05-01T01:02:03.865452+00:00",
created_at: "2026-05-01T01:02:03.865452+00:00",
flow: {
slug: "apply-for-a-lawful-development-certificate",
},
Expand All @@ -56,7 +56,7 @@ describe("buildContentFromSessions function", () => {
const result = `Service: Apply for a lawful development certificate
Address: 1 High Street
Project type: New office premises
Expiry Date: 29 May 2022
Expiry Date: 29 May 2026
Link: example.com/team/apply-for-a-lawful-development-certificate/preview?sessionId=123`;
expect(
await buildContentFromSessions(
Expand All @@ -80,7 +80,7 @@ describe("buildContentFromSessions function", () => {
},
},
id: "123",
created_at: "2022-05-01T01:02:03.865452+00:00",
created_at: "2026-05-01T01:02:03.865452+00:00",
flow: {
slug: "apply-for-a-lawful-development-certificate",
},
Expand All @@ -97,7 +97,7 @@ describe("buildContentFromSessions function", () => {
},
},
id: "456",
created_at: "2022-05-01T01:02:03.865452+00:00",
created_at: "2026-05-01T01:02:03.865452+00:00",
flow: {
slug: "apply-for-a-lawful-development-certificate",
},
Expand All @@ -114,7 +114,7 @@ describe("buildContentFromSessions function", () => {
},
},
id: "789",
created_at: "2022-05-01T01:02:03.865452+00:00",
created_at: "2026-05-01T01:02:03.865452+00:00",
flow: {
slug: "apply-for-a-lawful-development-certificate",
},
Expand All @@ -123,15 +123,15 @@ describe("buildContentFromSessions function", () => {
const result = `Service: Apply for a lawful development certificate
Address: 1 High Street
Project type: New office premises
Expiry Date: 29 May 2022
Expiry Date: 29 May 2026
Link: example.com/team/apply-for-a-lawful-development-certificate/preview?sessionId=123\n\nService: Apply for a lawful development certificate
Address: 2 High Street
Project type: New office premises
Expiry Date: 29 May 2022
Expiry Date: 29 May 2026
Link: example.com/team/apply-for-a-lawful-development-certificate/preview?sessionId=456\n\nService: Apply for a lawful development certificate
Address: 3 High Street
Project type: New office premises
Expiry Date: 29 May 2022
Expiry Date: 29 May 2026
Link: example.com/team/apply-for-a-lawful-development-certificate/preview?sessionId=789`;
expect(
await buildContentFromSessions(
Expand All @@ -141,6 +141,56 @@ describe("buildContentFromSessions function", () => {
).toEqual(result);
});

it("should filter out expired sessions", async () => {
const sessions: PartialDeep<LowCalSession>[] = [
{
data: {
passport: {
data: {
_address: {
single_line_address: "1 High Street",
},
"proposal.projectType": ["new.office"],
},
},
},
id: "123",
created_at: "2026-05-01T01:02:03.865452+00:00",
flow: {
slug: "apply-for-a-lawful-development-certificate",
},
},
{
data: {
passport: {
data: {
_address: {
single_line_address: "2 High Street",
},
"proposal.projectType": ["new.office"],
},
},
},
id: "456",
created_at: "2022-05-01T01:02:03.865452+00:00",
flow: {
slug: "apply-for-a-lawful-development-certificate",
},
},
];
const result = `Service: Apply for a lawful development certificate
Address: 1 High Street
Project type: New office premises
Expiry Date: 29 May 2026
Link: example.com/team/apply-for-a-lawful-development-certificate/preview?sessionId=123`;
expect(
await buildContentFromSessions(
sessions as LowCalSession[],
{ slug: "team" } as Team,
),
).toEqual(result);
});

it("should handle an empty address field", async () => {
const sessions: PartialDeep<LowCalSession>[] = [
{
Expand All @@ -153,7 +203,7 @@ describe("buildContentFromSessions function", () => {
},
},
id: "123",
created_at: "2022-05-01T01:02:03.865452+00:00",
created_at: "2026-05-01T01:02:03.865452+00:00",
flow: {
slug: "apply-for-a-lawful-development-certificate",
},
Expand All @@ -163,7 +213,7 @@ describe("buildContentFromSessions function", () => {
const result = `Service: Apply for a lawful development certificate
Address: Address not submitted
Project type: New office premises
Expiry Date: 29 May 2022
Expiry Date: 29 May 2026
Link: example.com/team/apply-for-a-lawful-development-certificate/preview?sessionId=123`;
expect(
await buildContentFromSessions(
Expand All @@ -187,7 +237,7 @@ describe("buildContentFromSessions function", () => {
},
},
id: "123",
created_at: "2022-05-01T01:02:03.865452+00:00",
created_at: "2026-05-01T01:02:03.865452+00:00",
flow: {
slug: "apply-for-a-lawful-development-certificate",
},
Expand All @@ -197,7 +247,7 @@ describe("buildContentFromSessions function", () => {
const result = `Service: Apply for a lawful development certificate
Address: 1 High Street
Project type: Project type not submitted
Expiry Date: 29 May 2022
Expiry Date: 29 May 2026
Link: example.com/team/apply-for-a-lawful-development-certificate/preview?sessionId=123`;
expect(
await buildContentFromSessions(
Expand Down
27 changes: 20 additions & 7 deletions api.planx.uk/modules/saveAndReturn/service/resumeApplication.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { gql } from "graphql-request";
import { LowCalSession, Team } from "../../../types";
import { convertSlugToName, getResumeLink, calculateExpiryDate } from "./utils";
import { sendEmail } from "../../../lib/notify";
import type { SiteAddress } from "@opensystemslab/planx-core/types";
import { differenceInDays } from "date-fns";
import { gql } from "graphql-request";
import { $api, $public } from "../../../client";
import { sendEmail } from "../../../lib/notify";
import { LowCalSession, Team } from "../../../types";
import {
DAYS_UNTIL_EXPIRY,
calculateExpiryDate,
convertSlugToName,
getResumeLink,
} from "./utils";

/**
* Send a "Resume" email to an applicant which list all open applications for a given council (team)
Expand Down Expand Up @@ -46,7 +52,9 @@ const validateRequest = async (
where: {
email: { _eq: $email }
deleted_at: { _is_null: true }
locked_at: { _is_null: true }
submitted_at: { _is_null: true }
sanitised_at: { _is_null: true }
flow: { team: { slug: { _eq: $teamSlug } } }
}
order_by: { flow: { slug: asc }, created_at: asc }
Expand Down Expand Up @@ -113,15 +121,20 @@ const buildContentFromSessions = async (
const resumeLink = getResumeLink(session, team, session.flow.slug);
const expiryDate = calculateExpiryDate(session.created_at);

return `Service: ${service}
// Filter out any sessions that are expired (safety net for failed sanitation)
const today = new Date();
const sessionAge = differenceInDays(today, new Date(session.created_at));

if (sessionAge < DAYS_UNTIL_EXPIRY)
return `Service: ${service}
Address: ${addressLine || "Address not submitted"}
Project type: ${projectType || "Project type not submitted"}
Expiry Date: ${expiryDate}
Link: ${resumeLink}`;
};

const content = await Promise.all(sessions.map(contentBuilder));
return content.join("\n\n");
return content.filter(Boolean).join("\n\n");
};

export { resumeApplication, buildContentFromSessions };
export { buildContentFromSessions, resumeApplication };
4 changes: 2 additions & 2 deletions api.planx.uk/modules/saveAndReturn/service/validateSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ async function reconcileSessionData({

const findParentNode = (nodeId: string): string | undefined => {
const [parentId, _] =
Object.entries(currentFlow).find(
([_, node]) => node.edges?.includes(nodeId),
Object.entries(currentFlow).find(([_, node]) =>
node.edges?.includes(nodeId),
) || [];
return parentId;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@ export const getExpiredSessionIds = async (): Promise<string[]> => {
query GetExpiredSessionIds($retentionPeriod: timestamptz) {
lowcal_sessions(
where: {
submitted_at: { _lt: $retentionPeriod }
sanitised_at: { _is_null: true }
_or: [
{ deleted_at: { _lt: $retentionPeriod } }
{ submitted_at: { _lt: $retentionPeriod } }
{ locked_at: { _lt: $retentionPeriod } }
]
}
) {
id
Expand Down Expand Up @@ -123,6 +127,7 @@ export const sanitiseLowcalSessions: Operation = async () => {
_or: [
{ deleted_at: { _lt: $retentionPeriod } }
{ submitted_at: { _lt: $retentionPeriod } }
{ locked_at: { _lt: $retentionPeriod } }
]
}
) {
Expand Down
10 changes: 5 additions & 5 deletions api.planx.uk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"dependencies": {
"@airbrake/node": "^2.1.8",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#aa93cbf",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#d74afe2",
"@types/isomorphic-fetch": "^0.0.36",
"adm-zip": "^0.5.10",
"aws-sdk": "^2.1467.0",
Expand All @@ -15,7 +15,7 @@
"copyfiles": "^2.4.1",
"cors": "^2.8.5",
"csv-stringify": "^6.4.5",
"date-fns": "^2.29.3",
"date-fns": "^3.3.1",
"dompurify": "^3.0.6",
"express": "^4.18.2",
"express-async-errors": "^3.1.1",
Expand Down Expand Up @@ -85,7 +85,7 @@
"@types/lodash": "^4.14.202",
"@types/mime": "^3.0.4",
"@types/multer": "^1.4.11",
"@types/node": "^18.18.1",
"@types/node": "^18.19.13",
"@types/passport": "^1.0.16",
"@types/passport-google-oauth20": "^2.0.14",
"@types/supertest": "^2.0.16",
Expand All @@ -95,7 +95,7 @@
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"dotenv": "^16.3.1",
"esbuild": "^0.19.2",
"esbuild": "^0.20.0",
"esbuild-jest": "^0.5.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
Expand All @@ -106,7 +106,7 @@
"lint-staged": "^15.0.2",
"nock": "^13.4.0",
"node-dev": "^8.0.0",
"prettier": "^3.1.1",
"prettier": "^3.2.4",
"rimraf": "^5.0.5",
"supertest": "^6.3.3",
"ts-jest": "^29.1.1",
Expand Down
Loading
Loading