tango-app-api-audit 3.5.0 → 3.5.2

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.5.0",
3
+ "version": "3.5.2",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -543,13 +543,11 @@ export async function getAuditFile( req, res ) {
543
543
 
544
544
  query: {
545
545
  bool: {
546
- must: [
546
+ 'must': [
547
547
  {
548
548
  term: { 'store_id.keyword': msg.store_id },
549
549
  },
550
- // {
551
- // term: { isJunk: false },
552
- // },
550
+
553
551
  {
554
552
  term: { isEmployee: false },
555
553
  },
@@ -560,6 +558,11 @@ export async function getAuditFile( req, res ) {
560
558
  term: { 'module.keyword': 'CUSTOMER' },
561
559
  },
562
560
  ],
561
+ 'should': [
562
+ { 'term': { 'isJunk': false } },
563
+ { 'bool': { 'must_not': { 'exists': { 'field': 'isJunk' } } } },
564
+ ],
565
+ 'minimum_should_match': 1,
563
566
  },
564
567
  },
565
568
 
@@ -618,7 +621,7 @@ export async function getAuditFile( req, res ) {
618
621
  userId: req.user._id,
619
622
  storeId: msg.store_id,
620
623
  clientId: msg.store_id.split( '-' )[0],
621
- auditType: 'Audit',
624
+ auditType: msg.audit_type || 'Audit',
622
625
  fileDate: msg.curr_date,
623
626
  queueName: inputData.queueName,
624
627
  beforeCount: msg.total_count || files.length,
@@ -639,7 +642,7 @@ export async function getAuditFile( req, res ) {
639
642
  userId: req.user._id,
640
643
  storeId: msg.store_id,
641
644
  clientId: msg.store_id.split( '-' )[0],
642
- auditType: 'Audit',
645
+ auditType: msg.audit_type ||'Audit',
643
646
  fileDate: msg.curr_date,
644
647
  queueName: inputData.queueName,
645
648
  beforeCount: msg.total_count || files.length,
@@ -705,7 +708,7 @@ export async function getAuditFile( req, res ) {
705
708
  queueName: inputData.queueName,
706
709
  store_id: storeId,
707
710
  file_date: fileDate,
708
- type: 'Audit',
711
+ type: msg.audit_type || 'Audit',
709
712
  auditId: insertData._id,
710
713
  userId: insertData.userId,
711
714
  zoneName: msg.zone_id,
@@ -1694,7 +1697,7 @@ export async function save( req, res ) {
1694
1697
  { 'module': 'REID-TRACKER-V1',
1695
1698
  'store_date_time': `${inputData.storeId}_${inputData.fileDate}_23:00`,
1696
1699
  'status': 'POSTPROCESS_AUDIT_SUCCESS',
1697
- 'status_time': Date.now(),
1700
+ 'status_time': Math.floor( Date.now() / 1000 ),
1698
1701
  'timestamp': new Date() };
1699
1702
 
1700
1703
 
@@ -3109,7 +3112,7 @@ export async function reTrigger( req, res ) {
3109
3112
  zoneName: inputData.zoneName,
3110
3113
  };
3111
3114
  const getQueueName = await findOneClient( { clientId: req.audit.clientId }, { 'auditConfigs': 1 } );
3112
- const queueName = inputData.moduleType == 'zone' ? getQueueName?.auditConfigs?.zoneQueueName : getQueueName?.auditConfigs?.trafficQueueName;
3115
+ const queueName = inputData.moduleType == 'zone' ? getQueueName?.auditConfigs?.zoneQueueName :inputData.moduleType == 'track'?getQueueName?.auditConfigs?.trackQueueName: getQueueName?.auditConfigs?.trafficQueueName;
3113
3116
  if ( !getQueueName || queueName == '' ) {
3114
3117
  return res.sendError( 'queueName does not create', 400 );
3115
3118
  }
@@ -3567,36 +3570,8 @@ export async function overviewTable( req, res ) {
3567
3570
  afterCount: 1,
3568
3571
  auditType: 1,
3569
3572
  status: 1,
3570
- // userId: 1,
3571
- },
3572
- },
3573
- // {
3574
- // $lookup: {
3575
- // from: 'users',
3576
- // let: { userId: '$userId' },
3577
- // pipeline: [
3578
- // {
3579
- // $match: {
3580
- // $expr: {
3581
- // $eq: [ '$_id', '$$userId' ],
3582
- // },
3583
- // },
3584
- // },
3585
- // {
3586
- // $project: {
3587
- // userName: 1,
3588
- // userEmail: '$email',
3589
- // },
3590
- // },
3591
- // ], as: 'user',
3592
- // },
3593
- // },
3594
- // {
3595
- // $unwind: {
3596
- // path: '$user',
3597
- // preserveNullAndEmptyArrays: true,
3598
- // },
3599
- // },
3573
+ },
3574
+ },
3600
3575
  {
3601
3576
  $project: {
3602
3577
  storeId: 1,
@@ -3608,8 +3583,6 @@ export async function overviewTable( req, res ) {
3608
3583
  afterCount: 1,
3609
3584
  auditType: 1,
3610
3585
  status: 1,
3611
- // userName: '$user.userName',
3612
- // userEmail: '$user.userEmail',
3613
3586
 
3614
3587
  },
3615
3588
  },
@@ -3625,8 +3598,6 @@ export async function overviewTable( req, res ) {
3625
3598
  { status: { $regex: inputData.searchValue, $options: 'i' } },
3626
3599
  { moduleType: { $regex: inputData.searchValue, $options: 'i' } },
3627
3600
  { zoneName: { $regex: inputData.searchValue, $options: 'i' } },
3628
- // { userName: { $regex: inputData.searchValue, $options: 'i' } },
3629
- // { userEmail: { $regex: inputData.searchValue, $options: 'i' } },
3630
3601
  ],
3631
3602
 
3632
3603
  },
@@ -4748,38 +4719,42 @@ export async function auditViewLogs( req, res ) {
4748
4719
  let logsQuery;
4749
4720
  const parsedOpenSearch = JSON.parse( process.env.OPENSEARCH );
4750
4721
  const logData =[];
4751
- if ( inputData.moduleType == 'traffic' ||inputData.moduleType == 'zone' ) {
4722
+ if ( inputData.moduleType == 'traffic' ||inputData.moduleType == 'zone'||inputData.moduleType == 'track' ) {
4723
+ const filter = [
4724
+ {
4725
+ 'term': {
4726
+ 'logData.fileDate.keyword': inputData.fileDate,
4727
+ },
4728
+ },
4729
+ {
4730
+ 'term': {
4731
+ 'logData.storeId.keyword': inputData.storeId,
4732
+ },
4733
+ },
4734
+ {
4735
+ 'term': {
4736
+ 'logData.moduleType.keyword': inputData.moduleType,
4737
+ },
4738
+ },
4739
+ {
4740
+ 'terms': {
4741
+ 'logSubType.keyword': [ 'auditDone', 'reTrigger' ],
4742
+ },
4743
+ },
4744
+ ];
4745
+ if ( inputData.moduleType !== 'track' ) {
4746
+ filter.push( {
4747
+ 'term': {
4748
+ 'logData.zoneName.keyword': inputData.zoneName,
4749
+ },
4750
+ } );
4751
+ }
4752
+
4752
4753
  logsQuery = {
4753
4754
  'size': 100,
4754
4755
  'query': {
4755
4756
  'bool': {
4756
- 'must': [
4757
- {
4758
- 'term': {
4759
- 'logData.fileDate.keyword': inputData.fileDate,
4760
- },
4761
- },
4762
- {
4763
- 'term': {
4764
- 'logData.storeId.keyword': inputData.storeId,
4765
- },
4766
- },
4767
- {
4768
- 'term': {
4769
- 'logData.moduleType.keyword': inputData.moduleType,
4770
- },
4771
- },
4772
- {
4773
- 'term': {
4774
- 'logData.zoneName.keyword': inputData.zoneName,
4775
- },
4776
- },
4777
- {
4778
- 'terms': {
4779
- 'logSubType.keyword': [ 'auditDone', 'reTrigger' ],
4780
- },
4781
- },
4782
- ],
4757
+ 'must': filter,
4783
4758
  },
4784
4759
  },
4785
4760
  };
@@ -173,7 +173,11 @@ export async function isAuditInputFolderExist( req, res, next ) {
173
173
  Bucket: bucket.auditInput,
174
174
  Key: `${inputData.fileDate}/${inputData.storeId}/${inputData.zoneName}`,
175
175
  };
176
- const isExist = await checkFileExist( params );
176
+ const trackParams={
177
+ Bucket: 'v4rnd-audit-input-images',
178
+ Key: `${inputData.storeId}/${inputData.fileDate}`,
179
+ };
180
+ const isExist = await checkFileExist( inputData.moduleType == 'track'? trackParams:params );
177
181
  if ( isExist ) {
178
182
  next();
179
183
  } else {