decopled crm for new appeals - all made on storage

This commit is contained in:
2022-09-28 10:13:36 +01:00
parent bfcd0329c6
commit 745b51839a
15 changed files with 451 additions and 99 deletions
+37 -7
View File
@@ -78,6 +78,7 @@ export const getBlobs = async (containerName, casefolderID) => {
"path": blob.name,
"documentType": blobDocumentType,
"versionId": blob.versionId,
"caseObj": casefolderID + "/" + casefolderID + "_case.json",
"isCurrentVersion": blob.isCurrentVersion,
"contentLength": blob.properties.contentLength,
"contentType": blob.contentType,
@@ -137,7 +138,7 @@ export const createBlob = async (formContent, containerName, caseref) => {
let caseID = formContent.pinswg_name;
const content = JSON.stringify(formContent);
const blobName = caseID + "/" + caseID + ".json";
const blobName = caseID + "/" + caseID + "_appeal.json";
console.log("blobName:", blobName);
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
@@ -280,6 +281,8 @@ export const downloadAllProgressFiles = async (
let blobClient = {};
let downloadedBlob = {};
let downloaded = "";
let caseBlob = {};
let caseDownloaded = "";
let blobCount = 0;
for (const prop in progressBlobObj) {
@@ -295,8 +298,29 @@ export const downloadAllProgressFiles = async (
downloaded = downloaded.substring(0, downloaded.length - 1);
//console.log(downloaded);
return '{ "@odata.count": ' + blobCount + ',"value": [' + downloaded + "]}";
for (const prop in progressBlobObj) {
//console.log(`${prop}: ${progressBlobObj[prop].caseObj}`);
blobClient = containerClient.getBlobClient(
progressBlobObj[prop].caseObj
);
caseBlob = await blobClient.download(0);
caseDownloaded =
caseDownloaded +
(await streamToBuffer(caseBlob.readableStreamBody)) +
",";
}
caseDownloaded = caseDownloaded.substring(0, caseDownloaded.length - 1);
return (
'{ "@odata.count": ' +
blobCount +
',"value": [' +
downloaded +
'],"case":[' +
caseDownloaded +
"]}"
);
};
const streamToBuffer = async (readableStream) => {
@@ -324,7 +348,6 @@ export const getCaseBlob = async (
creds
);
console.log("have got to create case");
containerClient.createIfNotExists();
let blobCount = 0;
@@ -335,7 +358,7 @@ export const getCaseBlob = async (
}
const content = JSON.stringify(formContent);
const blobName = caseReference + "/case/" + caseReference + ".json";
const blobName = caseReference + "/case/" + caseReference + "_case.json";
console.log("blobName:", blobName);
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
@@ -365,16 +388,18 @@ export const getProgressBlobs = async (containerName, caseReference) => {
blobCount++;
}
//console.log("this is the caasefolder:", caseReference, blobCount);
console.log("this is the caasefolder:", caseReference, blobCount);
let blobObj = [];
for await (const blob of containerClient.listBlobsFlat({
prefix: caseReference + "/" + caseReference + ".json",
prefix: caseReference + "/" + caseReference + "_appeal.json",
})) {
console.log("in here");
blobObj.push({
"name": blob.name.split("/")[1],
"path": blob.name,
"versionId": blob.versionId,
"caseObj": caseReference + "/" + caseReference + "_case.json",
"isCurrentVersion": blob.isCurrentVersion,
"contentLength": blob.properties.contentLength,
"contentType": blob.contentType,
@@ -444,6 +469,11 @@ export const getAllProgressBlobs = async (containerName) => {
"name": blob.name.split("/")[1],
"path": blob.name,
"versionId": blob.versionId,
"caseObj":
blob.name.split("/")[0] +
"/case/" +
blob.name.split("/")[0] +
"_case.json",
"isCurrentVersion": blob.isCurrentVersion,
"contentLength": blob.properties.contentLength,
"contentType": blob.contentType,