tango-app-api-trax 3.6.0-task-4 → 3.6.1-runai-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-trax",
3
- "version": "3.6.0-task-4",
3
+ "version": "3.6.1-runai-2",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -26,7 +26,7 @@
26
26
  "mongodb": "^6.8.0",
27
27
  "nodemon": "^3.1.4",
28
28
  "path": "^0.12.7",
29
- "tango-api-schema": "^2.2.144",
29
+ "tango-api-schema": "^2.2.197",
30
30
  "tango-app-api-middleware": "^3.1.77",
31
31
  "url": "^0.11.4",
32
32
  "winston": "^3.13.1",
@@ -281,6 +281,7 @@ export async function PCLconfigCreation( req, res ) {
281
281
  insertdata.checkListType = getCLconfig.checkListType;
282
282
  insertdata.storeCount = getCLconfig.storeCount;
283
283
  insertdata.questionCount = getCLconfig.questionCount;
284
+ insertdata.runAIQuestionCount = getCLconfig.runAIQuestionCount;
284
285
  insertdata.publishDate = getCLconfig.publishDate;
285
286
  insertdata.locationCount = getCLconfig.locationCount;
286
287
  insertdata.scheduleRepeatedType = getCLconfig.scheduleRepeatedType;
@@ -559,6 +560,7 @@ export async function PCLconfigCreation( req, res ) {
559
560
  element4.checkListType = getCLconfig.checkListType;
560
561
  element4.storeCount = getCLconfig.storeCount;
561
562
  element4.questionCount = getCLconfig.questionCount;
563
+ element4.runAIQuestionCount = getCLconfig.runAIQuestionCount;
562
564
  element4.publishDate = getCLconfig.publishDate;
563
565
  element4.locationCount = getCLconfig.locationCount;
564
566
  element4.scheduleRepeatedType = getCLconfig.scheduleRepeatedType;
@@ -617,6 +617,9 @@ export const flagCardsV1 = async ( req, res ) => {
617
617
  }
618
618
  } );
619
619
  flagCards.totalFlag += flagCards.detectionFlag.count;
620
+ if ( resultData?.runAI ) {
621
+ flagCards.runAIFlag = resultData?.runAI;
622
+ }
620
623
  }
621
624
 
622
625
  return res.sendSuccess( { flagCards } );
