Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/ReportGeneration-Opti-New' into …
Browse files Browse the repository at this point in the history
…main-prod
  • Loading branch information
abhinovpankaj committed Dec 16, 2023
2 parents 89d6c90 + 5d5d52b commit a6ae37c
Show file tree
Hide file tree
Showing 27 changed files with 1,612 additions and 457 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ npm-debug.log
package-lock.json
test/*.log
.env
git rm --cached .env
git rm --cached .env
.cache/
.gitignore
9 changes: 9 additions & 0 deletions .idea/DeckInspector-nodeJS-web-services.iml

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

8 changes: 8 additions & 0 deletions .idea/modules.xml

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

6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

6 changes: 4 additions & 2 deletions database/mongo.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ var Connect = async function () {
module.exports.ProjectDocuments = client.db(dbName).collection('ProjectDocuments');

module.exports.ProjectReports = client.db(dbName).collection('ProjectReports');
module.exports.InvasiveSections = client.db(dbName).collection('InvasiveSection');
module.exports.ConclusiveSections = client.db(dbName).collection('ConclusiveSection');
module.exports.InvasiveSections = client.db(dbName).collection('LocalInvasiveSection');
module.exports.ConclusiveSections = client.db(dbName).collection('LocalConclusiveSection');
module.exports.ProjectReportHashCode = client.db(dbName).collection('ProjectReportHashCode');


// //module.exports.ClientInfo = db.collection('clientInfo');
console.log('Connected to MongoDB');
} catch (e) {
Expand Down
20 changes: 3 additions & 17 deletions database/uploadimage.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const account = process.env.AZURE_STORAGE_ACCOUNT_NAME;
//const defaultAzureCredential = new DefaultAzureCredential();

const blobServiceClient = BlobServiceClient.fromConnectionString(process.env.STORAGE_CONNECTION_STRING);
const blobServiceClientOld = BlobServiceClient.fromConnectionString(process.env.OLD_STORAGE_CONNECTION_STRING);

async function uploadFile(containerName, blobName, localFileWithPath, uploadOptions) {

try {
Expand All @@ -38,21 +38,7 @@ async function uploadFile(containerName, blobName, localFileWithPath, uploadOpti

}

async function getBlobBufferFromOld(blobName,containerName) {
const containerClient = blobServiceClientOld.getContainerClient(containerName);
blobName= blobName.replace('%20',' ');
const blobClient = containerClient.getBlobClient(blobName);

// Get blob content from position 0 to the end
// In Node.js, get downloaded data by accessing downloadBlockBlobResponse.readableStreamBody
const downloadBlockBlobResponse = await blobClient.download();
const downloaded = (
await streamToBuffer(downloadBlockBlobResponse.readableStreamBody)
);


return downloaded;
}

async function getBlobBuffer(blobName,containerName) {
const containerClient = blobServiceClient.getContainerClient(containerName);
blobName= blobName.replace('%20',' ');
Expand Down Expand Up @@ -82,5 +68,5 @@ async function streamToBuffer(readableStream) {
readableStream.on("error", reject);
});
}
module.exports = { uploadFile ,getBlobBuffer,getBlobBufferFromOld};
module.exports = { uploadFile ,getBlobBuffer};

32 changes: 32 additions & 0 deletions model/projectReportHashCodeDAO.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"use strict";
var ObjectId = require('mongodb').ObjectId;
var mongo = require('../database/mongo');

module.exports= {
addProjectReportHashCode: async (project) => {
const result = await mongo.ProjectReportHashCode.insertOne(project);
console.log(result);
return result;
},
getProjectReportHashCodeById: async(projectId) => {
const result = await mongo.ProjectReportHashCode.findOne({projectId: projectId});
if(result && result.data)
{
return result.data;
}
},
deleteProjectReportHashCodeById: async(projectId) => {
return await mongo.ProjectReportHashCode.deleteOne({ projectId: projectId });
},
getProjectReportHashCodeByIdAndReportType: async(projectId,reportType) => {
const result = await mongo.ProjectReportHashCode.findOne({projectId: projectId,reportType:reportType});
if(result && result.data)
{
return result.data;
}
},

deleteProjectReportHashCodeByIdAndReportType: async(projectId,reportType) => {
return await mongo.ProjectReportHashCode.deleteOne({ projectId: projectId,reportType:reportType });
}
}
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
"dependencies": {
"@azure/identity": "^3.1.3",
"@azure/storage-blob": "^12.13.0",
"axios": "^1.5.1",
"bcrypt": "^5.1.0",
"body-parser": "^1.20.1",
"cors": "^2.8.5",
"crypto": "^1.0.1",
"docx-merger": "^1.2.2",
"docx-templates": "^4.11.3",
"docxtemplater": "^3.38.0",
Expand All @@ -33,13 +35,16 @@
"jpeg-autorotate": "^9.0.0",
"jsonwebtoken": "^9.0.0",
"jspdf": "^2.5.1",
"lodash": "^4.17.21",
"mongodb": "^4.13.0",
"mongoose": "^7.1.0",
"multer": "^1.4.5-lts.1",
"nodemon": "^2.0.22",
"object-hash": "^3.0.0",
"passport": "^0.6.0",
"pizzip": "^3.1.4",
"puppeteer": "^20.7.4",
"serialize-javascript": "^6.0.1",
"swagger-jsdoc": "^6.2.8",
"swagger-ui-express": "^4.6.0",
"uuid": "^9.0.1"
Expand Down
Loading

0 comments on commit a6ae37c

Please sign in to comment.