tango-app-api-audit 3.4.19 → 3.4.21

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.19",
3
+ "version": "3.4.21",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -24,8 +24,8 @@
24
24
  "mongodb": "^6.7.0",
25
25
  "nodemon": "^3.1.3",
26
26
  "swagger-ui-express": "^5.0.1",
27
- "tango-api-schema": "^2.1.58",
28
- "tango-app-api-middleware": "^3.1.45",
27
+ "tango-api-schema": "^2.2.12",
28
+ "tango-app-api-middleware": "^3.1.48",
29
29
  "winston": "^3.13.0",
30
30
  "winston-daily-rotate-file": "^5.0.0"
31
31
  },
@@ -874,18 +874,10 @@ export async function workSpace( req, res ) {
874
874
  },
875
875
  },
876
876
  },
877
- // {
878
- // $group: {
879
- // _id: { clientId: '$clientId', storeId: '$storeId' },
880
- // clientId: { $first: '$clientId' },
881
- // completedStoresCount: { $sum: '$completed' },
882
- // },
883
- // },
884
877
  {
885
878
  $group: {
886
879
  _id: '$clientId',
887
880
  clientId: { $first: '$clientId' },
888
- // completedStoresCount: { $first: '$completedStoresCount' },
889
881
  completedStoresCount: { $sum: '$completed' },
890
882
  },
891
883
  },
@@ -979,6 +971,31 @@ export async function workSpace( req, res ) {
979
971
  },
980
972
  ];
981
973
 
974
+ // const userDrafted = [
975
+ // {
976
+ // $match: {
977
+ // $and: [
978
+ // { clientId: { $in: clientList } },
979
+ // { userId: { $eq: req.user._id } },
980
+ // { auditStatus: { $eq: true } },
981
+ // { moduleType: { $eq: inputData.moduleType } },
982
+ // { createdAt: { $gte: new Date( dayjs( fileDate ).format( 'YYYY-MM-DD' ) ) } },
983
+ // { createdAt: { $lte: dateRange.end } },
984
+ // ],
985
+ // },
986
+ // },
987
+ // {
988
+ // $limit: 1,
989
+ // },
990
+ // {
991
+ // $project: {
992
+ // clienId: 1,
993
+ // auditStatus: 1,
994
+ // },
995
+ // },
996
+
997
+ // ];
998
+
982
999
  const userAsignAudit = [
983
1000
  {
984
1001
  $match: {
@@ -1035,6 +1052,9 @@ export async function workSpace( req, res ) {
1035
1052
  const userIncompleteFilesCount = await aggregateUserAudit(
1036
1053
  userIncompleteFiles,
1037
1054
  );
1055
+ // const userDraftedCount = await aggregateUserAudit(
1056
+ // userDrafted,
1057
+ // );
1038
1058
  const userAsignAuditCount = await aggregateAssignAudit( userAsignAudit );
1039
1059
  const completedStoresCount = await aggregateStoreAudit( completedStores );
1040
1060
  const clientAssignedCount = await aggregateAssignAudit( clientAssign );
@@ -1082,6 +1102,7 @@ export async function workSpace( req, res ) {
1082
1102
  queueName: merge[i].queueName,
1083
1103
  isDraft: merge[i]?.isDrafted || false,
1084
1104
  isEnable:
1105
+ // userDraftedCount.length > 0 && !merge[i].isDrafted? 0:
1085
1106
  Number( pending ) > 0 ||
1086
1107
  merge[i].isDrafted ||
1087
1108
  ( merge[i].userAsignedCount && merge[i].userAsignedCount > 0 ) ||
@@ -3917,11 +3938,23 @@ export async function getUserCredit( req, res ) {
3917
3938
 
3918
3939
  export async function getUserAuditCount( req, res ) {
3919
3940
  try {
3920
- for ( let i =4; i<35; i++ ) {
3941
+ // const options = { timeZone: 'Asia/Kolkata', year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit' };
3942
+ // const istTime = new Intl.DateTimeFormat( 'en-IN', options ).format( new Date( '' ) );
3943
+
3944
+ // // Get the day of the week (0 = Sunday, 1 = Monday, ..., 6 = Saturday)
3945
+ // const dayOfWeek = istTime.getDay();
3946
+
3947
+ // // Check if today is Monday (if weeks start on Monday)
3948
+ // const isFirstDay = dayOfWeek === 1; // Monday = 1
3949
+ // logger.info( { isFirstDay: isFirstDay } );
3950
+ // if ( isFirstDay ) {
3951
+ // await updateManyAuditUsers( {}, { lateLogin: 0 } );
3952
+ // }
3953
+ for ( let i =1; i<7; i++ ) {
3921
3954
  const userWallet = JSON.parse( process.env.USER_WALLET );
3922
3955
  const previousDate = dayjs( new Date() ).subtract( i, 'days' );
3923
3956
  const fileDate = dayjs( previousDate ).format( 'DD-MM-YYYY' );
3924
- const configTimeSpentSec = userWallet.minTimeSpentSec; // 25200 seconds / 7 hours;
3957
+ const configTimeSpentSec = userWallet.minTimeSpentSec; // 21600 seconds / 6 hours;
3925
3958
  // const beforeCountX = userWallet.beforeCountCreditPerc; // 0.0335;
3926
3959
  // const afterCountY = userWallet.afterCountCreditPerc; // 0.0035;
3927
3960
  const reduce = userWallet.reductionPerc; // 0.05;
@@ -4312,7 +4345,7 @@ export async function getUserAuditCount( req, res ) {
4312
4345
  if ( result.length == 0 ) {
4313
4346
  return res.sendError( 'No Record Inserted', 500 );
4314
4347
  }
4315
- if ( i == 34 ) {
4348
+ if ( i == 6 ) {
4316
4349
  return res.sendSuccess( { message: 'Inserted successfully!' } );
4317
4350
  }
4318
4351
  }