tango-app-api-trax 3.9.38 → 3.9.39

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.
Files changed (55) hide show
  1. package/index.js +1 -2
  2. package/package.json +2 -2
  3. package/src/controllers/internalTrax.controller.js +99 -221
  4. package/src/controllers/mobileTrax.controller.js +29 -69
  5. package/src/controllers/teaxFlag.controller.js +953 -15
  6. package/src/controllers/trax.controller.js +2 -3
  7. package/src/controllers/traxDashboard.controllers.js +55 -69
  8. package/src/hbs/flag.hbs +1 -1
  9. package/src/hbs/login-otp.hbs +943 -943
  10. package/src/hbs/template.hbs +0 -7
  11. package/src/hbs/visit-checklist.hbs +91 -71
  12. package/src/routes/internalTraxApi.router.js +0 -1
  13. package/src/routes/trax.routes.js +3 -0
  14. package/src/routes/traxFlag.router.js +24 -0
  15. package/src/services/app.service.js +9 -15
  16. package/src/services/approver.service.js +15 -23
  17. package/src/services/authentication.service.js +3 -9
  18. package/src/services/camera.service.js +13 -19
  19. package/src/services/checklist.service.js +27 -35
  20. package/src/services/checklistAssign.service.js +38 -43
  21. package/src/services/checklistQuestion.service.js +34 -39
  22. package/src/services/checklistlog.service.js +34 -39
  23. package/src/services/clientRequest.service.js +2 -9
  24. package/src/services/clients.services.js +18 -23
  25. package/src/services/cluster.service.js +23 -31
  26. package/src/services/domain.service.js +18 -23
  27. package/src/services/download.services.js +25 -35
  28. package/src/services/group.service.js +17 -23
  29. package/src/services/lenskartEmployeeMapping.service.js +10 -15
  30. package/src/services/locus.service.js +28 -35
  31. package/src/services/notification.service.js +26 -35
  32. package/src/services/otp.service.js +13 -20
  33. package/src/services/planogram.service.js +2 -9
  34. package/src/services/processedTaskConfig.service.js +27 -35
  35. package/src/services/processedTaskList.service.js +26 -32
  36. package/src/services/processedchecklist.services.js +47 -55
  37. package/src/services/processedchecklistconfig.services.js +34 -39
  38. package/src/services/recurringFlagTracker.service.js +32 -39
  39. package/src/services/runAIFeatures.services.js +27 -32
  40. package/src/services/runAIRequest.services.js +38 -43
  41. package/src/services/store.service.js +27 -32
  42. package/src/services/tagging.service.js +2 -9
  43. package/src/services/taskConfig.service.js +27 -35
  44. package/src/services/teams.service.js +24 -35
  45. package/src/services/ticket.service.js +10 -15
  46. package/src/services/user.service.js +20 -27
  47. package/src/services/userAssignedstores.service.js +5 -12
  48. package/src/utils/visitChecklistPdf.utils.js +21 -449
  49. package/src/logging/activityLogFlusher.js +0 -59
  50. package/src/logging/activityLogMiddleware.js +0 -45
  51. package/src/logging/activityLogStore.js +0 -91
  52. package/src/logging/compressBatches.js +0 -83
  53. package/src/logging/config.js +0 -24
  54. package/src/logging/createLoggableService.js +0 -46
  55. package/src/logging/logExternalCall.js +0 -37
@@ -625,7 +625,6 @@ export const zoneList = async ( req, res ) => {
625
625
  const allowedChecklistsStreams = [
626
626
  'Camera Angle Change Compliance',
627
627
  ];
628
- console.log( allowedChecklists.includes( inputBody.checkListName ) );
629
628
 
630
629
  if ( inputBody.checkListName && allowedChecklists.includes( inputBody.checkListName ) ) {
631
630
  console.log( '==================' );
@@ -1920,6 +1919,7 @@ export const updateConfigure = async ( req, res ) => {
1920
1919
 
1921
1920
  export const updateConfigurev1 = async ( req, res ) => {
1922
1921
  try {
1922
+ console.log( '123' );
1923
1923
  let inputBody = req.body;
1924
1924
  let id;
1925
1925
  let checklistDetails;
@@ -3977,7 +3977,6 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
3977
3977
  element4.rawVideoUpload = getCLconfig?.rawVideoUpload || false;
3978
3978
  element4.videoUploadTimeLimit = getCLconfig?.videoUploadTimeLimit || 0;
3979
3979
  element4.complianceCount = getCLconfig?.complianceCount || 0;
3980
- element4.userVerification = getCLconfig?.userVerification;
3981
3980
  assignUserList.push( { ...element4 } );
3982
3981
  }
3983
3982
  } ) );
@@ -4044,7 +4043,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
4044
4043
  }, { userId: 1, store_id: 1 } );
