tango-app-api-audit 3.4.69-beta.0 → 3.5.1

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.69-beta.0",
3
+ "version": "3.5.1",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -27,7 +27,7 @@
27
27
  "nodemon": "^3.1.3",
28
28
  "swagger-ui-express": "^5.0.1",
29
29
  "tango-api-schema": "^2.2.113",
30
- "tango-app-api-middleware": "^3.1.75",
30
+ "tango-app-api-middleware": "^3.1.76",
31
31
  "winston": "^3.13.0",
32
32
  "winston-daily-rotate-file": "^5.0.0"
33
33
  },
@@ -65,7 +65,7 @@ import { aggregateBinaryAudit } from '../service/binaryAudit.service.js';
65
65
  import { aggregateTraxAuditData, findOneTraxAuditData } from '../service/traxAuditData.service.js';
66
66
  import { bulkWriteAuditUserWallet, createAuditUserWallet, findOneAuditUserWallet } from '../service/auditUserWallet.service.js';
67
67
  import { updateOneAuditUsers } from '../service/auditUsers.service.js';
68
- import { bulkUpdate, clearScroll, scrollResponse, searchOpenSearchData } from 'tango-app-api-middleware/src/utils/openSearch.js';
68
+ import { bulkUpdate, clearScroll, upsertOpenSearchData, scrollResponse, searchOpenSearchData } from 'tango-app-api-middleware/src/utils/openSearch.js';
69
69
  // import { aggregateAuditUsers } from '../service/auditUsers.service.js';
70
70
 
71
71
  /* < -- *** Configuration *** --> */
