tango-app-api-report 3.0.10-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.10-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",
@@ -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 {
@@ -269,11 +273,11 @@ export async function uploadManualReport( req, res ) {
269
273
  Bucket: appConfig.cloud.aws.bucket.reportBucket,
270
274
  Key: `reports/${inputData.fileDate}/${data.reportName}/`,
271
275
  fileName: inputData.fileName,
272
- Body: req.files.files.data,
276
+ body: req.files.files.data,
273
277
  };
274
278
  const result = await fileUpload( uploadDataParams );
275
279
  logger.info( { result: result, value: 'file upload response' } );
276
- if ( !result ) {
280
+ if ( result.Error ) {
277
281
  return res.sendError( 'File Upload Failed', 500 );
278
282
  }
279
283
  let user = await findOneUser( { _id: req.user._id, isActive: true } );
@@ -314,10 +318,14 @@ export async function getReportList( req, res ) {
314
318
  const folderPath = await listFileByPath( fetchData );
315
319
 
316
320
  logger.info( { folderPath: folderPath, value: 'report list from bucket' } );
317
- if ( folderPath.length == 0 ) {
321
+ if ( folderPath?.data?.length == 0 ) {
318
322
  return res.sendError( 'No Reports Found', 204 );
319
323
  }
320
- 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 } );
321
329
  } catch ( error ) {
322
330
  logger.error( { error: error, message: req.query, function: 'getReportList' } );
323
331
  return res.sendError( error, 500 );