tango-app-api-audit 3.4.37 → 3.4.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-audit",
3
- "version": "3.4.37",
3
+ "version": "3.4.39",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -972,30 +972,30 @@ export async function workSpace( req, res ) {
972
972
  },
973
973
  ];
974
974
 
975
- // const userDrafted = [
976
- // {
977
- // $match: {
978
- // $and: [
979
- // { clientId: { $in: clientList } },
980
- // { userId: { $eq: req.user._id } },
981
- // { auditStatus: { $eq: true } },
982
- // { moduleType: { $eq: inputData.moduleType } },
983
- // { createdAt: { $gte: new Date( dayjs( fileDate ).format( 'YYYY-MM-DD' ) ) } },
984
- // { createdAt: { $lte: dateRange.end } },
985
- // ],
986
- // },
987
- // },
988
- // {
989
- // $limit: 1,
990
- // },
991
- // {
992
- // $project: {
993
- // clienId: 1,
994
- // auditStatus: 1,
995
- // },
996
- // },
975
+ const userDrafted = [
976
+ {
977
+ $match: {
978
+ $and: [
979
+ // { clientId: { $in: clientList } },
980
+ { userId: { $eq: req.user._id } },
981
+ { auditStatus: { $in: [ 'inprogress', 'drafted' ] } },
982
+ { moduleType: { $eq: inputData.moduleType } },
983
+ { createdAt: { $gte: new Date( dayjs( fileDate ).format( 'YYYY-MM-DD' ) ) } },
984
+ { createdAt: { $lte: dateRange.end } },
985
+ ],
986
+ },
987
+ },
988
+ {
989
+ $limit: 1,
990
+ },
991
+ {
992
+ $project: {
993
+ clienId: 1,
994
+ auditStatus: 1,
995
+ },
996
+ },
997
997
 
998
- // ];
998
+ ];
999
999
 
1000
1000
  const userAsignAudit = [
1001
1001
  {
@@ -1053,9 +1053,9 @@ export async function workSpace( req, res ) {
1053
1053
  const userIncompleteFilesCount = await aggregateUserAudit(
1054
1054
  userIncompleteFiles,
1055
1055
  );
1056
- // const userDraftedCount = await aggregateUserAudit(
1057
- // userDrafted,
1058
- // );
1056
+ const userDraftedCount = await aggregateUserAudit(
1057
+ userDrafted,
1058
+ );
1059
1059
  const userAsignAuditCount = await aggregateAssignAudit( userAsignAudit );
1060
1060
  const completedStoresCount = await aggregateStoreAudit( completedStores );
1061
1061
  const clientAssignedCount = await aggregateAssignAudit( clientAssign );
@@ -1103,7 +1103,7 @@ export async function workSpace( req, res ) {
1103
1103
  queueName: merge[i].queueName,
1104
1104
  isDraft: merge[i]?.isDrafted || false,
1105
1105
  isEnable:
1106
- // userDraftedCount.length > 0 && !merge[i].isDrafted? 0:
1106
+ userDraftedCount.length > 0 && !merge[i].isDrafted && ( !merge[i]?.userInprogressCount || merge[i]?.userInprogressCount == 0 ) ? 0:
1107
1107
  Number( pending ) > 0 ||
1108
1108
  merge[i].isDrafted ||
1109
1109
  ( merge[i].userAsignedCount && merge[i].userAsignedCount > 0 ) ||
@@ -3456,46 +3456,6 @@ export async function getDetectionAuditFile( req, res ) {
3456
3456
  const auditStatus = userDetails && userDetails.length > 0 ? userDetails[0].auditStatus : null;
3457
3457
  switch ( auditStatus ) {
3458
3458
  case null:
3459
- // const query = [
3460
- // {
3461
- // $match: {
3462
- // $and: [
3463
- // { userId: { $eq: req.user._id } },
3464
- // { isCompleted: { $eq: false } },
3465
- // { queueName: inputData.queueName },
3466
- // { moduleType: inputData.moduleType },
3467
- // ],
3468
- // },
3469
- // },
3470
- // ];
3471
- // const userAssign = await aggregateAssignAudit( query );
3472
- // if ( userAssign.length > 0 ) {
3473
- // logger.info( 'Hit in user assign', { inputData } );
3474
- // userAssign[0].auditType == 'Audit' ?
3475
- // ( msg = {
3476
- // storeId: userAssign[0].storeId,
3477
- // fileDate: userAssign[0].fileDate,
3478
- // fileCount: userAssign[0].fileCount,
3479
- // inputBucketName: userAssign[0].inputBucketName,
3480
- // folderPath: userAssign[0].folderPath,
3481
- // } ) :
3482
- // ( msg = {
3483
- // storeId: userAssign[0].storeId,
3484
- // fileDate: userAssign[0].fileDate,
3485
- // auditType: userAssign[0].auditType,
3486
- // fileCount: userAssign[0].fileCount,
3487
- // inputBucketName: userAssign[0].inputBucketName,
3488
- // folderPath: userAssign[0].folderPath,
3489
- // } );
3490
- // await updateOneAssignAudit(
3491
- // { _id: userAssign[0]._id },
3492
- // { isCompleted: true },
3493
- // );
3494
- // logger.info( 'Hit in auditUserAssignModel updateOne', {
3495
- // _id: userAssign[0]._id,
3496
- // isCompleted: true,
3497
- // } );
3498
- // } else {
3499
3459
  logger.info( 'Hit in new file', { inputData } );
3500
3460
  const consumer = await sqsReceive( inputData.queueName );
3501
3461
  if ( !consumer ) {
@@ -3507,7 +3467,6 @@ export async function getDetectionAuditFile( req, res ) {
3507
3467
  return res.sendError( `${inputData.queueName} is Empty`, 204 );
3508
3468
  }
3509
3469
  msg = JSON.parse( consumer );
3510
- // }
3511
3470
  break;
3512
3471
 
3513
3472
  case 'drafted':
@@ -3643,7 +3602,7 @@ export async function getDetectionAuditFile( req, res ) {
3643
3602
  };
3644
3603
  files.push( {
3645
3604
  img_path: data,
3646
- img_name: inputData.moduleType=='mobile-detection'?`${indexes[0]}-${indexes[3]}`: inputData.moduleType=='hygiene'?`${indexes[2]}-${indexes[3]}`:image[0],
3605
+ img_name: inputData.moduleType=='mobile-detection'?`${indexes[0]}-${indexes[3]}`:image[0],
3647
3606
  img_id: inputData.moduleType=='hygiene'? img[4] : img[3],
3648
3607
  selected: false,
3649
3608
  dropped: false,