get pending reps to dashboard from St Acc

This commit is contained in:
2023-01-16 09:56:37 +00:00
parent ee4d00a500
commit 0c1de7d26b
7 changed files with 239 additions and 34 deletions
+81 -1
View File
@@ -41,7 +41,7 @@ export const createContainerSas = async (containerName) => {
);
// Need only list permission to list blobs
const containerPermissions = "rcwltd";
const containerPermissions = "rcwltdf";
// Best practice: SAS options are time-limited
const sasOptions = {
@@ -472,6 +472,50 @@ export const downloadAllProgressFiles = async (
);
};
export const downloadAllRepsFiles = async (containerName, repsBlobObj) => {
console.log(
"/////////////////////////\n downloading files: " +
JSON.stringify(repsBlobObj) +
"\n/////////////////////////\n"
);
const containerToken = await createContainerSas(containerName);
const sasUrl = `${STORAGE_PATH}/${containerName}?${containerToken}`;
const containerClient = new ContainerClient(sasUrl);
let blobClient = {};
let downloadedBlob = {};
let repArr = [];
let downloaded = "";
let caseBlob = {};
let caseDownloaded = "";
let blobCount = 0;
for (const prop in repsBlobObj) {
console.log(`Progress - ${prop}: ${repsBlobObj[prop].name}`);
blobClient = containerClient.getBlobClient(repsBlobObj[prop].name);
downloadedBlob = await blobClient.download(0);
let repBlobObj = await streamToBuffer(
downloadedBlob.readableStreamBody
);
repBlobObj = JSON.parse(repBlobObj);
repBlobObj["casereference"] = repsBlobObj[prop].name.split("/")[0];
repBlobObj = JSON.stringify(repBlobObj);
downloaded = downloaded + repBlobObj + ",";
blobCount++;
}
downloaded = downloaded.substring(0, downloaded.length - 1);
return JSON.parse(
'{ "@odata.count": ' + blobCount + ',"value": [' + downloaded + "]}"
);
};
const streamToBuffer = async (readableStream) => {
return new Promise((resolve, reject) => {
const chunks = [];
@@ -605,3 +649,39 @@ export const getAllProgressBlobs = async (containerName) => {
return blobObj;
};
export const getRepslobs = async (containerName, caseReference) => {
const containerToken = await createContainerSas(containerName);
const sasUrl = `${STORAGE_PATH}/${containerName}?${containerToken}`;
const containerClient = new ContainerClient(sasUrl);
let blobCount = 0;
for await (const blob of containerClient.findBlobsByTags(
"blobType='Representation'"
)) {
blobCount++;
}
console.log("this is the caasefolder:", caseReference, blobCount);
let blobObj = [];
for await (const blob of containerClient.findBlobsByTags(
"blobType='Representation'"
)) {
console.log("in here");
console.log(blob);
blobObj.push(blob);
}
// blobObj = _.sortBy(blobObj, [
// function (o) {
// return o.lastModified;
// },
// ]).reverse()[0];
console.log("blobObjwwwww:", blobObj);
return blobObj;
};
+21
View File
@@ -793,6 +793,27 @@ export const getAwaitingSubmissionFromBlob = (containerName) => {
});
};
export const getRepsFromBlob = (containerName) => {
console.log(
"///////////////////////getRepsFromBlob: " +
containerName +
"\n///////////////////////\n"
);
return axios
.get(
BASE_URL +
"/api/file/getrepsblob?container=" +
containerName +
hashAPIPath("/api/file/getrepsblob?container=" + containerName)
)
.then((res) => {
return res.data;
})
.catch((error) => {
//console.log("API call error", error);
});
};
export const getAwaitingSubmissionFromBlobProxy = (containerName) => {
return axios
.get(