diff --git a/components/admin/utils/serverside.js b/components/admin/utils/serverside.js
index 2f313c30..20870e7f 100644
--- a/components/admin/utils/serverside.js
+++ b/components/admin/utils/serverside.js
@@ -5,7 +5,7 @@ import { PrismaClient } from "@prisma/client";
import CryptoJS from "crypto-js";
import { getUpToLastSlash, streamToString } from "../utils/adminHelper";
import { listContainersForUser } from "../../../actions/azurestorage";
-
+import pLimit from "p-limit";
const prisma = global.prisma || new PrismaClient();
const WORDKEY = process.env.HASHKEY;
/**
@@ -34,112 +34,120 @@ export async function fetchAdminStorageData() {
const users = await prisma.user.findMany();
+ const limit = pLimit(5);
let data = await Promise.all(
users.map(async (user) => {
- const containers = await listContainersForUser(
- blobServiceClient,
- `${user.id}`,
- user.email
- );
+ limit(async () => {
+ const containers = await listContainersForUser(
+ blobServiceClient,
+ `${user.id}`,
+ user.email
+ );
- const containersWithHashes = await Promise.all(
- containers.map(async (container) => {
- const groupedByFolder = await container.blobs.reduce(
- async (accP, blob) => {
- const acc = await accP;
- const folderPath =
- getUpToLastSlash(blob.name.trim()) || "";
+ const containersWithHashes = await Promise.all(
+ containers.map(async (container) => {
+ const groupedByFolder = await container.blobs.reduce(
+ async (accP, blob) => {
+ const acc = await accP;
+ const folderPath =
+ getUpToLastSlash(blob.name.trim()) || "";
- const hashedfilepath = hashAPIPath(
- `/api/file/downloadblob?container=${
- container.container
- }&casefolderID=${folderPath}&blobname=${blob.name
- .substring(blob.name.lastIndexOf("/") + 1)
- .trim()}`,
- process.env.HASHKEY
- );
-
- const fileNameOnly = blob.name.substring(
- blob.name.lastIndexOf("/") + 1
- );
- const isTmpFile = fileNameOnly.startsWith("TMP-");
-
- const blobWithHash = {
- ...blob,
- hashedfilepath,
- isTmpFile
- };
-
- let folderGroup = acc.find(
- (f) => f.folderPath === folderPath
- );
- if (!folderGroup) {
- folderGroup = {
- folderPath,
- blobs: [],
- hasRepJson: false,
- repJsonBlob: null,
- repComplete: false,
- hasTmpFile: false
- };
- acc.push(folderGroup);
- }
-
- folderGroup.blobs.push(blobWithHash);
-
- if (isTmpFile) {
- folderGroup.hasTmpFile = true;
- }
-
- // rep.json handling
- if (blob.name.toLowerCase().endsWith("rep.json")) {
- folderGroup.hasRepJson = true;
- folderGroup.repJsonBlob = blobWithHash;
-
- const containerClient =
- blobServiceClient.getContainerClient(
+ const hashedfilepath = hashAPIPath(
+ `/api/file/downloadblob?container=${
container.container
- );
- const blockBlobClient =
- containerClient.getBlockBlobClient(
- blob.name
- );
+ }&casefolderID=${folderPath}&blobname=${blob.name
+ .substring(
+ blob.name.lastIndexOf("/") + 1
+ )
+ .trim()}`,
+ process.env.HASHKEY
+ );
- try {
- const downloadResponse =
- await blockBlobClient.download(0);
- const downloaded = await streamToString(
- downloadResponse.readableStreamBody
- );
- const json = JSON.parse(downloaded);
- folderGroup.repComplete = Boolean(
- json.repComplete
- );
- } catch (err) {
- console.error(
- "Error reading rep.json",
- err
- );
- folderGroup.repComplete = false;
+ const fileNameOnly = blob.name.substring(
+ blob.name.lastIndexOf("/") + 1
+ );
+ const isTmpFile =
+ fileNameOnly.startsWith("TMP-");
+
+ const blobWithHash = {
+ ...blob,
+ hashedfilepath,
+ isTmpFile
+ };
+
+ let folderGroup = acc.find(
+ (f) => f.folderPath === folderPath
+ );
+ if (!folderGroup) {
+ folderGroup = {
+ folderPath,
+ blobs: [],
+ hasRepJson: false,
+ repJsonBlob: null,
+ repComplete: false,
+ hasTmpFile: false
+ };
+ acc.push(folderGroup);
}
- }
- return acc;
- },
- Promise.resolve([])
- );
+ folderGroup.blobs.push(blobWithHash);
- return { ...container, folders: groupedByFolder };
- })
- );
+ if (isTmpFile) {
+ folderGroup.hasTmpFile = true;
+ }
- return containersWithHashes.length > 0
- ? {
- id: user.id,
- email: user.email,
- containers: containersWithHashes
- }
- : null;
+ // rep.json handling
+ if (
+ blob.name.toLowerCase().endsWith("rep.json")
+ ) {
+ folderGroup.hasRepJson = true;
+ folderGroup.repJsonBlob = blobWithHash;
+
+ const containerClient =
+ blobServiceClient.getContainerClient(
+ container.container
+ );
+ const blockBlobClient =
+ containerClient.getBlockBlobClient(
+ blob.name
+ );
+
+ try {
+ const downloadResponse =
+ await blockBlobClient.download(0);
+ const downloaded = await streamToString(
+ downloadResponse.readableStreamBody
+ );
+ const json = JSON.parse(downloaded);
+ folderGroup.repComplete = Boolean(
+ json.repComplete
+ );
+ } catch (err) {
+ console.error(
+ "Error reading rep.json",
+ err
+ );
+ folderGroup.repComplete = false;
+ }
+ }
+
+ return acc;
+ },
+ Promise.resolve([])
+ );
+
+ return { ...container, folders: groupedByFolder };
+ })
+ );
+
+ return containersWithHashes.length > 0
+ ? {
+ id: user.id,
+ email: user.email,
+ containers: containersWithHashes
+ }
+ : null;
+ });
})
);
diff --git a/components/newappeal/buildchecksection.js b/components/newappeal/buildchecksection.js
index 6285306f..e385e3fe 100644
--- a/components/newappeal/buildchecksection.js
+++ b/components/newappeal/buildchecksection.js
@@ -450,7 +450,7 @@ let BuildCheckSection = (props) => {
data-module="govuk-button"
onClick={async () => {
await triggerAppealDownload();
- finaliseAppeal();
+ // finaliseAppeal();
}}
>
{t("newappeal:submit-appeal-button")}
diff --git a/components/pdftemplates/appealRow_pdf.js b/components/pdftemplates/appealRow_pdf.js
index 9164c508..00fa2fdb 100644
--- a/components/pdftemplates/appealRow_pdf.js
+++ b/components/pdftemplates/appealRow_pdf.js
@@ -112,7 +112,8 @@ export const AppealRow_pdf = (props) => {
color: "grey"
},
documentList: {
- fontSize: 10
+ fontSize: 10,
+ lineHeight: 1.4
},
richArea: {
fontSize: 12,
@@ -432,51 +433,68 @@ export const AppealRow_pdf = (props) => {
flexDirection: "column",
marginBottom: 10
}}
- wrap={false}
>
-
+
+ {rows[0].value}
+
+
+
+
- {rows[0].value}
-
-
-
- {blobList.map((blob, i) => (
-
- {getDocumentTypeFromFilename(
- blob.name
- ) ===
+ {blobList.map((blob, i) => {
+ const isTargetType =
+ getDocumentTypeFromFilename(
+ blob.name
+ ) ===
documentTypeCode[0]
- .value && (
-
- {blob.name}
- {blob?.size &&
- " - " +
- bytesToSize(
- blob?.size
- )}{" "}
- {"\n"}
-
- )}
-
- ))}
+
+ {blob.name}
+ {blob?.size &&
+ ` - ${bytesToSize(blob.size)}`}
+
+
+ );
+ })}
+
);