tango-app-api-audit 3.4.9 → 3.4.11-alpha.0

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.9",
3
+ "version": "3.4.11-alpha.0",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -527,6 +527,7 @@ export async function getAuditFile( req, res ) {
527
527
  img_name: indexes[1],
528
528
  img_id: image[0],
529
529
  selected: false,
530
+ isKids: false,
530
531
  dropped: false,
531
532
  count: 1,
532
533
  mappedid: [ mapimg ],
@@ -715,6 +716,7 @@ export async function getAuditImage( msg ) {
715
716
  img_name: indexes[1],
716
717
  img_id: image[0],
717
718
  selected: false,
719
+ isKids: false,
718
720
  dropped: false,
719
721
  count: 1,
720
722
  mappedid: [ mapimg ],
@@ -2345,12 +2347,21 @@ export async function userMetrics( req, res ) {
2345
2347
  beforeCount: 1,
2346
2348
  afterCount: 1,
2347
2349
  mappingPerc: {
2348
- $round: [
2350
+ $cond: [
2351
+ { $and: [
2352
+ { $gt: [ '$beforeCount', 0 ] },
2353
+ { $gt: [ '$afterCount', 0 ] },
2354
+ ] },
2349
2355
  {
2350
- $multiply: [
2351
- { $divide: [ '$afterCount', '$beforeCount' ] }, 100,
2356
+ $round: [
2357
+ {
2358
+ $multiply: [
2359
+ { $divide: [ '$afterCount', '$beforeCount' ] }, 100,
2360
+ ],
2361
+ }, 2,
2352
2362
  ],
2353
- }, 2,
2363
+ },
2364
+ 0,
2354
2365
  ],
2355
2366
  },
2356
2367
  checkIntime: 1,
@@ -2535,7 +2546,7 @@ export async function userMetrics( req, res ) {
2535
2546
  'Check Intime': '$checkIntime',
2536
2547
  'Check OutTime': '$checkOutTime',
2537
2548
  'Working Hours': '$workingHours',
2538
- 'Audited Date': { $dateToString: { format: '%Y,%b %d', date: '$createdAt' } },
2549
+ 'Audited Date': { $dateToString: { format: '%Y-%m-%d', date: '$createdAt' } },
2539
2550
  },
2540
2551
  },
2541
2552
  );
@@ -3879,7 +3890,7 @@ export async function auditImages( req, res ) {
3879
3890
  export async function getUserAuditCount( req, res ) {
3880
3891
  try {
3881
3892
  const userWallet = JSON.parse( process.env.USER_WALLET );
3882
- const previousDate = dayjs( new Date() ).subtract( 19, 'days' );
3893
+ const previousDate = dayjs( new Date() ).subtract( 1, 'days' );
3883
3894
  const fileDate = dayjs( previousDate ).format( 'DD-MM-YYYY' );
3884
3895
  const configTimeSpentSec = userWallet.minTimeSpentSec; // 18000;
3885
3896
  // const beforeCountX = userWallet.beforeCountCreditPerc; // 0.0335;
@@ -3921,32 +3932,34 @@ export async function getUserAuditCount( req, res ) {
3921
3932
  ],
3922
3933
  },
3923
3934
  },
3924
- {
3925
- $project: {
3926
-
3927
- trafficUserCount: { $cond: [
3928
- { $eq: [ '$moduleType', 'traffic' ] }, '$userId', '$$REMOVE',
3929
- ] },
3930
- zoneUserCount: { $cond: [
3931
- { $eq: [ '$moduleType', 'zone' ] }, '$userId', '$$REMOVE',
3932
- ] },
3933
-
3934
- trafficFilesCount: { $cond: [
3935
- { $eq: [ '$moduleType', 'traffic' ] }, '$beforeCount', '$$REMOVE',
3936
- ] },
3937
- zoneFilesCount: { $cond: [
3938
- { $eq: [ '$moduleType', 'zone' ] }, '$beforeCount', '$$REMOVE',
3939
- ] },
3935
+ // {
3936
+ // $project: {
3937
+
3938
+ // trafficUserCount: { $cond: [
3939
+ // { $eq: [ '$moduleType', 'traffic' ] }, '$userId', '$$REMOVE',
3940
+ // ] },
3941
+ // zoneUserCount: { $cond: [
3942
+ // { $eq: [ '$moduleType', 'zone' ] }, '$userId', '$$REMOVE',
3943
+ // ] },
3944
+
3945
+ // trafficFilesCount: { $cond: [
3946
+ // { $eq: [ '$moduleType', 'traffic' ] }, '$beforeCount', '$$REMOVE',
3947
+ // ] },
3948
+ // zoneFilesCount: { $cond: [
3949
+ // { $eq: [ '$moduleType', 'zone' ] }, '$beforeCount', '$$REMOVE',
3950
+ // ] },
3940
3951
 
3941
- },
3942
- },
3952
+ // },
3953
+ // },
3943
3954
  {
3944
3955
  $group: {
3945
- _id: '$moduleType',
3946
- trafficUserCount: { $addToSet: '$trafficUserCount' },
3947
- zoneUserCount: { $addToSet: '$zoneUserCount' },
3948
- trafficFilesCount: { $sum: '$trafficFilesCount' },
3949
- zoneFilesCount: { $sum: '$zoneFilesCount' },
3956
+ _id: null,
3957
+ // trafficUserCount: { $addToSet: '$trafficUserCount' },
3958
+ // zoneUserCount: { $addToSet: '$zoneUserCount' },
3959
+ // trafficFilesCount: { $sum: '$trafficFilesCount' },
3960
+ // zoneFilesCount: { $sum: '$zoneFilesCount' },
3961
+ userCount: { $addToSet: '$userId' },
3962
+ filesCount: { $sum: '$beforeCount' },
3950
3963
  },
3951
3964
  },
3952
3965
  ];
@@ -3990,11 +4003,10 @@ export async function getUserAuditCount( req, res ) {
3990
4003
  if ( userCount?.length == 0 ) {
3991
4004
  return res.sendError( 'No Data Found', 204 );
3992
4005
  }
3993
- const zoneMinimumTarget =userCount[0]?.zoneUserCount?.length !== 0 && userCount[0]?.zoneFilesCount !==0 ? Math.floor( userCount[0].zoneFilesCount/userCount[0].zoneUserCount.length ) : 0;
3994
- const trafficMinimumTarget =userCount[0]?.trafficUserCount?.length !== 0 && userCount[0]?.trafficFilesCount !==0 ? Math.floor( userCount[0].trafficFilesCount/userCount[0].trafficUserCount.length ) : 0;
3995
-
3996
- const beforeCountTraffic = 544/trafficMinimumTarget;
3997
- const beforeCountZone = 544/zoneMinimumTarget; // 0.0035;
4006
+ const minimumTarget =userCount[0]?.userCount?.length !== 0 && userCount[0]?.filesCount !==0 ? Math.floor( userCount[0].filesCount/userCount[0].userCount.length ) : 0;
4007
+ // const trafficMinimumTarget =userCount[0]?.trafficUserCount?.length !== 0 && userCount[0]?.trafficFilesCount !==0 ? Math.floor( userCount[0].trafficFilesCount/userCount[0].trafficUserCount.length ) : 0;
4008
+ const beforeCreditCal = 544/minimumTarget;
4009
+ // const beforeCountZone = 544/zoneMinimumTarget; // 0.0035;
3998
4010
  const afterCountCredit = 136;
3999
4011
 
4000
4012
  const query = [
@@ -4010,8 +4022,7 @@ export async function getUserAuditCount( req, res ) {
4010
4022
  },
4011
4023
  },
4012
4024
  {
4013
- $set: { minimumTarget: { $cond: [ { $eq: [ '$moduleType', 'traffic' ] }, trafficMinimumTarget, zoneMinimumTarget ] },
4014
- afterCountCredit: afterCountCredit },
4025
+ $set: { minimumTarget: minimumTarget, afterCountCredit: afterCountCredit, beforeCreditCal: beforeCreditCal },
4015
4026
  },
4016
4027
  {
4017
4028
  $project: {
@@ -4025,7 +4036,7 @@ export async function getUserAuditCount( req, res ) {
4025
4036
  minimumTarget: 1,
4026
4037
  afterCountCredit: 1,
4027
4038
  totalEarn: { $ifNull: [ 0, 0 ] },
4028
- singleImageAmount: { $ifNull: [ 0, 0 ] },
4039
+ singleImageAmount: { $ifNull: [ '$beforeCreditCal', 0 ] },
4029
4040
  totalReducedAmount: { $ifNull: [ 0, 0 ] },
4030
4041
  totalCredit: { $ifNull: [ 0, 0 ] },
4031
4042
  deductionBytimeSpent: { $ifNull: [ 0, 0 ] },
@@ -4034,7 +4045,7 @@ export async function getUserAuditCount( req, res ) {
4034
4045
  },
4035
4046
  {
4036
4047
  $group: {
4037
- _id: { user: '$userId', type: '$moduleType' },
4048
+ _id: { user: '$userId' },
4038
4049
  totalCount: { $sum: 1 },
4039
4050
  moduleType: { $first: '$moduleType' },
4040
4051
  totalBeforeCount: { $sum: '$beforeCount' },
@@ -4064,8 +4075,8 @@ export async function getUserAuditCount( req, res ) {
4064
4075
  fileDate: 1,
4065
4076
  fileDateISO: 1,
4066
4077
  minimumTarget: 1,
4067
- singleImageAmount: { $cond: [ { $eq: [ '$moduleType', 'traffic' ] }, beforeCountTraffic, beforeCountZone ] },
4068
- beforeCountCredit: { $multiply: [ '$totalBeforeCount', { $cond: [ { $eq: [ '$moduleType', 'traffic' ] }, beforeCountTraffic, beforeCountZone ] } ] },
4078
+ singleImageAmount: 1,
4079
+ beforeCountCredit: { $multiply: [ '$totalBeforeCount', '$singleImageAmount' ] },
4069
4080
  // afterCountCredit: { $cond: [ { $and: [
4070
4081
  // { $gte: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 0.4 ] }, { $lte: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 0.7 ] },
4071
4082
  // ] }, 136,
@@ -4077,7 +4088,7 @@ export async function getUserAuditCount( req, res ) {
4077
4088
  // },
4078
4089
  // ] },
4079
4090
  afterCountCredit: afterCountCredit,
4080
- totalEarn: { $add: [ { $multiply: [ '$totalBeforeCount', { $cond: [ { $eq: [ '$moduleType', 'traffic' ] }, beforeCountTraffic, beforeCountZone ] } ] }, 136 ] },
4091
+ totalEarn: { $add: [ { $multiply: [ '$totalBeforeCount', '$singleImageAmount' ] }, 136 ] },
4081
4092
  deductionBytimeSpent: 1,
4082
4093
  deductionByMinimumTarget: 1,
4083
4094
  mappingperc: { $multiply: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 100 ] },
@@ -4115,7 +4126,7 @@ export async function getUserAuditCount( req, res ) {
4115
4126
  fileDate: 1,
4116
4127
  fileDateISO: 1,
4117
4128
  minimumTarget: 1,
4118
- singleImageAmount: { $cond: [ { $eq: [ '$moduleType', 'traffic' ] }, beforeCountTraffic, beforeCountZone ] },
4129
+ singleImageAmount: 1,
4119
4130
  beforeCountCredit: 1,
4120
4131
  afterCountCredit: 1,
4121
4132
  totalEarn: 1,
@@ -3077,7 +3077,7 @@ export async function userMetrics( req, res ) {
3077
3077
  'Check Intime': '$checkIntime',
3078
3078
  'Check OutTime': '$checkOutTime',
3079
3079
  'Working Hours': '$workingHours',
3080
- 'Audited Date': { $dateToString: { format: '%Y,%b %d', date: '$createdAt' } },
3080
+ 'Audited Date': { $dateToString: { format: '%Y-%m-%d', date: '$createdAt' } },
3081
3081
  // 'Mapping Percentage': '$mappingPerc',
3082
3082
  };
3083
3083
  const YesNo = {
@@ -3089,7 +3089,7 @@ export async function userMetrics( req, res ) {
3089
3089
  'Check Intime': '$checkIntime',
3090
3090
  'Check OutTime': '$checkOutTime',
3091
3091
  'Working Hours': '$workingHours',
3092
- 'Audited Date': { $dateToString: { format: '%Y,%b %d', date: '$createdAt' } },
3092
+ 'Audited Date': { $dateToString: { format: '%Y-%m-%d', date: '$createdAt' } },
3093
3093
  // 'Mapping Percentage': '$mappingPerc',
3094
3094
  };
3095
3095
  [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )?