tango-app-api-audit 3.4.11-alpha.20 → 3.4.11-alpha.22

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.11-alpha.20",
3
+ "version": "3.4.11-alpha.22",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1613,7 +1613,7 @@ export async function saveBinary( req, res ) {
1613
1613
  question: req.userAudit?.question,
1614
1614
  result: req.userAudit?.answer,
1615
1615
  endTime: Date.now(),
1616
- timeSpent:timeDifferenceInMinutes,
1616
+ timeSpent: timeDifferenceInMinutes,
1617
1617
  auditId: new mongoose.Types.ObjectId( inputData.auditId ),
1618
1618
  },
1619
1619
  createdAt: Date.now(),
@@ -4519,7 +4519,7 @@ export async function save( req, res ) {
4519
4519
  const storeUpdated ={
4520
4520
  status: 'completed',
4521
4521
  afterCount: inputData.employeeCount,
4522
- timeSpent:timeDifferenceInMinutes,
4522
+ timeSpent: timeDifferenceInMinutes,
4523
4523
  };
4524
4524
  logger.info( { query: query, function: 'saveQuery' } );
4525
4525
  const [ userUpdate, storeUpdate ] = await Promise.all( [ updateOneUserEmpDetection( { _id: inputData.auditId }, userUpdated ), updateOneStoreEmpDetection( query, storeUpdated ) ] );
@@ -4541,7 +4541,7 @@ export async function save( req, res ) {
4541
4541
  tempId.push( inputData?.employee[i].img_id );
4542
4542
  }
4543
4543
  }
4544
- const getStore = await findOneStore( { storeId: inputData.storeId }, { storeName: 1 } );
4544
+ const [ getStore, getClient ] = await Promise.all( [ findOneStore( { storeId: inputData.storeId }, { storeName: 1, storeProfile: 1, spocDetails: 1 } ), findOneClient( { clientId: inputData.clientId }, { clientName: 1 } ) ] );
4545
4545
  const sqsProduceQueue = {
4546
4546
  QueueUrl: `${sqs.url}${sqs.uniformOutput}`,
4547
4547
  MessageBody: JSON.stringify( {
@@ -4568,6 +4568,25 @@ export async function save( req, res ) {
4568
4568
  return res.sendError( 'SQS not sent', 500 );
4569
4569
  }
4570
4570
 
4571
+ // trax output in open serach
4572
+ const output = {
4573
+ clientId: inputData.clientId,
4574
+ clientName: getClient?.clientName,
4575
+ storeId: inputData.storeId,
4576
+ storeName: getStore?.storeName,
4577
+ spocName: getStore?.spocDetails[0]?.name,
4578
+ spocEmail: getStore?.spocDetails[0]?.email,
4579
+ spocContact: getStore?.spocDetails[0].contact,
4580
+ address: getStore?.storeProfile?.address,
4581
+ fileDate: inputData.fileDate,
4582
+ moduleType: inputData.moduleType,
4583
+ inputBucketName: getFilePath?.sqs?.Body?.inputBucketName,
4584
+ tempId: tempId,
4585
+ count: inputData.employeeCount,
4586
+ folderPath: getFilePath?.sqs?.Body?.folderPath,
4587
+ createdAt: new Date(),
4588
+ };
4589
+ await insertOpenSearchData( openSearch.traxDetectionOutput, output );
4571
4590
  const logData = {
4572
4591
  userId: req.user._id,
4573
4592
  userName: req.user.userName,
@@ -4584,7 +4603,7 @@ export async function save( req, res ) {
4584
4603
  afterCount: inputData.employeeCount,
4585
4604
  startTime: req.userAudit?.startTime,
4586
4605
  endTime: Date.now(),
4587
- timeSpent:timeDifferenceInMinutes,
4606
+ timeSpent: timeDifferenceInMinutes,
4588
4607
  auditId: new mongoose.Types.ObjectId( inputData.auditId ),
4589
4608
  },
4590
4609
  createdAt: Date.now(),