@@ -819,6 +822,8 @@ export const flagTablesV1 = async ( req, res ) => {
819
822
  findAndQuery.push( { timeFlag: { $gte: 1 } } );
820
823
  } else if ( requestData?.filter === 'detection' ) {
821
824
  findAndQuery.push( { checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum' ] } } );
825
+ } else if ( requestData?.filter === 'runAI' ) {
826
+ findAndQuery.push( { runAIQuestionCount: { $gte: 1 } } );
822
827
  }
823
828
 
824
829
  findQuery.push( { $match: { $and: findAndQuery } } );
@@ -1033,7 +1038,7 @@ export const flagTablesV1 = async ( req, res ) => {
1033
1038
  if ( getChecklistPerformanceData.length ) {
1034
1039
  const detectionChecklists = getChecklistPerformanceData?.filter( ( val ) => val?.checkListType !== 'custom' );
1035
1040
 
1036
- if ( detectionChecklists?.length ) {
1041
+ if ( detectionChecklists?.length || requestData?.filter === 'runAI' ) {
1037
1042
  const detectionPayload = {
1038
1043
  'fromDate': requestData.fromDate,
1039
1044
  'toDate': requestData.toDate,
@@ -1046,13 +1051,23 @@ export const flagTablesV1 = async ( req, res ) => {
1046
1051
  if ( resultData ) {
1047
1052
  if ( resultData.status_code == '200' ) {
1048
1053
  for ( let index = 0; index < getChecklistPerformanceData.length; index++ ) {
1049
- if ( getChecklistPerformanceData[index].checkListType !== 'custom' ) {
1050
- getChecklistPerformanceData[index].flagCount = resultData?.[getChecklistPerformanceData[index]?.checkListType] || 0;
1051
- getChecklistPerformanceData[index].flaggedStores = resultData?.[`${getChecklistPerformanceData[index]?.checkListType}_flaggedstores`] || 0;
1052
- getChecklistPerformanceData[index].assignedStores = getChecklistPerformanceData[index]?.aiStoreList?.filter( ( element ) => requestData.storeId.includes( element ) )?.length || 0;
1053
- getChecklistPerformanceData[index].complianceRate = ( 100- ( getChecklistPerformanceData[index].flaggedStores / getChecklistPerformanceData[index].assignedStores ) * 100 );
1054
- getChecklistPerformanceData[index].complianceRate = Math.min( 100, Math.max( 0, getChecklistPerformanceData[index].complianceRate ) );
1055
- getChecklistPerformanceData[index].complianceRate = ( getChecklistPerformanceData[index].complianceRate % 1 === 0 ) ? getChecklistPerformanceData[index].complianceRate.toFixed( 0 ) : getChecklistPerformanceData[index].complianceRate.toFixed( 2 );
1054
+ if ( requestData?.filter === 'runAI' ) {
1055
+ let findCheckList = resultData.runAI.list.find( ( ele ) => ele.checkListName == getChecklistPerformanceData[index].getChecklistPerformanceData );
1056
+ if ( findCheckList ) {
1057
+ getChecklistPerformanceData[index].flaggedStores = findCheckList.flagCount;
1058
+ getChecklistPerformanceData[index].complianceRate = ( 100- ( getChecklistPerformanceData[index].flaggedStores / getChecklistPerformanceData[index].assignedStores ) * 100 );
1059
+ getChecklistPerformanceData[index].complianceRate = Math.min( 100, Math.max( 0, getChecklistPerformanceData[index].complianceRate ) );
1060
+ getChecklistPerformanceData[index].complianceRate = ( getChecklistPerformanceData[index].complianceRate % 1 === 0 ) ? getChecklistPerformanceData[index].complianceRate.toFixed( 0 ) : getChecklistPerformanceData[index].complianceRate.toFixed( 2 );
1061
+ }
1062
+ } else {
1063
+ if ( getChecklistPerformanceData[index].checkListType !== 'custom' ) {
1064
+ getChecklistPerformanceData[index].flagCount = resultData?.[getChecklistPerformanceData[index]?.checkListType] || 0;
1065
+ getChecklistPerformanceData[index].flaggedStores = resultData?.[`${getChecklistPerformanceData[index]?.checkListType}_flaggedstores`] || 0;
1066
+ getChecklistPerformanceData[index].assignedStores = getChecklistPerformanceData[index]?.aiStoreList?.filter( ( element ) => requestData.storeId.includes( element ) )?.length || 0;
1067
+ getChecklistPerformanceData[index].complianceRate = ( 100- ( getChecklistPerformanceData[index].flaggedStores / getChecklistPerformanceData[index].assignedStores ) * 100 );
1068
+ getChecklistPerformanceData[index].complianceRate = Math.min( 100, Math.max( 0, getChecklistPerformanceData[index].complianceRate ) );
1069
+ getChecklistPerformanceData[index].complianceRate = ( getChecklistPerformanceData[index].complianceRate % 1 === 0 ) ? getChecklistPerformanceData[index].complianceRate.toFixed( 0 ) : getChecklistPerformanceData[index].complianceRate.toFixed( 2 );
1070
+ }
1056
1071
  }
1057
1072
  }
1058
1073
  }
@@ -2388,7 +2403,7 @@ export const flagChecklistTableV1 = async ( req, res ) => {
2388
2403
  // let loginUser = { clientId: reqestData.clientId, role: req.user.role, userType: req.user.userType, userEmail: req.user.email };
2389
2404
  // let getUserEmails = await getChecklistUsers( loginUser );
2390
2405
  // End: Get User Based Checklist////
2391
- if ( reqestData.ChecklistType == 'custom' ) {
2406
+ if ( reqestData.ChecklistType == 'custom' && reqestData?.filter !== 'runAI' ) {
2392
2407
  const match = {
2393
2408
  $match: {
2394
2409
  $and: [
@@ -2500,7 +2515,7 @@ export const flagChecklistTableV1 = async ( req, res ) => {
2500
2515
  if ( reqestData.export ) {
2501
2516
  reqestData.limit = 10000;
2502
2517
  reqestData.offset = 0;
2503
- let LamdaURL = 'https://bnauly42yuztzrgtttodzt3bcm0oqrsi.lambda-url.ap-south-1.on.aws/';
2518
+ let LamdaURL = 'https://vpcejaftccr3jzqf5wrdkks7yy0krqix.lambda-url.ap-south-1.on.aws/';
2504
2519
  let resultData = await LamdaServiceCall( LamdaURL, reqestData );
2505
2520
  if ( resultData ) {
2506
2521
  if ( resultData.status_code == '200' ) {
@@ -2509,16 +2524,27 @@ export const flagChecklistTableV1 = async ( req, res ) => {
2509
2524
  if ( reqestData.ChecklistType==='scrum'||reqestData.ChecklistType==='cleaning' ) {
2510
2525
  reqestData.ChecklistType = 'scrumdetection';
2511
2526
  }
2512
- resultData[reqestData.ChecklistType + 'Data'].forEach( ( element ) => {
2513
- exportdata.push( {
2514
- 'Date': element?.date,
2515
- 'Store Name': element?.storeName,
2516
- 'Store Id': element?.storeId,
2517
- // 'Store Spoc Email': element?.SpocEmail,
2518
- 'Detections': element?.detections,
2519
- 'Detection Status': element?.detectionStatus,
2527
+ if ( reqestData?.filter === 'runAI' ) {
2528
+ resultData.aiFlagData.forEach( ( element ) => {
2529
+ exportdata.push( {
2530
+ 'Date': dayjs( element.dateString ).format( 'DD MMM, YYYY' ),
2531
+ 'Store Name': element?.storeName,
2532
+ 'User Email': element?.spocEmail,
2533
+ 'Detections': element?.detections,
2534
+ } );
2520
2535
  } );
2521
- } );
2536
+ } else {
2537
+ resultData[reqestData.ChecklistType + 'Data'].forEach( ( element ) => {
2538
+ exportdata.push( {
2539
+ 'Date': element?.date,
2540
+ 'Store Name': element?.storeName,
2541
+ 'Store Id': element?.storeId,
2542
+ // 'Store Spoc Email': element?.SpocEmail,
2543
+ 'Detections': element?.detections,
2544
+ 'Detection Status': element?.detectionStatus,
2545
+ } );
2546
+ } );
2547
+ }
2522
2548
  return await download( exportdata, res );
2523
2549
  } else {
2524
2550
  return res.sendError( 'No Content', 204 );
@@ -2529,11 +2555,18 @@ export const flagChecklistTableV1 = async ( req, res ) => {
2529
2555
  }
2530
2556
  // console.log( reqestData );
2531
2557
 
2532
- let LamdaURL = 'https://bnauly42yuztzrgtttodzt3bcm0oqrsi.lambda-url.ap-south-1.on.aws/';
2558
+ let LamdaURL = 'https://vpcejaftccr3jzqf5wrdkks7yy0krqix.lambda-url.ap-south-1.on.aws/';
2533
2559
  let resultData = await LamdaServiceCall( LamdaURL, reqestData );
2534
2560
  // console.log( 'resultData =>', resultData );
2535
2561
  if ( resultData ) {
2536
2562
  if ( resultData.status_code == '200' ) {
2563
+ if ( reqestData?.filter === 'runAI' ) {
2564
+ resultData.aiFlagData = resultData.aiFlagData.map( ( ele ) => {
2565
+ ele = { ...ele, date: dayjs( ele.dateString ).format( 'DD MMM, YYYY' ), storeSpocEmail: ele?.spocEmail, checklistStatus: 'submit' };
2566
+ return ele;
2567
+ } );
2568
+ resultData = { customData: resultData.aiFlagData, totalCount: resultData.totalCount };
2569
+ }
2537
2570
  return res.sendSuccess( resultData );
2538
2571
  } else {
2539
2572
  return res.sendError( 'No Content', 204 );
@@ -2871,21 +2904,25 @@ export const flagComparisonCardsV2 = async ( req, res ) => {
2871
2904
  },
2872
2905
  { checkListType: 1 },
2873
2906
  );
2874
- if ( !publishedAiChecklists?.length ) {
2875
- return 0;
2876
- }
2907
+ // if ( !publishedAiChecklists?.length ) {
2908
+ // return 0;
2909
+ // }
2877
2910
 
2878
2911
  const LamdaURL = 'https://f65azvtljclaxp6l7rnx65cdmm0lcgvp.lambda-url.ap-south-1.on.aws/';
2879
2912
  const resultData = await LamdaServiceCall( LamdaURL, detectionPayload );
2880
2913
  const published = publishedAiChecklists.map( ( val ) => val?.checkListType );
2881
2914
  if ( resultData?.status_code === '200' ) {
2882
2915
  let result = 0;
2883
- published.forEach( ( item ) => {
2884
- if ( resultData[item] ) {
2885
- result += resultData[item];
2886
- }
2887
- } );
2888
- return result;
2916
+ let ai = 0;
2917
+ if ( !publishedAiChecklists?.length ) {
2918
+ published.forEach( ( item ) => {
2919
+ if ( resultData[item] ) {
2920
+ result += resultData[item];
2921
+ }
2922
+ } );
2923
+ }
2924
+ ai = resultData?.runAI?.flagCount || 0;
2925
+ return { result, ai };
2889
2926
  }
2890
2927
  return 0;
2891
2928
  };
@@ -2910,15 +2947,17 @@ export const flagComparisonCardsV2 = async ( req, res ) => {
2910
2947
  questionComparisonFlag: { comparisonData: 0, ComparisonFlag: false },
2911
2948
  delayInSubmissionComparisonFlag: { comparisonData: 0, ComparisonFlag: false },
2912
2949
  detectionComparisonFlag: { comparisonData: 0, ComparisonFlag: false },
2950
+ runAIComparisonFlag: { comparisonData: 0, ComparisonFlag: false },
2913
2951
  };
2914
2952
 
2915
2953
  if ( rangeOneData.length && rangeTwoData.length ) {
2916
- let rangeOneTotalFlag = rangeOneData[0].totalFlag + rangeOneDetectionCount || 0;
2917
- let rangeTwoTotalFlag = rangeTwoData[0].totalFlag + rangeTwoDetectionCount || 0;
2954
+ let rangeOneTotalFlag = rangeOneData[0].totalFlag + rangeOneDetectionCount.result || 0;
2955
+ let rangeTwoTotalFlag = rangeTwoData[0].totalFlag + rangeTwoDetectionCount.result || 0;
2918
2956
  flagComparisonCards.totalComparisonFlag = calculateComparison( rangeOneTotalFlag, rangeTwoTotalFlag );
2919
2957
  flagComparisonCards.questionComparisonFlag = calculateComparison( rangeOneData[0].questionFlag, rangeTwoData[0].questionFlag );
2920
2958
  flagComparisonCards.delayInSubmissionComparisonFlag = calculateComparison( rangeOneData[0].delayInSubmission, rangeTwoData[0].delayInSubmission );
2921
- flagComparisonCards.detectionComparisonFlag = calculateComparison( rangeOneDetectionCount, rangeTwoDetectionCount );
2959
+ flagComparisonCards.detectionComparisonFlag = calculateComparison( rangeOneDetectionCount.result, rangeTwoDetectionCount.result );
2960
+ flagComparisonCards.runAIComparisonFlag = calculateComparison( rangeOneDetectionCount.ai, rangeTwoDetectionCount.ai );
2922
2961
  }
2923
2962
  flagComparisonCards.traxMonthlyComparison = false;
2924
2963
  let traxMonthlyComparisonData = await clientService.findOne( { clientId: requestData.clientId }, { traxMonthlyComparison: 1 } );
@@ -2961,6 +3000,8 @@ export const flagTablesV2 = async ( req, res ) => {
2961
3000
  findAndQuery.push( { timeFlag: { $gte: 1 } } );
2962
3001
  } else if ( requestData?.filter === 'detection' ) {
2963
3002
  findAndQuery.push( { checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum' ] } } );
3003
+ } else if ( requestData?.filter === 'runAI' ) {
3004
+ findAndQuery.push( { checkListName: { $in: req.body.runAIChecklistName } } );
2964
3005
  }
2965
3006
 
2966
3007
  findQuery.push( { $match: { $and: findAndQuery } } );
@@ -2989,6 +3030,7 @@ export const flagTablesV2 = async ( req, res ) => {
2989
3030
  scheduleRepeatedType: 1,
2990
3031
  store_id: 1,
2991
3032
  aiStoreList: 1,
3033
+ runAIQuestionCount: 1,
2992
3034
  },
2993
3035
  } );
2994
3036
 
@@ -3035,6 +3077,7 @@ export const flagTablesV2 = async ( req, res ) => {
3035
3077
  aiStoreList: { $max: '$aiStoreList' },
3036
3078
  aiStoreListNew: { $sum: { $size: '$aiStoreList' } },
3037
3079
  submittedQuestionCount: { $sum: { $cond: [ { $eq: [ '$checklistStatus', 'submit' ] }, '$questionCount', 0 ] } },
3080
+ runAIQuestionCount: { $last: '$runAIQuestionCount' },
3038
3081
  },
3039
3082
  } );
3040
3083
 
@@ -3056,6 +3099,7 @@ export const flagTablesV2 = async ( req, res ) => {
3056
3099
  customQuestionFlagCount: '$questionFlag',
3057
3100
  customTimeFlagCount: '$timeFlag',
3058
3101
  aiStoreList: 1,
3102
+ runAIQuestionCount: 1,
3059
3103
  },
3060
3104
  } );
3061
3105
 
@@ -3089,6 +3133,7 @@ export const flagTablesV2 = async ( req, res ) => {
3089
3133
  customQuestionFlagCount: 1,
3090
3134
  customTimeFlagCount: 1,
3091
3135
  aiStoreList: 1,
3136
+ runAIQuestionCount: 1,
3092
3137
  },
3093
3138
  } );
3094
3139
 
@@ -3115,7 +3160,7 @@ export const flagTablesV2 = async ( req, res ) => {
3115
3160
  if ( getChecklistPerformanceData.length ) {
3116
3161
  const detectionChecklists = getChecklistPerformanceData?.filter( ( val ) => val?.checkListType !== 'custom' );
3117
3162
 
3118
- if ( detectionChecklists?.length ) {
3163
+ if ( detectionChecklists?.length || [ 'runAI', 'all' ].includes( requestData?.filter ) ) {
3119
3164
  const detectionPayload = {
3120
3165
  'fromDate': requestData.fromDate,
3121
3166
  'toDate': requestData.toDate,
@@ -3128,13 +3173,37 @@ export const flagTablesV2 = async ( req, res ) => {
3128
3173
  if ( resultData ) {
3129
3174
  if ( resultData.status_code == '200' ) {
3130
3175
  for ( let index = 0; index < getChecklistPerformanceData.length; index++ ) {
3131
- if ( getChecklistPerformanceData[index].checkListType !== 'custom' ) {
3132
- getChecklistPerformanceData[index].flagCount = resultData?.[getChecklistPerformanceData[index]?.checkListType] || 0;
3133
- getChecklistPerformanceData[index].flaggedStores = resultData?.[`${getChecklistPerformanceData[index]?.checkListType}_flaggedstores`] || 0;
3134
- getChecklistPerformanceData[index].assignedStores = getChecklistPerformanceData[index]?.aiStoreList?.filter( ( element ) => requestData.storeId.includes( element ) )?.length || 0;
3176
+ if ( [ 'runAI', 'all' ].includes( requestData?.filter ) ) {
3177
+ let findCheckList = resultData.runAI.list.find( ( ele ) => ele.checkListName == getChecklistPerformanceData[index].checkListName );
3178
+ if ( findCheckList ) {
3179
+ if ( requestData?.filter == 'all' ) {
3180
+ getChecklistPerformanceData[index].runAIFlag = findCheckList.flagCount;
3181
+ getChecklistPerformanceData[index].flaggedStores = getChecklistPerformanceData[index].flaggedStores + findCheckList.flagCount;
3182
+ } else {
3183
+ getChecklistPerformanceData[index].flagCount = findCheckList.flagCount;
3184
+ getChecklistPerformanceData[index].flaggedStores = findCheckList.flagCount;
3185
+ }
3186
+ } else {
3187
+ if ( requestData?.filter == 'all' ) {
3188
+ getChecklistPerformanceData[index].runAIFlag = 0;
3189
+ getChecklistPerformanceData[index].runAIFlagStore = 0;
3190
+ } else {
3191
+ getChecklistPerformanceData[index].flagCount = 0;
3192
+ getChecklistPerformanceData[index].flaggedStores = 0;
3193
+ }
3194
+ }
3135
3195
  getChecklistPerformanceData[index].complianceRate = ( 100- ( getChecklistPerformanceData[index].flaggedStores / getChecklistPerformanceData[index].assignedStores ) * 100 );
3136
3196
  getChecklistPerformanceData[index].complianceRate = Math.min( 100, Math.max( 0, getChecklistPerformanceData[index].complianceRate ) );
3137
3197
  getChecklistPerformanceData[index].complianceRate = ( getChecklistPerformanceData[index].complianceRate % 1 === 0 ) ? getChecklistPerformanceData[index].complianceRate.toFixed( 0 ) : getChecklistPerformanceData[index].complianceRate.toFixed( 2 );
3198
+ } else {
3199
+ if ( getChecklistPerformanceData[index].checkListType !== 'custom' ) {
3200
+ getChecklistPerformanceData[index].flagCount = resultData?.[getChecklistPerformanceData[index]?.checkListType] || 0;
3201
+ getChecklistPerformanceData[index].flaggedStores = resultData?.[`${getChecklistPerformanceData[index]?.checkListType}_flaggedstores`] || 0;
3202
+ getChecklistPerformanceData[index].assignedStores = getChecklistPerformanceData[index]?.aiStoreList?.filter( ( element ) => requestData.storeId.includes( element ) )?.length || 0;
3203
+ getChecklistPerformanceData[index].complianceRate = ( 100- ( getChecklistPerformanceData[index].flaggedStores / getChecklistPerformanceData[index].assignedStores ) * 100 );
3204
+ getChecklistPerformanceData[index].complianceRate = Math.min( 100, Math.max( 0, getChecklistPerformanceData[index].complianceRate ) );
3205
+ getChecklistPerformanceData[index].complianceRate = ( getChecklistPerformanceData[index].complianceRate % 1 === 0 ) ? getChecklistPerformanceData[index].complianceRate.toFixed( 0 ) : getChecklistPerformanceData[index].complianceRate.toFixed( 2 );
3206
+ }
3138
3207
  }
3139
3208
  }
3140
3209
  }
@@ -3147,12 +3216,13 @@ export const flagTablesV2 = async ( req, res ) => {
3147
3216
  getChecklistPerformanceData.forEach( ( element ) => {
3148
3217
  const data = {
3149
3218
  'Checklist Name': element.checkListName,
3150
- 'Question Flags': element?.customQuestionFlagCount,
3151
- 'Not Submitted Flags': element?.customTimeFlagCount,
3152
- 'Detection Flags': element?.flagCount,
3153
3219
  'Coverage': element?.coverage,
3154
3220
  'Assigned Stores': element?.checkListType === 'custom' ? element?.assignedStores : element?.assignedStoresAi,
3155
3221
  'Flagged Stores': element?.flaggedStores,
3222
+ 'Question Flags': element?.customQuestionFlagCount,
3223
+ ...( element.runAIFlag ? { 'Run AI Flag': element.runAIFlag } : {} ),
3224
+ 'Not Submitted Flags': element?.customTimeFlagCount,
3225
+ 'Detection Flags': element?.flagCount,
3156
3226
  'Compliance': element?.complianceRate,
3157
3227
  // 'Flag Type': element?.checkListType === 'custom' ? 'Question' : 'Detection',
3158
3228
  };
@@ -3162,18 +3232,21 @@ export const flagTablesV2 = async ( req, res ) => {
3162
3232
  delete data['Flagged Count'];
3163
3233
  delete data['Not Submitted Flags'];
3164
3234
  delete data['Detection Flags'];
3235
+ delete data['Run AI Flag'];
3165
3236
  } else if ( requestData?.filter === 'time' ) {
3166
3237
  data['Flags'] = data['Not Submitted Flags'];
3167
3238
  delete data['Question Flags'];
3168
3239
  delete data['Flagged Count'];
3169
3240
  delete data['Not Submitted Flags'];
3170
3241
  delete data['Detection Flags'];
3242
+ delete data['Run AI Flag'];
3171
3243
  } else if ( requestData?.filter === 'detection' ) {
3172
3244
  data['Flags'] = data['Detection Flags'];
3173
3245
  delete data['Question Flags'];
3174
3246
  delete data['Flagged Count'];
3175
3247
  delete data['Not Submitted Flags'];
3176
3248
  delete data['Detection Flags'];
3249
+ delete data['Run AI Flag'];
3177
3250
  }
3178
3251
  exportdata.push( data );
3179
3252
  } );
@@ -174,6 +174,8 @@ export const create = async ( req, res ) => {
174
174
  checkNumber = 1;
175
175
  }
176
176
 
177
+ let runAIQuestionCount = 0;
178
+
177
179
  inputBody.sections.forEach( async ( element ) => {
178
180
  if ( !element?.questions?.length && inputBody.submitType == 'configure' ) {
179
181
  return res.sendError( { message: 'Question is Required' }, 400 );
@@ -181,6 +183,8 @@ export const create = async ( req, res ) => {
181
183
  if ( element?.questions?.length ) {
182
184
  questionCount = questionCount + element?.questions?.length;
183
185
  }
186
+ let runAiQuestions = element?.questions.filter( ( qn ) => qn.runAI );
187
+ runAIQuestionCount +=runAiQuestions.length;
184
188
  } );
185
189
 
186
190
  let checkListDetails = {
@@ -193,6 +197,7 @@ export const create = async ( req, res ) => {
193
197
  questionCount: questionCount,
194
198
  client_id: req.body?.clientId,
195
199
  owner: req.user.userType == 'client' ? [ { name: req.user.userName, value: req.user.email } ] : [],
200
+ runAIQuestionCount: runAIQuestionCount,
196
201
  // configStartDate:new Date(),
197
202
  // configEndDate:new Date(),
198
203
  };
@@ -812,7 +817,7 @@ export const update = async ( req, res ) => {
812
817
  }
813
818
 
814
819
  let getExistQuestions = await questionService.findSort( { checkListId: req.params.checklistId, client_id: req.body.clientId }, {}, { sectionNumber: 1 } );
815
-
820
+ let runAIQuestionCount = 0;
816
821
  inputBody.sections.forEach( async ( element ) => {
817
822
  if ( !element.questions.length && inputBody.submitType == 'configure' ) {
818
823
  return res.sendError( { message: 'Question is Required' }, 400 );
@@ -821,6 +826,8 @@ export const update = async ( req, res ) => {
821
826
  if ( element.questions.length ) {
822
827
  questionCount = questionCount + element.questions.length;
823
828
  }
829
+ let runAiQuestions = element?.questions.filter( ( qn ) => qn.runAI );
830
+ runAIQuestionCount +=runAiQuestions.length;
824
831
  } );
825
832
 
826
833
 
@@ -828,6 +835,7 @@ export const update = async ( req, res ) => {
828
835
  checkListName: inputBody.checklistName,
829
836
  checkListDescription: inputBody.checklistDescription,
830
837
  questionCount: questionCount,
838
+ runAIQuestionCount: runAIQuestionCount,
831
839
  };
832
840
 
833
841
  await checklistService.updateOne( { _id: req.params.checklistId }, params );
@@ -2951,6 +2959,7 @@ export async function insertSingleProcessData( checklistId, processId = 0, oldDa
2951
2959
  insertdata.checkListType = getCLconfig.checkListType;
2952
2960
  insertdata.storeCount = getCLconfig.storeCount;
2953
2961
  insertdata.questionCount = getCLconfig.questionCount;
2962
+ insertdata.runAIQuestionCount = getCLconfig.runAIQuestionCount;
2954
2963
  insertdata.publishDate = getCLconfig.publishDate;
2955
2964
  insertdata.locationCount = getCLconfig.locationCount;
2956
2965
  insertdata.scheduleRepeatedType = getCLconfig.scheduleRepeatedType;
@@ -3671,6 +3680,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
3671
3680
  element4.checkListType = getCLconfig.checkListType;
3672
3681
  element4.storeCount = getCLconfig.storeCount;
3673
3682
  element4.questionCount = getCLconfig.questionCount;
3683
+ element4.runAIQuestionCount = getCLconfig.runAIQuestionCount;
3674
3684
  element4.publishDate = getCLconfig.publishDate;
3675
3685
  element4.locationCount = getCLconfig.locationCount;
3676
3686
  element4.scheduleRepeatedType = getCLconfig.scheduleRepeatedType;