tango-app-api-report 3.0.11-dev → 3.0.12-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.11-dev",
3
+ "version": "3.0.12-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.103",
28
- "tango-app-api-middleware": "^1.0.81-dev",
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( 'tango-retail-activity-logs', logObj );
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( 'tango-retail-activity-logs', logObj );
100
+ await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
89
101
  if ( updateAck ) {
90
102
  res.sendSuccess( { result: 'Updated Successfully' } );
91
103
  }
@@ -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.length == 0 ) {
321
+ if ( folderPath?.data?.length == 0 ) {
310
322
  return res.sendError( 'No Reports Found', 204 );
311
323
  }
312
- return res.sendSuccess( { result: folderPath } );
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 );