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

chore: rename export zip to {flow-slug}-{session-id}.zip #2893

Merged
merged 6 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const createPaymentSendEvents = async (
});
}

const publishedFlowData = await getMostRecentPublishedFlow(session.flowId);
const publishedFlowData = await getMostRecentPublishedFlow(session.flow.id);
if (!publishedFlowData) {
return next({
status: 400,
Expand All @@ -55,7 +55,7 @@ const createPaymentSendEvents = async (
).find(([_nodeId, nodeData]) => nodeData.type === ComponentType.Send);
const destinations: Destination[] = sendNode?.[1]?.data?.destinations;

let teamSlug = await getTeamSlugByFlowId(session.flowId);
let teamSlug = await getTeamSlugByFlowId(session.flow.id);
const eventPayload = { sessionId: payload.sessionId };

if (destinations.includes(Destination.BOPS)) {
Expand Down
16 changes: 9 additions & 7 deletions api.planx.uk/modules/send/utils/exportZip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ export async function buildSubmissionExportZip({
includeOneAppXML?: boolean;
includeDigitalPlanningJSON?: boolean;
}): Promise<ExportZip> {
// create zip
const zip = new ExportZip(sessionId);

// fetch session data
const sessionData = await $api.session.find(sessionId);
if (!sessionData) {
Expand All @@ -37,6 +34,10 @@ export async function buildSubmissionExportZip({
);
}
const passport = sessionData.data?.passport as IPassport;
const flowSlug = sessionData?.flow.slug;

// create zip
const zip = new ExportZip(sessionId, flowSlug);

// add OneApp XML to the zip
if (includeOneAppXML) {
Expand Down Expand Up @@ -111,8 +112,9 @@ export async function buildSubmissionExportZip({
}

// add template files to zip
const templateNames =
await $api.getDocumentTemplateNamesForSession(sessionId);
const templateNames = await $api.getDocumentTemplateNamesForSession(
sessionId,
);
for (const templateName of templateNames || []) {
try {
const isTemplateSupported = hasRequiredDataForTemplate({
Expand Down Expand Up @@ -199,11 +201,11 @@ export class ExportZip {
filename: string;
private tmpDir: string;

constructor(sessionId: string) {
constructor(sessionId: string, flowSlug: string) {
this.zip = new AdmZip();
// make a tmp directory to avoid file name collisions if simultaneous applications
this.tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), sessionId));
this.filename = path.join(__dirname, `ripa-test-${sessionId}.zip`);
this.filename = path.join(__dirname, `${flowSlug}-${sessionId}.zip`);
Copy link
Contributor

@DafyddLlyr DafyddLlyr Mar 15, 2024

Choose a reason for hiding this comment

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

This gives me the following on Pizza -
image

Are you getting this also? Could we drop __dirname here?

Copy link
Member Author

Choose a reason for hiding this comment

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

dirname only occurs on docker envs as I understand it (so local & pizzas), should be automatically omitted on staging / prod !

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Perfect, thanks for clarifying! Makes sense considering we don't get this on staging / prod.

}

addFile({ name, buffer }: { name: string; buffer: Buffer }) {
Expand Down
2 changes: 1 addition & 1 deletion 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#dab9c39",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#d7e82f0",
"@types/isomorphic-fetch": "^0.0.36",
"adm-zip": "^0.5.10",
"aws-sdk": "^2.1467.0",
Expand Down
20 changes: 10 additions & 10 deletions api.planx.uk/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion e2e/tests/api-driven/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"dependencies": {
"@cucumber/cucumber": "^9.3.0",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#dab9c39",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#d7e82f0",
"axios": "^1.6.0",
"dotenv": "^16.3.1",
"dotenv-expand": "^10.0.0",
Expand Down
22 changes: 11 additions & 11 deletions e2e/tests/api-driven/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion e2e/tests/ui-driven/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"postinstall": "./install-dependencies.sh"
},
"dependencies": {
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#dab9c39",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#d7e82f0",
"axios": "^1.6.2",
"dotenv": "^16.3.1",
"eslint": "^8.56.0",
Expand Down
20 changes: 10 additions & 10 deletions e2e/tests/ui-driven/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion editor.planx.uk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@mui/styles": "^5.15.2",
"@mui/utils": "^5.15.2",
"@opensystemslab/map": "^0.8.0",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#dab9c39",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#d7e82f0",
"@tiptap/core": "^2.0.3",
"@tiptap/extension-bold": "^2.0.3",
"@tiptap/extension-bubble-menu": "^2.1.13",
Expand Down
22 changes: 11 additions & 11 deletions editor.planx.uk/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading