tango-app-api-report 3.0.11-dev → 3.0.13-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-report",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.13-dev",
|
|
4
4
|
"description": "report",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"aws-sdk": "^2.1578.0",
|
|
17
17
|
"cors": "^2.8.5",
|
|
18
|
+
"dayjs": "^1.11.11",
|
|
18
19
|
"dotenv": "^16.4.5",
|
|
19
20
|
"express": "^4.18.3",
|
|
20
21
|
"express-fileupload": "^1.5.0",
|
|
@@ -24,8 +25,8 @@
|
|
|
24
25
|
"nodemailer": "^6.9.13",
|
|
25
26
|
"nodemon": "^3.1.0",
|
|
26
27
|
"swagger-ui-express": "^5.0.0",
|
|
27
|
-
"tango-api-schema": "^2.0.
|
|
28
|
-
"tango-app-api-middleware": "^1.0.
|
|
28
|
+
"tango-api-schema": "^2.0.104",
|
|
29
|
+
"tango-app-api-middleware": "^1.0.73-test",
|
|
29
30
|
"winston": "^3.12.0",
|
|
30
31
|
"winston-daily-rotate-file": "^5.0.0"
|
|
31
32
|
},
|
|
@@ -3,11 +3,15 @@ import { appConfig, fileUpload, getObject, getOpenSearchData, insertOpenSearchDa
|
|
|
3
3
|
import { findOneUser, getUserNameEmailById } from '../service/user.service.js';
|
|
4
4
|
import { updateOneBasePriceModel } from '../service/basePrice.service.js';
|
|
5
5
|
import { aggregateClient } from '../service/client.service.js';
|
|
6
|
+
import utc from 'dayjs/plugin/utc.js';
|
|
7
|
+
import timezone from 'dayjs/plugin/timezone.js';
|
|
6
8
|
import aws from 'aws-sdk';
|
|
7
9
|
import * as nodemailer from 'nodemailer';
|
|
10
|
+
import dayjs from 'dayjs';
|
|
8
11
|
|
|
9
12
|
// import basePricingModel from 'tango-api-schema/schema/basePricing.model.js';
|
|
10
|
-
|
|
13
|
+
dayjs.extend( utc );
|
|
14
|
+
dayjs.extend( timezone );
|
|
11
15
|
|
|
12
16
|
export async function createReport( req, res ) {
|
|
13
17
|
try {
|
|
@@ -26,9 +30,10 @@ export async function createReport( req, res ) {
|
|
|
26
30
|
logSubType: 'reportConfig',
|
|
27
31
|
changes: [ `${req.body?.fileName}` ],
|
|
28
32
|
eventType: 'create',
|
|
33
|
+
showTo: [ 'tango' ],
|
|
29
34
|
};
|
|
30
35
|
|
|
31
|
-
await insertOpenSearchData(
|
|
36
|
+
await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
32
37
|
if ( createReport ) {
|
|
33
38
|
res.sendSuccess( { result: 'Created Successfully' } );
|
|
34
39
|
}
|
|
@@ -68,6 +73,9 @@ export async function getSingleReport( req, res ) {
|
|
|
68
73
|
|
|
69
74
|
export async function updateReport( req, res ) {
|
|
70
75
|
try {
|
|
76
|
+
const previousReport = await reportGetSingle( {
|
|
77
|
+
_id: req.params?.id,
|
|
78
|
+
} );
|
|
71
79
|
const updateAck = await reportUpdate( {
|
|
72
80
|
_id: req.params?.id, fileType: req.body?.fileType, email: req.body?.email, clientId: req.body?.clientId,
|
|
73
81
|
} );
|
|
@@ -83,9 +91,13 @@ export async function updateReport( req, res ) {
|
|
|
83
91
|
logSubType: 'reportConfig',
|
|
84
92
|
changes: [ `Report id ${req.params?.id}` ],
|
|
85
93
|
eventType: 'update',
|
|
94
|
+
showTo: [ 'tango' ],
|
|
95
|
+
current: req.body,
|
|
96
|
+
previous: previousReport,
|
|
97
|
+
|
|
86
98
|
};
|
|
87
99
|
|
|
88
|
-
await insertOpenSearchData(
|
|
100
|
+
await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
89
101
|
if ( updateAck ) {
|
|
90
102
|
res.sendSuccess( { result: 'Updated Successfully' } );
|
|
91
103
|
}
|
|
@@ -202,7 +214,7 @@ export async function generateReport( req, res ) {
|
|
|
202
214
|
QueueUrl: `${appConfig.cloud.aws.sqs.url}${appConfig.cloud.aws.sqs.generateReport}`,
|
|
203
215
|
MessageBody: JSON.stringify( {
|
|
204
216
|
file_date: inputData.fileDate,
|
|
205
|
-
client_name:
|
|
217
|
+
client_name: req.report?.reportConfigs?.reportName,
|
|
206
218
|
client_id: Number( inputData.clientId ),
|
|
207
219
|
message: 'good to trigger',
|
|
208
220
|
} ),
|
|
@@ -216,9 +228,9 @@ export async function generateReport( req, res ) {
|
|
|
216
228
|
logType: 'report',
|
|
217
229
|
logSubType: 'generateReport',
|
|
218
230
|
logData: {
|
|
219
|
-
clientName:
|
|
231
|
+
clientName: req.report?.clientName,
|
|
220
232
|
fileDate: inputData.fileDate,
|
|
221
|
-
reportName:
|
|
233
|
+
reportName: req.report?.reportConfigs?.reportName,
|
|
222
234
|
clientId: inputData.ClientId,
|
|
223
235
|
sqsMessageId: sqsQueue.MessageId,
|
|
224
236
|
},
|
|
@@ -259,7 +271,7 @@ export async function uploadManualReport( req, res ) {
|
|
|
259
271
|
logger.info( { files: req.files } );
|
|
260
272
|
const uploadDataParams = {
|
|
261
273
|
Bucket: appConfig.cloud.aws.bucket.reportBucket,
|
|
262
|
-
Key: `reports/${inputData.fileDate}/${
|
|
274
|
+
Key: `reports/${inputData.fileDate}/${req.report?.reportConfigs?.reportName}/`,
|
|
263
275
|
fileName: inputData.fileName,
|
|
264
276
|
body: req.files.files.data,
|
|
265
277
|
};
|
|
@@ -280,7 +292,7 @@ export async function uploadManualReport( req, res ) {
|
|
|
280
292
|
logSubType: 'uploadReport',
|
|
281
293
|
logData: {
|
|
282
294
|
fileDate: inputData.fileDate,
|
|
283
|
-
reportName:
|
|
295
|
+
reportName: req.report?.reportConfigs?.reportName,
|
|
284
296
|
clientId: data.clientId,
|
|
285
297
|
},
|
|
286
298
|
};
|
|
@@ -306,10 +318,14 @@ export async function getReportList( req, res ) {
|
|
|
306
318
|
const folderPath = await listFileByPath( fetchData );
|
|
307
319
|
|
|
308
320
|
logger.info( { folderPath: folderPath, value: 'report list from bucket' } );
|
|
309
|
-
if ( folderPath
|
|
321
|
+
if ( folderPath?.data?.length == 0 ) {
|
|
310
322
|
return res.sendError( 'No Reports Found', 204 );
|
|
311
323
|
}
|
|
312
|
-
|
|
324
|
+
let temp =[];
|
|
325
|
+
for ( const item of folderPath.data ) {
|
|
326
|
+
temp.push( { Key: item.Key, LastModified: dayjs( item.LastModified ).tz( 'Asia/Kolkata' ).format( 'YYYY-MM-DD HH:mm:ss' ) } );
|
|
327
|
+
}
|
|
328
|
+
return res.sendSuccess( { result: temp } );
|
|
313
329
|
} catch ( error ) {
|
|
314
330
|
logger.error( { error: error, message: req.query, function: 'getReportList' } );
|
|
315
331
|
return res.sendError( error, 500 );
|
|
@@ -358,7 +374,7 @@ export async function sendReport( req, res ) {
|
|
|
358
374
|
for ( const data of getReportList ) {
|
|
359
375
|
const fetchData = {
|
|
360
376
|
Bucket: appConfig.cloud.aws.bucket.reportBucket,
|
|
361
|
-
Key: `reports/${inputData.fileDate}/${
|
|
377
|
+
Key: `reports/${inputData.fileDate}/${req.report?.reportConfigs?.reportName}/${inputData.fileDate}_${data.fileName}.${data.fileType}`,
|
|
362
378
|
};
|
|
363
379
|
reportName.push( `${inputData.fileDate}_${data.fileName}` );
|
|
364
380
|
name.push( `${data.fileName}` );
|
|
@@ -407,7 +423,7 @@ export async function sendReport( req, res ) {
|
|
|
407
423
|
QueueUrl: `${appConfig.cloud.aws.sqs.url}${appConfig.cloud.aws.sqs.sendReport}`,
|
|
408
424
|
MessageBody: JSON.stringify( {
|
|
409
425
|
file_date: inputData.fileDate,
|
|
410
|
-
client_name:
|
|
426
|
+
client_name: req.report?.reportConfigs?.reportName,
|
|
411
427
|
client_id: Number( inputData.clientId ),
|
|
412
428
|
file_name: regionalKey,
|
|
413
429
|
report_name: name,
|
|
@@ -424,7 +440,7 @@ export async function sendReport( req, res ) {
|
|
|
424
440
|
logSubType: 'sendReport',
|
|
425
441
|
logData: {
|
|
426
442
|
fileDate: inputData.fileDate,
|
|
427
|
-
reportName:
|
|
443
|
+
reportName: req.report?.reportConfigs?.reportName,
|
|
428
444
|
clientId: getReportList[0].clientId,
|
|
429
445
|
},
|
|
430
446
|
};
|