4045
4044
 
4046
4045
  if ( inprogressData.length ) {
4047
- await processedchecklist.updateMany( { _id: { $in: inprogressData.map( ( ele ) => new ObjectId( ele._id ) ) } }, { scheduleEndTime: getCLconfig.scheduleEndTime, scheduleEndTime_iso: endTimeIso.format(), complianceCount: getCLconfig.complianceCount, allowedOverTime: getCLconfig.allowedOverTime, allowedStoreLocation: getCLconfig.allowedStoreLocation, userVerification: getCLconfig.userVerification } );
4046
+ await processedchecklist.updateMany( { _id: { $in: inprogressData.map( ( ele ) => new ObjectId( ele._id ) ) } }, { scheduleEndTime: getCLconfig.scheduleEndTime, scheduleEndTime_iso: endTimeIso.format() } );
4048
4047
  inprogressData.forEach( ( item ) => {
4049
4048
  let checkData = assignUserList.find( ( ele ) => ele.userId.toString() == item.userId.toString() && ele.store_id == item.store_id );
4050
4049
  if ( !checkData ) {
@@ -276,10 +276,29 @@ export const checklistPerformance = async ( req, res ) => {
276
276
  toDate = new Date( toDate.getTime() - userTimezoneOffset );
277
277
  toDate.setUTCHours( 23, 59, 59, 59 );
278
278
  let result = {};
279
+ let checklistIdList = [];
279
280
 
280
281
  let limit = parseInt( requestData?.limit ) || 10;
281
282
  let skip = limit * ( requestData?.offset ) || 0;
282
283
 
284
+ const detectionPayload = {
285
+ 'fromDate': requestData.fromDate,
286
+ 'toDate': requestData.toDate,
287
+ 'clientId': requestData.clientId,
288
+ 'sortColumnName': requestData.sortColumnName,
289
+ 'sortBy': requestData.sortBy,
290
+ 'storeId': requestData.storeId,
291
+ };
292
+
293
+
294
+ let complianceURL = JSON.parse( process.env.LAMBDAURL ).complianceURL;
295
+ const complianceData = await LamdaServiceCall( complianceURL, detectionPayload );
296
+ if ( complianceData?.data?.length && requestData?.sortColumnName == 'questionCompliance' ) {
297
+ const end = skip + requestData?.limit;
298
+ checklistIdList = complianceData.data.slice( skip, end )?.map( ( ele ) => ele?.sourceCheckList_id );
299
+ }
300
+
301
+
283
302
  // Get User Based Checklist //
284
303
  // let loginUser = { clientId: requestData.clientId, role: req.user.role, userType: req.user.userType, userEmail: req.user.email };
285
304
  // let getUserEmails = await getChecklistUsers( loginUser );
@@ -295,6 +314,10 @@ export const checklistPerformance = async ( req, res ) => {
295
314
  { $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: requestData.userEmailes } } ] },
296
315
  );
297
316
 
317
+ if ( requestData?.sortColumnName == 'questionCompliance' ) {
318
+ findAndQuery.push( { sourceCheckList_id: { $in: checklistIdList } } );
319
+ }
320
+
298
321
  findQuery.push( { $match: { $and: findAndQuery } } );
299
322
 
300
323
  if ( requestData.searchValue && requestData.searchValue != '' ) {
@@ -344,16 +367,6 @@ export const checklistPerformance = async ( req, res ) => {
344
367
  timeFlag: { $sum: '$timeFlag' },
345
368
  questionFlagCount: { $sum: '$questionFlag' },
346
369
  runAIFlagCount: { $sum: '$runAIFlag' },
347
- userComplianceCountTotal: {
348
- $sum: {
349
- $cond: [
350
- { $eq: [ '$checklistStatus', 'submit' ] },
351
- { $ifNull: [ '$userComplianceCount', 0 ] },
352
- 0,
353
- ],
354
- },
355
- },
356
- complianceCount: { $first: '$complianceCount' },
357
370
  checkListType: { $last: '$checkListType' },
358
371
  redo: { $sum: { $cond: [ { $eq: [ '$redoStatus', true ] }, 1, 0 ] } },
359
372
  task: {
@@ -413,41 +426,6 @@ export const checklistPerformance = async ( req, res ) => {
413
426
  checkListType: 1,
414
427
  redo: 1,
415
428
  task: 1,
416
- questionCompliance: {
417
- $let: {
418
- vars: {
419
- divisor: {
420
- $cond: [
421
- { $gt: [ '$submittedChecklist', 1 ] },
422
- { $multiply: [ { $ifNull: [ '$complianceCount', 0 ] }, '$submittedChecklist' ] },
423
- { $ifNull: [ '$complianceCount', 0 ] },
424
- ],
425
- },
426
- },
427
- in: {
428
- $cond: [
429
- { $gt: [ '$$divisor', 0 ] },
430
- {
431
- $max: [
432
- 0,
433
- {
434
- $round: [
435
- {
436
- $multiply: [
437
- { $divide: [ '$userComplianceCountTotal', '$$divisor' ] },
438
- 100,
439
- ],
440
- },
441
- 0,
442
- ],
443
- },
444
- ],
445
- },
446
- 0,
447
- ],
448
- },
449
- },
450
- },
451
429
  },
452
430
  } );
453
431
 
@@ -468,10 +446,18 @@ export const checklistPerformance = async ( req, res ) => {
468
446
  },
469
447
  } );
470
448
  let getChecklistPerformanceData = await processedchecklistService.aggregate( findQuery );
471
- if ( !getChecklistPerformanceData[0].count[0].total ) {
449
+ if ( !getChecklistPerformanceData[0].data.length ) {
472
450
  return res.sendError( 'no data found', 204 );
473
451
  }
474
452
 
453
+ getChecklistPerformanceData?.[0]?.data.forEach( ( ele ) => {
454
+ let findCompliance;
455
+ if ( complianceData?.data?.length ) {
456
+ findCompliance = complianceData?.data?.find( ( data ) => data.sourceCheckList_id == ele?.sourceCheckList_id );
457
+ }
458
+ ele['questionComplianceRate'] = findCompliance?.compliancePercentage ?? 0;
459
+ } );
460
+
475
461
  if ( requestData.export ) {
476
462
  const exportdata = [];
477
463
  getChecklistPerformanceData[0].data.forEach( ( element ) => {
@@ -4349,26 +4335,26 @@ function escapeRegex( text ) {
4349
4335
  // }
4350
4336
  // }
4351
4337
 
4352
- // async function LamdaServiceCall( url, data ) {
4353
- // try {
4354
- // const requestOptions = {
4355
- // method: 'POST',
4356
- // headers: {
4357
- // 'Content-Type': 'application/json',
4358
- // },
4359
- // body: JSON.stringify( data ),
4360
- // };
4361
- // console.log( data );
4362
- // const response = await fetch( url, requestOptions );
4363
- // if ( !response.ok ) {
4364
- // throw new Error( `Response status: ${response.status}` );
4365
- // return false;
4366
- // }
4367
- // const json = await response.json();
4368
- // return json;
4369
- // } catch ( error ) {
4370
- // console.log( error );
4371
- // logger.error( { error: error, message: data, function: 'LamdaServiceCall' } );
4372
- // return false;
4373
- // }
4374
- // }
4338
+ async function LamdaServiceCall( url, data ) {
4339
+ try {
4340
+ const requestOptions = {
4341
+ method: 'POST',
4342
+ headers: {
4343
+ 'Content-Type': 'application/json',
4344
+ },
4345
+ body: JSON.stringify( data ),
4346
+ };
4347
+ console.log( data );
4348
+ const response = await fetch( url, requestOptions );
4349
+ if ( !response.ok ) {
4350
+ throw new Error( `Response status: ${response.status}` );
4351
+ return false;
4352
+ }
4353
+ const json = await response.json();
4354
+ return json;
4355
+ } catch ( error ) {
4356
+ console.log( error );
4357
+ logger.error( { error: error, message: data, function: 'LamdaServiceCall' } );
4358
+ return false;
4359
+ }
4360
+ }
package/src/hbs/flag.hbs CHANGED
@@ -176,7 +176,7 @@
176
176
  <td class="flagText" style="padding-left:30px; line-height: 24px;">No of Flags :</td>
177
177
  <td></td>
178
178
  <td></td>
179
- <td class="flagText">{{data.flagCount}}{{#eq data.status 'submit'}}(RunAIFlag:{{data.runAIFlag}},QuestionFlag:{{data.questionFlag}}){{/eq}}</td>
179
+ <td class="flagText">{{data.flagCount}}</td>
180
180
  </tr>
181
181
  <tr bgcolor="#ffffff" style="border:none;margin-top:3px;">
182
182
  <td class="flagText" style="padding-left:30px; line-height: 24px;">Submitted By :</td>