tango-app-api-audit 3.4.10 → 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.10",
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 ],
@@ -3888,7 +3890,7 @@ export async function auditImages( req, res ) {
3888
3890
  export async function getUserAuditCount( req, res ) {
3889
3891
  try {
3890
3892
  const userWallet = JSON.parse( process.env.USER_WALLET );
3891
- const previousDate = dayjs( new Date() ).subtract( 19, 'days' );
3893
+ const previousDate = dayjs( new Date() ).subtract( 1, 'days' );
3892
3894
  const fileDate = dayjs( previousDate ).format( 'DD-MM-YYYY' );
3893
3895
  const configTimeSpentSec = userWallet.minTimeSpentSec; // 18000;
3894
3896
  // const beforeCountX = userWallet.beforeCountCreditPerc; // 0.0335;
@@ -3930,32 +3932,34 @@ export async function getUserAuditCount( req, res ) {
3930
3932
  ],
3931
3933
  },
3932
3934
  },
3933
- {
3934
- $project: {
3935
-
3936
- trafficUserCount: { $cond: [
3937
- { $eq: [ '$moduleType', 'traffic' ] }, '$userId', '$$REMOVE',
3938
- ] },
3939
- zoneUserCount: { $cond: [
3940
- { $eq: [ '$moduleType', 'zone' ] }, '$userId', '$$REMOVE',
3941
- ] },
3942
-
3943
- trafficFilesCount: { $cond: [
3944
- { $eq: [ '$moduleType', 'traffic' ] }, '$beforeCount', '$$REMOVE',
3945
- ] },
3946
- zoneFilesCount: { $cond: [
3947
- { $eq: [ '$moduleType', 'zone' ] }, '$beforeCount', '$$REMOVE',
3948
- ] },
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
+ // ] },
3949
3951
 
3950
- },
3951
- },
3952
+ // },
3953
+ // },
3952
3954
  {
3953
3955
  $group: {
3954
- _id: '$moduleType',
3955
- trafficUserCount: { $addToSet: '$trafficUserCount' },
3956
- zoneUserCount: { $addToSet: '$zoneUserCount' },
3957
- trafficFilesCount: { $sum: '$trafficFilesCount' },
3958
- 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' },
3959
3963
  },
3960
3964
  },
3961
3965
  ];
@@ -3999,11 +4003,10 @@ export async function getUserAuditCount( req, res ) {
3999
4003
  if ( userCount?.length == 0 ) {
4000
4004
  return res.sendError( 'No Data Found', 204 );
4001
4005
  }
4002
- const zoneMinimumTarget =userCount[0]?.zoneUserCount?.length !== 0 && userCount[0]?.zoneFilesCount !==0 ? Math.floor( userCount[0].zoneFilesCount/userCount[0].zoneUserCount.length ) : 0;
4003
- const trafficMinimumTarget =userCount[0]?.trafficUserCount?.length !== 0 && userCount[0]?.trafficFilesCount !==0 ? Math.floor( userCount[0].trafficFilesCount/userCount[0].trafficUserCount.length ) : 0;
4004
-
4005
- const beforeCountTraffic = 544/trafficMinimumTarget;
4006
- 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;
4007
4010
  const afterCountCredit = 136;
4008
4011
 
4009
4012
  const query = [
@@ -4019,8 +4022,7 @@ export async function getUserAuditCount( req, res ) {
4019
4022
  },
4020
4023
  },
4021
4024
  {
4022
- $set: { minimumTarget: { $cond: [ { $eq: [ '$moduleType', 'traffic' ] }, trafficMinimumTarget, zoneMinimumTarget ] },
4023
- afterCountCredit: afterCountCredit },
4025
+ $set: { minimumTarget: minimumTarget, afterCountCredit: afterCountCredit, beforeCreditCal: beforeCreditCal },
4024
4026
  },
4025
4027
  {
4026
4028
  $project: {
@@ -4034,7 +4036,7 @@ export async function getUserAuditCount( req, res ) {
4034
4036
  minimumTarget: 1,
4035
4037
  afterCountCredit: 1,
4036
4038
  totalEarn: { $ifNull: [ 0, 0 ] },
4037
- singleImageAmount: { $ifNull: [ 0, 0 ] },
4039
+ singleImageAmount: { $ifNull: [ '$beforeCreditCal', 0 ] },
4038
4040
  totalReducedAmount: { $ifNull: [ 0, 0 ] },
4039
4041
  totalCredit: { $ifNull: [ 0, 0 ] },
4040
4042
  deductionBytimeSpent: { $ifNull: [ 0, 0 ] },
@@ -4043,7 +4045,7 @@ export async function getUserAuditCount( req, res ) {
4043
4045
  },
4044
4046
  {
4045
4047
  $group: {
4046
- _id: { user: '$userId', type: '$moduleType' },
4048
+ _id: { user: '$userId' },
4047
4049
  totalCount: { $sum: 1 },
4048
4050
  moduleType: { $first: '$moduleType' },
4049
4051
  totalBeforeCount: { $sum: '$beforeCount' },
@@ -4073,8 +4075,8 @@ export async function getUserAuditCount( req, res ) {
4073
4075
  fileDate: 1,
4074
4076
  fileDateISO: 1,
4075
4077
  minimumTarget: 1,
4076
- singleImageAmount: { $cond: [ { $eq: [ '$moduleType', 'traffic' ] }, beforeCountTraffic, beforeCountZone ] },
4077
- beforeCountCredit: { $multiply: [ '$totalBeforeCount', { $cond: [ { $eq: [ '$moduleType', 'traffic' ] }, beforeCountTraffic, beforeCountZone ] } ] },
4078
+ singleImageAmount: 1,
4079
+ beforeCountCredit: { $multiply: [ '$totalBeforeCount', '$singleImageAmount' ] },
4078
4080
  // afterCountCredit: { $cond: [ { $and: [
4079
4081
  // { $gte: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 0.4 ] }, { $lte: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 0.7 ] },
4080
4082
  // ] }, 136,
@@ -4086,7 +4088,7 @@ export async function getUserAuditCount( req, res ) {
4086
4088
  // },
4087
4089
  // ] },
4088
4090
  afterCountCredit: afterCountCredit,
4089
- totalEarn: { $add: [ { $multiply: [ '$totalBeforeCount', { $cond: [ { $eq: [ '$moduleType', 'traffic' ] }, beforeCountTraffic, beforeCountZone ] } ] }, 136 ] },
4091
+ totalEarn: { $add: [ { $multiply: [ '$totalBeforeCount', '$singleImageAmount' ] }, 136 ] },
4090
4092
  deductionBytimeSpent: 1,
4091
4093
  deductionByMinimumTarget: 1,
4092
4094
  mappingperc: { $multiply: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 100 ] },
@@ -4124,7 +4126,7 @@ export async function getUserAuditCount( req, res ) {
4124
4126
  fileDate: 1,
4125
4127
  fileDateISO: 1,
4126
4128
  minimumTarget: 1,
4127
- singleImageAmount: { $cond: [ { $eq: [ '$moduleType', 'traffic' ] }, beforeCountTraffic, beforeCountZone ] },
4129
+ singleImageAmount: 1,
4128
4130
  beforeCountCredit: 1,
4129
4131
  afterCountCredit: 1,
4130
4132
  totalEarn: 1,