tango-app-api-audit 3.4.3-alpha.16 → 3.4.3-alpha.18

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-audit",
3
- "version": "3.4.3-alpha.16",
3
+ "version": "3.4.3-alpha.18",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -356,6 +356,7 @@ export async function getAuditFile( req, res ) {
356
356
  auditId: userDetails[0]._id,
357
357
  moduleType: userDetails[0].moduleType,
358
358
  zoneName: userDetails[0].zoneName,
359
+ beforeCount: userDetails[0].beforeCount,
359
360
  },
360
361
  createdAt: new Date(),
361
362
  };
@@ -458,6 +459,7 @@ export async function getAuditFile( req, res ) {
458
459
  auditId: reauditInsert._id,
459
460
  zoneName: msg.zone_id,
460
461
  moduleType: inputData.moduleType,
462
+ beforeCount: msg.total_count,
461
463
  },
462
464
  createdAt: new Date(),
463
465
  };
@@ -610,6 +612,7 @@ export async function getAuditFile( req, res ) {
610
612
  auditId: insertData._id,
611
613
  zoneName: msg.zone_id,
612
614
  moduleType: inputData.moduleType,
615
+ beforeCount: msg.total_count,
613
616
  },
614
617
  createdAt: new Date(),
615
618
  };
@@ -1660,21 +1663,22 @@ export async function userAuditHistory( req, res ) {
1660
1663
  chunk.forEach( ( element ) => {
1661
1664
  exportData.push( {
1662
1665
  'File Date': element.fileDate,
1663
- 'Brand ID': element.clientId,
1664
1666
  'Brand Name': element.clientName,
1665
- 'Store ID': element.storeId,
1667
+ 'Brand ID': element.clientId,
1666
1668
  'Store Name': element.storeName,
1669
+ 'Store ID': element.storeId,
1667
1670
  'Zone Name': element.moduleType == 'zone' ? element.zoneName : '',
1668
1671
  'Audit Type': element.auditType,
1669
1672
  'Product Type': element.moduleType,
1670
1673
  'Before Count': element.beforeCount,
1671
1674
  'After Count': element.afterCount || '',
1672
1675
  'Accuracy': element.accuracy || '',
1676
+ 'Audited Date': dayjs( element.createdAt ).format( 'YYYY,MMM D' ),
1673
1677
  'Start Time': element.startTime,
1674
1678
  'End Time': element.endTime || '',
1675
1679
  'Time Spent': element.timeSpent,
1676
- 'Audit Status': element.auditStatus,
1677
- 'Audited Date': dayjs( element.createdAt ).format( 'YYYY,MMM D' ),
1680
+ 'Status': element.auditStatus,
1681
+
1678
1682
 
1679
1683
  } );
1680
1684
  } );
@@ -3811,7 +3815,7 @@ export async function auditImages( req, res ) {
3811
3815
  export async function getUserAuditCount( req, res ) {
3812
3816
  try {
3813
3817
  const userWallet = JSON.parse( process.env.USER_WALLET );
3814
- const previousDate = dayjs( new Date() ).subtract( 1, 'days' );
3818
+ const previousDate = dayjs( new Date() ).subtract( 16, 'days' );
3815
3819
  const fileDate = dayjs( previousDate ).format( 'DD-MM-YYYY' );
3816
3820
  const configTimeSpentSec = userWallet.minTimeSpentSec; // 18000;
3817
3821
  const beforeCountX = userWallet.beforeCountCreditPerc; // 0.0335;
@@ -4040,16 +4044,16 @@ export async function getUserAuditCount( req, res ) {
4040
4044
  totalTimeSpent: {
4041
4045
  $cond: [ { $eq: [ '$hours', 0 ] },
4042
4046
  { $concat: [
4043
- { $toString: '$minutes' }, ' minutes',
4047
+ '00:', { $toString: '$minutes' }, ':00',
4044
4048
  ] },
4045
4049
  { $cond: [ { $eq: [ '$minutes', 0 ] },
4046
4050
  { $concat: [
4047
- { $toString: '$hours' }, ' hours',
4051
+ { $toString: '$hours' }, ':00:00',
4048
4052
  ] },
4049
4053
  {
4050
4054
  $concat: [
4051
- { $toString: '$hours' }, ' hours and ',
4052
- { $toString: '$minutes' }, ' minutes',
4055
+ { $toString: '$hours' }, ':',
4056
+ { $toString: '$minutes' }, ':00',
4053
4057
  ],
4054
4058
  },
4055
4059
  ] },
@@ -4451,8 +4455,12 @@ export async function auditViewLogs( req, res ) {
4451
4455
  'logData.moduleType.keyword': inputData.moduleType,
4452
4456
  },
4453
4457
  },
4458
+ {
4459
+ 'term': {
4460
+ 'logSubType.keyword': { $in: [ 'auditDone', 'reAuditPush', 'reTrigger' ] },
4461
+ },
4462
+ },
4454
4463
  ],
4455
-
4456
4464
  },
4457
4465
  },
4458
4466
  };
@@ -4461,7 +4469,7 @@ export async function auditViewLogs( req, res ) {
4461
4469
  logData.push( logs.body.hits.hits[0]._source );
4462
4470
  return res.sendSuccess( logData );
4463
4471
  } else {
4464
- return res.sendError( 'No Record Inserted', 500 );
4472
+ return res.sendError( 'No Record Inserted', 204 );
4465
4473
  }
4466
4474
  } catch ( error ) {
4467
4475
  const err = error.message || 'Internal Server Error';
@@ -1714,18 +1714,17 @@ export async function userAuditHistory( req, res ) {
1714
1714
  const temp ={
1715
1715
 
1716
1716
  'File Date': element.fileDate,
1717
- 'Brand ID': element.clientId,
1718
1717
  'Brand Name': element.clientName,
1719
- 'Store ID': element.storeId,
1718
+ 'Brand ID': element.clientId,
1720
1719
  'Store Name': element.storeName,
1720
+ 'Store ID': element.storeId,
1721
1721
  'Audit Type': element.auditType,
1722
1722
  'Product Type': element.value,
1723
+ 'Audited Date': dayjs( element.createdAt ).format( 'YYYY,MMM D' ),
1723
1724
  'Start Time': element.startTime,
1724
1725
  'End Time': element.endTime || '',
1725
1726
  'Time Spent': element.timeSpent,
1726
1727
  'Status': toCamelCase( element.auditStatus ),
1727
- 'Audited Date': dayjs( element.createdAt ).format( 'YYYY,MMM D' ),
1728
- 'Result': element.answer,
1729
1728
 
1730
1729
 
1731
1730
  };
@@ -2202,10 +2201,10 @@ export async function storeMetrics( req, res ) {
2202
2201
  question: 1,
2203
2202
  questionType: 1,
2204
2203
  answer: 1,
2205
- // userId: {
2206
- // $arrayElemAt: [ '$userId', { $subtract: [ { $size: '$userId' }, 1 ] } ], //need to check if no data
2207
- // },
2208
- userId: 1,
2204
+ userId: {
2205
+ $arrayElemAt: [ '$userId', { $subtract: [ { $size: '$userId' }, 1 ] } ], // need to check if no data
2206
+ },
2207
+ // userId: 1,
2209
2208
  auditType: 1,
2210
2209
  beforeCount: 1,
2211
2210
  afterCount: { $ifNull: [ '$afterCount', null ] },