@@ -539,7 +539,7 @@ export async function getAuditFile( req, res ) {
539
539
 
540
540
  const getQuery = {
541
541
  size: inputData?.limit || 2,
542
- _source: [ 'module', 'date', 'store_id', 'outputCluster', 'personPath', 'isEmployee' ], // Only fetch necessary fields
542
+ _source: [ 'module', 'date', 'store_id', 'outputCluster', 'personPath', 'isEmployee', 'isJunk' ], // Only fetch necessary fields
543
543
 
544
544
  query: {
545
545
  bool: {
@@ -547,6 +547,9 @@ export async function getAuditFile( req, res ) {
547
547
  {
548
548
  term: { 'store_id.keyword': msg.store_id },
549
549
  },
550
+ // {
551
+ // term: { isJunk: false },
552
+ // },
550
553
  {
551
554
  term: { isEmployee: false },
552
555
  },
@@ -1530,7 +1533,7 @@ export async function save( req, res ) {
1530
1533
  const temp = getData?.body?.hits?.hits?.map( ( item ) => item._id );
1531
1534
  const body = temp.flatMap( ( id ) => [
1532
1535
  { update: { _index: 'tracker_process', _id: id } },
1533
- { doc: { outputCluster: imgName } },
1536
+ { doc: { outputCluster: imgName, isEmployee: false, isJunk: false } },
1534
1537
  ] );
1535
1538
  const re= await bulkUpdate( body );
1536
1539
  logger.info( { re: re } );
@@ -1669,22 +1672,34 @@ export async function save( req, res ) {
1669
1672
  timeSpent: inputData.timeSpent,
1670
1673
  },
1671
1674
  );
1672
- const sqsProduceQueue = {
1673
- QueueUrl: ( auditConfig?.isCheckMinAfterCount ==1 && inputData.customerCount > auditConfig?.minAfterCount ) ? `${sqs.url}${sqs.feature_new}`: `${sqs.url}${sqs.feature}`,
1674
- MessageBody: JSON.stringify( {
1675
- store_id: inputData.storeId,
1676
- store_date: inputData.fileDate,
1677
- bucket_name: `${bucket.auditUploadBucket}`,
1678
- zone_id: inputData.zoneName,
1679
- process_type: 'audit',
1680
- } ),
1681
- };
1682
- logger.info( { sqsProduceQueue: sqsProduceQueue } );
1683
- const sqsQueue = await sendMessageToQueue(
1684
- sqsProduceQueue.QueueUrl,
1685
- sqsProduceQueue.MessageBody,
1686
- );
1687
- logger.info( { sqsQueue: sqsQueue } );
1675
+ if ( inputData.moduleType !== 'track' ) {
1676
+ const sqsProduceQueue = {
1677
+ QueueUrl: ( auditConfig?.isCheckMinAfterCount ==1 && inputData.customerCount > auditConfig?.minAfterCount ) ? `${sqs.url}${sqs.feature_new}`: `${sqs.url}${sqs.feature}`,
1678
+ MessageBody: JSON.stringify( {
1679
+ store_id: inputData.storeId,
1680
+ store_date: inputData.fileDate,
1681
+ bucket_name: `${bucket.auditUploadBucket}`,
1682
+ zone_id: inputData.zoneName,
1683
+ process_type: 'audit',
1684
+ } ),
1685
+ };
1686
+ logger.info( { sqsProduceQueue: sqsProduceQueue } );
1687
+ const sqsQueue = await sendMessageToQueue(
1688
+ sqsProduceQueue.QueueUrl,
1689
+ sqsProduceQueue.MessageBody,
1690
+ );
1691
+ logger.info( { sqsQueue: sqsQueue } );
1692
+ } else {
1693
+ const query =
1694
+ { 'module': 'REID-TRACKER-V1',
1695
+ 'store_date_time': `${inputData.storeId}_${inputData.fileDate}_23:00`,
1696
+ 'status': 'POSTPROCESS_AUDIT_SUCCESS',
1697
+ 'status_time': Date.now(),
1698
+ 'timestamp': new Date() };
1699
+
1700
+
1701
+ await upsertOpenSearchData( 'tracker_process', `${inputData.storeId}_${inputData.fileDate}_23:00`, { doc: query } );
1702
+ }
1688
1703
  }
1689
1704
 
1690
1705
  return res.sendSuccess( { result: 'Updated Successfully' } );
@@ -3552,36 +3567,8 @@ export async function overviewTable( req, res ) {
3552
3567
  afterCount: 1,
3553
3568
  auditType: 1,
3554
3569
  status: 1,
3555
- // userId: 1,
3556
- },
3557
- },
3558
- // {
3559
- // $lookup: {
3560
- // from: 'users',
3561
- // let: { userId: '$userId' },
3562
- // pipeline: [
3563
- // {
3564
- // $match: {
3565
- // $expr: {
3566
- // $eq: [ '$_id', '$$userId' ],
3567
- // },
3568
- // },
3569
- // },
3570
- // {
3571
- // $project: {
3572
- // userName: 1,
3573
- // userEmail: '$email',
3574
- // },
3575
- // },
3576
- // ], as: 'user',
3577
- // },
3578
- // },
3579
- // {
3580
- // $unwind: {
3581
- // path: '$user',
3582
- // preserveNullAndEmptyArrays: true,
3583
- // },
3584
- // },
3570
+ },
3571
+ },
3585
3572
  {
3586
3573
  $project: {
3587
3574
  storeId: 1,
@@ -3593,8 +3580,6 @@ export async function overviewTable( req, res ) {
3593
3580
  afterCount: 1,
3594
3581
  auditType: 1,
3595
3582
  status: 1,
3596
- // userName: '$user.userName',
3597
- // userEmail: '$user.userEmail',
3598
3583
 
3599
3584
  },
3600
3585
  },
@@ -3610,8 +3595,6 @@ export async function overviewTable( req, res ) {
3610
3595
  { status: { $regex: inputData.searchValue, $options: 'i' } },
3611
3596
  { moduleType: { $regex: inputData.searchValue, $options: 'i' } },
3612
3597
  { zoneName: { $regex: inputData.searchValue, $options: 'i' } },
3613
- // { userName: { $regex: inputData.searchValue, $options: 'i' } },
3614
- // { userEmail: { $regex: inputData.searchValue, $options: 'i' } },
3615
3598
  ],
3616
3599
 
3617
3600
  },
@@ -4733,38 +4716,42 @@ export async function auditViewLogs( req, res ) {
4733
4716
  let logsQuery;
4734
4717
  const parsedOpenSearch = JSON.parse( process.env.OPENSEARCH );
4735
4718
  const logData =[];
4736
- if ( inputData.moduleType == 'traffic' ||inputData.moduleType == 'zone' ) {
4719
+ if ( inputData.moduleType == 'traffic' ||inputData.moduleType == 'zone'||inputData.moduleType == 'track' ) {
4720
+ const filter = [
4721
+ {
4722
+ 'term': {
4723
+ 'logData.fileDate.keyword': inputData.fileDate,
4724
+ },
4725
+ },
4726
+ {
4727
+ 'term': {
4728
+ 'logData.storeId.keyword': inputData.storeId,
4729
+ },
4730
+ },
4731
+ {
4732
+ 'term': {
4733
+ 'logData.moduleType.keyword': inputData.moduleType,
4734
+ },
4735
+ },
4736
+ {
4737
+ 'terms': {
4738
+ 'logSubType.keyword': [ 'auditDone', 'reTrigger' ],
4739
+ },
4740
+ },
4741
+ ];
4742
+ if ( inputData.moduleType !== 'track' ) {
4743
+ filter.push( {
4744
+ 'term': {
4745
+ 'logData.zoneName.keyword': inputData.zoneName,
4746
+ },
4747
+ } );
4748
+ }
4749
+
4737
4750
  logsQuery = {
4738
4751
  'size': 100,
4739
4752
  'query': {
4740
4753
  'bool': {
4741
- 'must': [
4742
- {
4743
- 'term': {
4744
- 'logData.fileDate.keyword': inputData.fileDate,
4745
- },
4746
- },
4747
- {
4748
- 'term': {
4749
- 'logData.storeId.keyword': inputData.storeId,
4750
- },
4751
- },
4752
- {
4753
- 'term': {
4754
- 'logData.moduleType.keyword': inputData.moduleType,
4755
- },
4756
- },
4757
- {
4758
- 'term': {
4759
- 'logData.zoneName.keyword': inputData.zoneName,
4760
- },
4761
- },
4762
- {
4763
- 'terms': {
4764
- 'logSubType.keyword': [ 'auditDone', 'reTrigger' ],
4765
- },
4766
- },
4767
- ],
4754
+ 'must': filter,
4768
4755
  },
4769
4756
  },
4770
4757
  };