tango-app-api-audit 1.0.58 → 1.0.59

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/app.js ADDED
@@ -0,0 +1,38 @@
1
+ import express from 'express';
2
+ import { auditRouter } from './index.js';
3
+ import dotenv from 'dotenv';
4
+ import { logger } from 'tango-app-api-middleware';
5
+ import { connectdb } from './config/database/database.js';
6
+ import responseMiddleware from './config/response/response.js';
7
+ import errorMiddleware from './config/response/error.js';
8
+ import pkg from 'body-parser';
9
+ import { swaggerConfig } from './config/swagger/swagger.js';
10
+ import swagger from 'swagger-ui-express';
11
+
12
+ const { json, urlencoded } = pkg;
13
+ const env=dotenv.config();
14
+
15
+ const app = express();
16
+ const PORT = process.env.PORT || 3000;
17
+
18
+
19
+ app.use( json( { limit: '500mb' } ) );
20
+ app.use(
21
+ urlencoded( {
22
+ extended: true,
23
+ } ),
24
+ );
25
+ app.use( responseMiddleware );
26
+ app.use( errorMiddleware );
27
+ if ( env.error ) {
28
+ logger.error( '.env not found' );
29
+ process.exit( 1 );
30
+ }
31
+ app.use( '/api-docs', swagger.serve, swagger.setup( swaggerConfig ) );
32
+ app.use( '/v3/audit', auditRouter );
33
+
34
+ app.listen( PORT, () => {
35
+ logger.info( `server is running on port= ${PORT} ` );
36
+ connectdb();
37
+ } );
38
+
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "tango-app-api-audit",
3
- "version": "1.0.58",
3
+ "version": "1.0.59",
4
4
  "description": "audit & audit metrics apis",
5
- "main": "index.js",
5
+ "main": "app.js",
6
6
  "type": "module",
7
7
  "scripts": {
8
- "start": "nodemon --exec \"eslint --fix . && node index.js\""
8
+ "start": "nodemon --exec \"eslint --fix . && node app.js\""
9
9
  },
10
10
  "engines": {
11
11
  "node": ">=18.10.0"
@@ -1277,12 +1277,12 @@ export async function save( req, res ) {
1277
1277
  return res.sendError( mappingUpload, 500 );
1278
1278
  }
1279
1279
 
1280
- let getUserAuditData = await findOneUserAudit( {
1281
- _id: new mongoose.Types.ObjectId( inputData.auditId ),
1282
- moduleType: inputData.moduleType,
1283
- zoneName: inputData.zoneName,
1284
- } );
1285
- const isoDate = getUserAuditData.startTime;
1280
+ // let getUserAuditData = await findOneUserAudit( {
1281
+ // _id: new mongoose.Types.ObjectId( inputData.auditId ),
1282
+ // // moduleType: inputData.moduleType,
1283
+ // // zoneName: inputData.zoneName,
1284
+ // } );
1285
+ const isoDate = userAudit?.startTime;
1286
1286
  const currentTime = dayjs();
1287
1287
  const isoDateTime = dayjs( isoDate );
1288
1288
  const timeDifferenceInMinutes = currentTime.diff( isoDateTime, 'seconds' );
@@ -1307,7 +1307,7 @@ export async function save( req, res ) {
1307
1307
 
1308
1308
  let storeConfig = await findOneStore(
1309
1309
  {
1310
- storeId: getUserAuditData.storeId,
1310
+ storeId: userAudit?.storeId,
1311
1311
  },
1312
1312
  {
1313
1313
  auditConfigs: 1,
@@ -1316,11 +1316,8 @@ export async function save( req, res ) {
1316
1316
  );
1317
1317
 
1318
1318
  let clientData = await findClient( { clientId: storeConfig.clientId } );
1319
-
1320
- if (
1321
- ( storeAuditData.beforeCount - inputData.customerCount ) /
1322
- storeAuditData.beforeCount <
1323
- storeConfig.auditConfigs.ratio &&
1319
+ const ratio = ( ( storeAuditData.beforeCount - inputData.customerCount ) / storeAuditData.beforeCount ) * 100;
1320
+ if ( ratio < storeConfig.auditConfigs.ratio &&
1324
1321
  inputData.auditType == 'Audit' &&
1325
1322
  inputData.moduleType == 'traffic'
1326
1323
  ) {
@@ -1377,7 +1374,7 @@ export async function save( req, res ) {
1377
1374
  fileDate: inputData.fileDate,
1378
1375
  moduleType: inputData.moduleType,
1379
1376
  zoneName: inputData.zoneName,
1380
- auditType: inputData.auditType,
1377
+ // auditType: inputData.auditType,
1381
1378
  },
1382
1379
  {
1383
1380
  status: 'completed',
@@ -2756,7 +2753,7 @@ export async function reTrigger( req, res ) {
2756
2753
  }
2757
2754
 
2758
2755
  const storeRecord ={
2759
- status: req.audit.status !== 'completed' ? 'skipped': 'not_assign',
2756
+ status: 'not_assign',
2760
2757
  };
2761
2758
 
2762
2759
  await updateOneStoreAudit( query, storeRecord );
@@ -2816,7 +2813,7 @@ export async function reTrigger( req, res ) {
2816
2813
  }
2817
2814
 
2818
2815
  const storeRecord ={
2819
- status: req.audit.status !== 'completed' ? 'skipped': 'assigned',
2816
+ status: 'assigned',
2820
2817
  };
2821
2818
 
2822
2819
  await updateOneStoreAudit( query, storeRecord );