tango-app-api-audit 3.4.0-alpha.12 → 3.4.0-alpha.14

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.0-alpha.12",
3
+ "version": "3.4.0-alpha.14",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -60,6 +60,7 @@ import {
60
60
  } from '../service/auditStoreData.service.js';
61
61
  import { aggregateStoreEmpDetection } from '../service/storeEmpDetection.service.js';
62
62
  import { aggregateBinaryAudit } from '../service/binaryAudit.service.js';
63
+ import { aggregateTraxAuditData, findOneTraxAuditData } from '../service/traxAuditData.service.js';
63
64
 
64
65
  /* < -- *** Configuration *** --> */
65
66
 
@@ -3386,6 +3387,15 @@ export async function totalNotAssignedCount( req, res ) {
3386
3387
  { createdAt: -1 },
3387
3388
  );
3388
3389
  const latestDate = getStoreData?.fileDate || dayjs( fileDate ).format( 'DD-MM-YYYY' );
3390
+
3391
+ const geTraxData = await findOneTraxAuditData(
3392
+ {},
3393
+ { fileDate: 1 },
3394
+ { createdAt: -1 },
3395
+ );
3396
+ const latestTraxDate = geTraxData?.fileDate || dayjs( fileDate ).format( 'DD-MM-YYYY' );
3397
+ logger.info( { geTraxData: geTraxData } );
3398
+
3389
3399
  const query = [
3390
3400
  {
3391
3401
  $match: {
@@ -3421,6 +3431,52 @@ export async function totalNotAssignedCount( req, res ) {
3421
3431
  },
3422
3432
  },
3423
3433
  ];
3434
+ const traxQuery = [
3435
+ {
3436
+ $match: {
3437
+ fileDate: { $eq: latestTraxDate },
3438
+ },
3439
+ },
3440
+ {
3441
+ $project: {
3442
+ totalUnattendedCustomerCount: { $cond: [
3443
+ { $eq: [ '$moduleType', 'unattended-customer' ] }, 1, 0,
3444
+ ] },
3445
+ totalLeftInMiddleCount: { $cond: [
3446
+ { $eq: [ '$moduleType', 'left-in-middle' ] }, 1, 0,
3447
+ ] },
3448
+ totalUniformDetectionCount: { $cond: [
3449
+ { $eq: [ '$moduleType', 'uniform-detection' ] }, 1, 0,
3450
+ ] },
3451
+ totalMobileDetectionCount: { $cond: [
3452
+ { $eq: [ '$moduleType', 'mobile-detection' ] }, 1, 0,
3453
+ ] },
3454
+
3455
+ },
3456
+ },
3457
+ {
3458
+ $group: {
3459
+ _id: null,
3460
+ totalTraxAuditCount: { $sum: 1 },
3461
+ totalUnattendedCustomerCount: { $sum: '$totalUnattendedCustomerCount' },
3462
+ totalLeftInMiddleCount: { $sum: '$totalLeftInMiddleCount' },
3463
+ totalUniformDetectionCount: { $sum: '$totalUniformDetectionCount' },
3464
+ totalMobileDetectionCount: { $sum: '$totalMobileDetectionCount' },
3465
+
3466
+
3467
+ },
3468
+ },
3469
+ {
3470
+ $project: {
3471
+ _id: 0,
3472
+ totalTraxAuditCount: 1,
3473
+ totalUnattendedCustomerCount: 1,
3474
+ totalLeftInMiddleCount: 1,
3475
+ totalUniformDetectionCount: 1,
3476
+ totalMobileDetectionCount: 1,
3477
+ },
3478
+ },
3479
+ ];
3424
3480
  const inprogressCount=[
3425
3481
  {
3426
3482
  $match: {
@@ -3461,13 +3517,95 @@ export async function totalNotAssignedCount( req, res ) {
3461
3517
  },
3462
3518
  },
3463
3519
  ];
3520
+ // const binaryInprogressCount=[
3521
+ // {
3522
+ // $match: {
3523
+ // fileDate: { $eq: latestDate },
3524
+ // },
3525
+ // },
3526
+ // {
3527
+ // $project: {
3528
+ // inprogressAuditCount: {
3529
+ // $cond: [
3530
+ // { $in: [ '$status', [ 'completed', 'not_assign', 'skipped' ] ] }, 1, 0,
3531
+ // ],
3532
+ // },
3533
+ // inprogressZoneCount: { $cond: [
3534
+ // { $and: [ { $eq: [ '$moduleType', 'zone' ] }, { $in: [ '$status', [ 'completed', 'not_assign', 'skipped' ] ] } ] }, 1, 0,
3535
+ // ] },
3536
+ // inprogressTrafficCount: { $cond: [
3537
+ // { $and: [ { $eq: [ '$moduleType', 'traffic' ] }, { $in: [ '$status', [ 'completed', 'not_assign', 'skipped' ] ] } ] }, 1, 0,
3538
+ // ] },
3539
+
3540
+ // },
3541
+ // },
3542
+ // {
3543
+ // $group: {
3544
+ // _id: null,
3545
+ // inprogressAuditCount: { $sum: '$inprogressAuditCount' },
3546
+ // inprogressZoneCount: { $sum: '$inprogressZoneCount' },
3547
+ // inprogressTrafficCount: { $sum: '$inprogressTrafficCount' },
3548
+
3549
+ // },
3550
+ // },
3551
+ // {
3552
+ // $project: {
3553
+ // _id: 0,
3554
+ // inprogressAuditCount: { $ifNull: [ '$inprogressAuditCount', 0 ] },
3555
+ // inprogressZoneCount: { $ifNull: [ '$inprogressZoneCount', 0 ] },
3556
+ // inprogressTrafficCount: { $ifNull: [ '$inprogressTrafficCount', 0 ] },
3557
+ // },
3558
+ // },
3559
+ // ];
3560
+ // const mappingInprogressCount=[
3561
+ // {
3562
+ // $match: {
3563
+ // fileDate: { $eq: latestDate },
3564
+ // },
3565
+ // },
3566
+ // {
3567
+ // $project: {
3568
+ // inprogressAuditCount: {
3569
+ // $cond: [
3570
+ // { $in: [ '$status', [ 'completed', 'not_assign', 'skipped' ] ] }, 1, 0,
3571
+ // ],
3572
+ // },
3573
+ // inprogressZoneCount: { $cond: [
3574
+ // { $and: [ { $eq: [ '$moduleType', 'zone' ] }, { $in: [ '$status', [ 'completed', 'not_assign', 'skipped' ] ] } ] }, 1, 0,
3575
+ // ] },
3576
+ // inprogressTrafficCount: { $cond: [
3577
+ // { $and: [ { $eq: [ '$moduleType', 'traffic' ] }, { $in: [ '$status', [ 'completed', 'not_assign', 'skipped' ] ] } ] }, 1, 0,
3578
+ // ] },
3579
+
3580
+ // },
3581
+ // },
3582
+ // {
3583
+ // $group: {
3584
+ // _id: null,
3585
+ // inprogressAuditCount: { $sum: '$inprogressAuditCount' },
3586
+ // inprogressZoneCount: { $sum: '$inprogressZoneCount' },
3587
+ // inprogressTrafficCount: { $sum: '$inprogressTrafficCount' },
3588
+
3589
+ // },
3590
+ // },
3591
+ // {
3592
+ // $project: {
3593
+ // _id: 0,
3594
+ // inprogressAuditCount: { $ifNull: [ '$inprogressAuditCount', 0 ] },
3595
+ // inprogressZoneCount: { $ifNull: [ '$inprogressZoneCount', 0 ] },
3596
+ // inprogressTrafficCount: { $ifNull: [ '$inprogressTrafficCount', 0 ] },
3597
+ // },
3598
+ // },
3599
+ // ];
3464
3600
  const getTotalcount = await aggregateAuditStoreData( query );
3465
-
3601
+ const getTotalTraxAudit = await aggregateTraxAuditData( traxQuery );
3466
3602
  const getInprogressCount = await aggregateStoreAudit( inprogressCount );
3467
- if ( getTotalcount.length == 0 ) {
3603
+ // const getBinaryInprogressCount = await aggregateBinaryAudit( binaryInprogressCount );
3604
+ // const getMappingInprogressCount = await aggregateStoreEmpDetection( mappingInprogressCount );
3605
+ if ( getTotalcount.length == 0 && getTotalTraxAudit.length == 0 ) {
3468
3606
  return res.sendError( 'No Data Found', 204 );
3469
3607
  }
3470
-
3608
+ logger.info( { getTotalTraxAudit: getTotalTraxAudit } );
3471
3609
  if ( getInprogressCount.length >0 ) {
3472
3610
  notAssignedCount.totalAuditCount = getTotalcount[0].totalAuditCount - getInprogressCount[0]?.inprogressAuditCount;
3473
3611
  notAssignedCount.totalZoneCount = getTotalcount[0].totalZoneCount - getInprogressCount[0]?.inprogressZoneCount;
@@ -3477,6 +3615,7 @@ export async function totalNotAssignedCount( req, res ) {
3477
3615
  notAssignedCount.totalZoneCount = getTotalcount[0].totalZoneCount;
3478
3616
  notAssignedCount.totalTrafficCount= getTotalcount[0].totalTrafficCount;
3479
3617
  }
3618
+ notAssignedCount.totalTraxAuditCount = getTotalTraxAudit[0]?.totalTraxAuditCount;
3480
3619
  return res.sendSuccess( { result: notAssignedCount } );
3481
3620
  } catch ( error ) {
3482
3621
  const err = error.message || 'Internal Server Error';
@@ -1,4 +1,4 @@
1
- import { checkFileExist, download, getDate, getDateWithCustomizeTime, getUTC, insertOpenSearchData, listFileByPath, logger, signedUrl, sqsReceive } from 'tango-app-api-middleware';
1
+ import { checkFileExist, chunkArray, download, getDate, getDateWithCustomizeTime, getUTC, insertOpenSearchData, listFileByPath, logger, signedUrl, sqsReceive } from 'tango-app-api-middleware';
2
2
  import { aggregateBinaryAudit, createBinaryAudit, updateOneBinaryAuditModel } from '../service/binaryAudit.service.js';
3
3
  import { countDocumentsStore, findOneStore } from '../service/store.service.js';
4
4
  import { findOneUser } from '../service/user.service.js';
@@ -619,6 +619,48 @@ export async function workSpace( req, res ) {
619
619
  },
620
620
  ];
621
621
 
622
+ const binarCompletedStores = [
623
+ {
624
+ $match: {
625
+ $and: [
626
+ { clientId: { $in: clientList } },
627
+ { fileDate: { $eq: latestDate } },
628
+ { moduleType: { $eq: inputData.moduleType } },
629
+ ],
630
+ },
631
+ },
632
+ {
633
+ $project: {
634
+ clientId: 1,
635
+ completed: {
636
+ $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, 1, 0 ],
637
+ },
638
+ },
639
+ },
640
+ // {
641
+ // $group: {
642
+ // _id: { clientId: '$clientId', storeId: '$storeId' },
643
+ // clientId: { $first: '$clientId' },
644
+ // completedStoresCount: { $sum: '$completed' },
645
+ // },
646
+ // },
647
+ {
648
+ $group: {
649
+ _id: '$clientId',
650
+ clientId: { $first: '$clientId' },
651
+ // completedStoresCount: { $first: '$completedStoresCount' },
652
+ completedStoresCount: { $sum: '$completed' },
653
+ },
654
+ },
655
+ {
656
+ $project: {
657
+ _id: 0,
658
+ clientId: 1,
659
+ completedStoresCount: 1,
660
+ },
661
+ },
662
+ ];
663
+
622
664
  const auditFiles = [
623
665
  {
624
666
  $match: {
@@ -754,7 +796,7 @@ export async function workSpace( req, res ) {
754
796
  const auditUserCount = inputData.moduleType.includes( [ 'uniform-detection', 'mobile-detection' ] )?await aggregateUserEmpDetection( auditFiles ) : await aggregateBinaryAudit( auditFiles );
755
797
  const userIncompleteFilesCount = inputData.moduleType.includes( [ 'uniform-detection', 'mobile-detection' ] )?await aggregateUserEmpDetection( userIncompleteFiles ) : await aggregateBinaryAudit( userIncompleteFiles );
756
798
  const userAsignAuditCount = await aggregateAssignAudit( userAsignAudit );
757
- const completedStoresCount = inputData.moduleType.includes( [ 'uniform-detection', 'mobile-detection' ] )? await aggregateStoreEmpDetection( completedStores ) : await aggregateBinaryAudit( completedStores );
799
+ const completedStoresCount = inputData.moduleType.includes( [ 'uniform-detection', 'mobile-detection' ] )? await aggregateStoreEmpDetection( completedStores ) : await aggregateBinaryAudit( binarCompletedStores );
758
800
  const clientAssignedCount = await aggregateAssignAudit( clientAssign );
759
801
  const auditStoreData = await aggregateTraxAuditData(
760
802
  auditStoreDataQuery,
@@ -1170,7 +1212,7 @@ export async function saveBinary( req, res ) {
1170
1212
  };
1171
1213
  let updatDataunattended= await updateOneBinaryAuditModel( unattendedquery, update );
1172
1214
  if ( updatDataunattended.modifiedCount==0 ) {
1173
- return res.sendError( updatDataunattended, 204 );
1215
+ return res.sendError( 'Update failed, it may be invalid request', 400 );
1174
1216
  }
1175
1217
  logger.info( 'update in binary data', { query: unattendedquery, update: update } );
1176
1218
  res.sendSuccess( `Successfully update in ${inputData.moduleType} ` );
@@ -1194,7 +1236,7 @@ export async function saveBinary( req, res ) {
1194
1236
  };
1195
1237
  let updatDataleft= await updateOneBinaryAuditModel( leftquery, leftupdate );
1196
1238
  if ( updatDataleft.modifiedCount==0 ) {
1197
- return res.sendError( updatDataleft, 204 );
1239
+ return res.sendError( 'Update failed, it may be invalid request', 400 );
1198
1240
  }
1199
1241
  logger.info( 'update in binary data', { query: leftquery, update: leftupdate } );
1200
1242
  res.sendSuccess( `Successfully update in ${inputData.moduleType} ` );
@@ -1218,7 +1260,7 @@ export async function saveBinary( req, res ) {
1218
1260
  };
1219
1261
  let updatDatacamera= await updateOneBinaryAuditModel( cameraquery, cameraupdate );
1220
1262
  if ( updatDatacamera.modifiedCount==0 ) {
1221
- return res.sendError( updatDatacamera, 204 );
1263
+ return res.sendError( 'Update failed, it may be invalid request', 400 );
1222
1264
  }
1223
1265
  logger.info( 'update in binary data', { query: cameraquery, update: cameraupdate } );
1224
1266
  res.sendSuccess( `Successfully update in ${inputData.moduleType} ` );
@@ -1959,6 +2001,189 @@ export async function storeMetrics( req, res ) {
1959
2001
 
1960
2002
  ];
1961
2003
 
2004
+ const binaryQuery = [
2005
+ {
2006
+ $match: {
2007
+ $and: filter,
2008
+ },
2009
+ },
2010
+
2011
+ {
2012
+ $lookup: {
2013
+ from: 'stores',
2014
+ let: { storeId: '$storeId' },
2015
+ pipeline: [
2016
+ {
2017
+ $match: {
2018
+ $expr: {
2019
+ $eq: [ '$storeId', '$$storeId' ],
2020
+ },
2021
+ },
2022
+ },
2023
+ {
2024
+ $project: {
2025
+ _id: 0,
2026
+ storeName: 1,
2027
+ },
2028
+ },
2029
+ ], as: 'stores',
2030
+ },
2031
+ },
2032
+ {
2033
+ $unwind: {
2034
+ path: '$stores',
2035
+ preserveNullAndEmptyArrays: true,
2036
+ },
2037
+ },
2038
+ {
2039
+ $project: {
2040
+ auditId: '$_id',
2041
+ _id: 0,
2042
+ fileDate: 1,
2043
+ storeId: 1,
2044
+ storeName: '$stores.storeName',
2045
+ clientName: '',
2046
+ clientId: 1,
2047
+ moduleType: 1,
2048
+ value: {
2049
+ $replaceAll: { input: '$moduleType', find: '-', replacement: ' ' },
2050
+ },
2051
+ tempId: 1,
2052
+ streamName: 1,
2053
+ question: 1,
2054
+ questionType: 1,
2055
+ answer: 1,
2056
+ // userId: {
2057
+ // $arrayElemAt: [ '$userId', { $subtract: [ { $size: '$userId' }, 1 ] } ], //need to check if no data
2058
+ // },
2059
+ userId: 1,
2060
+ auditType: 1,
2061
+ beforeCount: 1,
2062
+ afterCount: { $ifNull: [ '$afterCount', null ] },
2063
+ accuracy: { $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, { $round: [
2064
+ {
2065
+ $multiply: [ { $divide: [ '$afterCount', '$beforeCount' ] }, 100 ],
2066
+ }, 1,
2067
+ ],
2068
+ }, null ] },
2069
+ timeSpent: 1,
2070
+ status: 1,
2071
+ auditStatus: 1,
2072
+ },
2073
+ },
2074
+ {
2075
+ $lookup: {
2076
+ from: 'users',
2077
+ let: { userId: '$userId' },
2078
+ pipeline: [
2079
+ {
2080
+ $match: {
2081
+ $expr: {
2082
+ $eq: [ '$_id', '$$userId' ],
2083
+ },
2084
+ },
2085
+ },
2086
+ {
2087
+ $project: {
2088
+ _id: 0,
2089
+ userName: 1,
2090
+ userEmail: '$email',
2091
+ },
2092
+ },
2093
+ ], as: 'users',
2094
+ },
2095
+ },
2096
+ {
2097
+ $unwind: {
2098
+ path: '$users',
2099
+ preserveNullAndEmptyArrays: true,
2100
+ },
2101
+ },
2102
+ {
2103
+ $lookup: {
2104
+ from: 'clients',
2105
+ let: { clientId: '$clientId' },
2106
+ pipeline: [
2107
+ {
2108
+ $match: {
2109
+ $expr: {
2110
+ $eq: [ '$clientId', '$$clientId' ],
2111
+ },
2112
+ },
2113
+ },
2114
+ {
2115
+ $project: {
2116
+ _id: 0,
2117
+ clientName: 1,
2118
+ },
2119
+ },
2120
+ ], as: 'client',
2121
+ },
2122
+ },
2123
+ {
2124
+ $unwind: {
2125
+ path: '$client',
2126
+ preserveNullAndEmptyArrays: true,
2127
+ },
2128
+ },
2129
+ {
2130
+ $project: {
2131
+ auditId: 1,
2132
+ fileDate: 1,
2133
+ storeId: 1,
2134
+ storeName: 1,
2135
+ userName: '$users.userName',
2136
+ userEmail: '$users.userEmail',
2137
+ clientId: 1,
2138
+ clientName: '$client.clientName',
2139
+ tempId: 1,
2140
+ streamName: 1,
2141
+ question: 1,
2142
+ questionType: 1,
2143
+ answer: 1,
2144
+ moduleType: 1,
2145
+ value: 1,
2146
+ auditType: 1,
2147
+ beforeCount: 1,
2148
+ afterCount: { $ifNull: [ '$afterCount', null ] },
2149
+ accuracy: { $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, { $round: [
2150
+ {
2151
+ $multiply: [ { $divide: [ '$afterCount', '$beforeCount' ] }, 100 ],
2152
+ }, 1,
2153
+ ],
2154
+ }, null ] },
2155
+ timeSpent: {
2156
+
2157
+ $cond: [
2158
+ { $lt: [ '$timeSpent', 60 ] }, // Case 1: If less than 60 seconds
2159
+ { $concat: [ { $toString: '$timeSpent' }, ' sec' ] },
2160
+ {
2161
+ $cond: [
2162
+ { $lt: [ '$timeSpent', 3600 ] }, // Case 2: If less than 60 minutes (3600 seconds)
2163
+ {
2164
+ $concat: [
2165
+ { $toString: { $round: [ { $divide: [ '$timeSpent', 60 ] }, 1 ] } }, // Convert to minutes
2166
+ ' min',
2167
+ ],
2168
+ },
2169
+ {
2170
+ $concat: [
2171
+ { $toString: { $round: [ { $divide: [ '$timeSpent', 3600 ] }, 1 ] } }, // Convert to hours
2172
+ ' hr',
2173
+ ],
2174
+ },
2175
+ ],
2176
+ },
2177
+ ],
2178
+
2179
+ },
2180
+ status: 1,
2181
+ auditStatus: 1,
2182
+ },
2183
+ },
2184
+
2185
+ ];
2186
+
1962
2187
  if ( inputData.searchValue && inputData.searchValue !== '' ) {
1963
2188
  query.push( {
1964
2189
  $match: {
@@ -1988,7 +2213,7 @@ export async function storeMetrics( req, res ) {
1988
2213
  },
1989
2214
  );
1990
2215
  }
1991
- const count = inputData.moduleType.includes( [ 'uniform-detection', 'mobile-detection' ] )?await aggregateStoreEmpDetection( query ) : await aggregateBinaryAudit( query );
2216
+ const count = inputData.moduleType.includes( [ 'uniform-detection', 'mobile-detection' ] )?await aggregateStoreEmpDetection( query ) : await aggregateBinaryAudit( binaryQuery );
1992
2217
 
1993
2218
  if ( count.length == 0 ) {
1994
2219
  return res.sendError( 'No data Found', 204 );
@@ -2669,7 +2894,57 @@ export async function overAllAuditSummary( req, res ) {
2669
2894
  },
2670
2895
  },
2671
2896
  ];
2672
- const storeAudit = inputData.moduleType.includes( [ 'uniform-detection', 'mobile-detection' ] )?await aggregateStoreEmpDetection( storeAuditQuery ) : await aggregateBinaryAudit( storeAuditQuery );
2897
+
2898
+ const binaryAuditQuery =[
2899
+ {
2900
+ $match: {
2901
+ $and: filters,
2902
+ },
2903
+
2904
+ },
2905
+ {
2906
+ $project: {
2907
+ completedStores: { $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, 1, 0 ] },
2908
+ auditInprogress: { $cond: [ { $and: [ { $in: [ '$auditStatus', [ 'inprogress' ] ] }, { $eq: [ '$auditType', 'Audit' ] } ] }, 1, 0 ] },
2909
+ reAuditInprogress: { $cond: [ { $and: [ { $in: [ '$auditStatus', [ 'inprogress' ] ] }, { $eq: [ '$auditType', 'ReAudit' ] } ] }, 1, 0 ] },
2910
+ draft: { $cond: [ { $eq: [ '$auditStatus', 'drafted' ] }, 1, 0 ] },
2911
+ assigned: { $cond: [ { $eq: [ '$auditStatus', 'assigned' ] }, 1, 0 ] },
2912
+ exceptNoAssigned: { $cond: { if: { $not: { $in: [ '$auditStatus', [ 'skipped', 'not_assign' ] ] } }, then: 1, else: 0 } },
2913
+ auditCompleted: { $cond: [ { $and: [ { $in: [ '$auditStatus', [ 'completed' ] ] }, { $eq: [ '$auditType', 'Audit' ] } ] }, 1, 0 ] },
2914
+ reAuditCompleted: { $cond: [ { $and: [ { $in: [ '$auditStatus', [ 'completed' ] ] }, { $eq: [ '$auditType', 'ReAudit' ] } ] }, 1, 0 ] },
2915
+
2916
+
2917
+ },
2918
+ },
2919
+ {
2920
+ $group: {
2921
+ _id: null,
2922
+ completedStores: { $sum: '$completedStores' },
2923
+ auditInprogress: { $sum: '$auditInprogress' },
2924
+ reAuditInprogress: { $sum: '$reAuditInprogress' },
2925
+ draft: { $sum: '$draft' },
2926
+ assigned: { $sum: '$assigned' },
2927
+ exceptNoAssigned: { $sum: '$exceptNoAssigned' },
2928
+ auditCompleted: { $sum: '$auditCompleted' },
2929
+ reAuditCompleted: { $sum: '$reAuditCompleted' },
2930
+ },
2931
+ },
2932
+ {
2933
+ $project: {
2934
+ completedStores: 1,
2935
+ inprogressStores: { $subtract: [ temp.auditStores, '$completedStores' ] },
2936
+ auditInprogress: 1,
2937
+ reAuditInprogress: 1,
2938
+ draft: 1,
2939
+ assigned: 1,
2940
+ exceptNoAssigned: { $subtract: [ temp.auditStores, '$exceptNoAssigned' ] },
2941
+ auditCompleted: 1,
2942
+ reAuditCompleted: 1,
2943
+ },
2944
+ },
2945
+ ];
2946
+
2947
+ const storeAudit = inputData.moduleType.includes( [ 'uniform-detection', 'mobile-detection' ] )?await aggregateStoreEmpDetection( storeAuditQuery ) : await aggregateBinaryAudit( binaryAuditQuery );
2673
2948
  if ( storeAudit.length > 0 ) {
2674
2949
  temp.inprogressStores= storeAudit[0].inprogressStores;
2675
2950
  temp.completedStores = storeAudit[0].completedStores;