tango-app-api-infra 3.1.34-beta.46 → 3.1.34-beta.49

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-infra",
3
- "version": "3.1.34-beta.46",
3
+ "version": "3.1.34-beta.49",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -15,7 +15,8 @@
15
15
  "dependencies": {
16
16
  "aws-sdk": "^2.1571.0",
17
17
  "cors": "^2.8.5",
18
- "dayjs": "^1.11.10",
18
+ "dayjs": "^1.11.13",
19
+ "dayjs-plugin-utc": "^0.1.2",
19
20
  "dotenv": "^16.4.5",
20
21
  "excel4node": "^1.8.2",
21
22
  "express": "^4.18.3",
@@ -26,8 +27,8 @@
26
27
  "mongodb": "^6.4.0",
27
28
  "nodemon": "^3.1.0",
28
29
  "swagger-ui-express": "^5.0.0",
29
- "tango-api-schema": "^2.1.30",
30
- "tango-app-api-middleware": "^3.1.43-alpha.8",
30
+ "tango-api-schema": "^2.2.29",
31
+ "tango-app-api-middleware": "^3.1.50",
31
32
  "winston": "^3.12.0",
32
33
  "winston-daily-rotate-file": "^5.0.0"
33
34
  },
@@ -7,6 +7,10 @@ import { logger, fileUpload, signedUrl, chunkArray, sendEmailWithSES, getOpenSea
7
7
  import { aggregateUser, findOneUser, updateOneUser } from '../services/user.service.js';
8
8
  import { findOneClient, updateoneClient } from '../services/client.service.js';
9
9
  import dayjs from 'dayjs';
10
+ import utc from 'dayjs/plugin/utc.js';
11
+ import timezone from 'dayjs/plugin/timezone.js';
12
+ dayjs.extend( utc );
13
+ dayjs.extend( timezone );
10
14
  import { readFileSync } from 'fs';
11
15
  import { join } from 'path';
12
16
  import handlebars from 'handlebars';
@@ -19,7 +23,7 @@ import { aggregateCamera } from '../services/camera.service.js';
19
23
  import { aggregatemailonlyuser, createmailonlyuser, updateonemailonlyuser, findOnemailonlyuser, deletemailonlyuser } from '../services/mailonlyusers.service.js';
20
24
  import { findcluster } from '../services/cluster.service.js';
21
25
  import { findteams } from '../services/teams.service.js';
22
-
26
+ import { aggreagteUserAudit } from '../services/userAudit.service.js';
23
27
  export async function createTicket( req, res ) {
24
28
  try {
25
29
  req.body.issueDate = new Date( req.body.Date );
@@ -606,7 +610,7 @@ export async function emailUserListv2( req, res ) {
606
610
  const result = await aggregateUser( query );
607
611
  for ( let user of result ) {
608
612
  if ( user.role !== 'superadmin' ) {
609
- let storeIds =new Set();
613
+ let storeIds = new Set();
610
614
  if ( user.assignedStores ) {
611
615
  storeIds = new Set( user.assignedStores.map( ( store ) => store.storeId ) );
612
616
  }
@@ -644,7 +648,7 @@ export async function emailUserListv2( req, res ) {
644
648
  }
645
649
  }
646
650
  let TeamMember = await findteams( { clientId: inputData.clientId, users: { $elemMatch: { email: user.email } } } );
647
- if ( TeamMember&&TeamMember.length>0 ) {
651
+ if ( TeamMember && TeamMember.length > 0 ) {
648
652
  for ( let team of TeamMember ) {
649
653
  let clusterList = await findcluster( { clientId: inputData.clientId, teams: { $elemMatch: { name: team.teamName } } } );
650
654
  if ( clusterList.length > 0 ) {
@@ -655,7 +659,7 @@ export async function emailUserListv2( req, res ) {
655
659
  }
656
660
  }
657
661
  let TeamLeader = await findteams( { clientId: inputData.clientId, Teamlead: { $elemMatch: { email: user.email } } } );
658
- if ( TeamLeader&&TeamLeader.length>0 ) {
662
+ if ( TeamLeader && TeamLeader.length > 0 ) {
659
663
  for ( let team of TeamLeader ) {
660
664
  let clusterList = await findcluster( { clientId: inputData.clientId, teams: { $elemMatch: { name: team.teamName } } } );
661
665
  if ( clusterList.length > 0 ) {
@@ -775,7 +779,7 @@ export async function OutsideUserList( req, res ) {
775
779
  data.Finalstores = [ ...data.stores, ...data.groups ];
776
780
  data.Finalstores = [ ...new Set( data.Finalstores ) ];
777
781
  data.assigned = data.Finalstores.length;
778
- data.assignedValue=[];
782
+ data.assignedValue = [];
779
783
  for ( let store of data.Finalstores ) {
780
784
  let obj = { storeName: store };
781
785
  data.assignedValue.push( obj );
@@ -903,7 +907,7 @@ export async function OutsideUserListv2( req, res ) {
903
907
  data.Finalstores = [ ...data.stores, ...storelist ];
904
908
  data.Finalstores = [ ...new Set( data.Finalstores ) ];
905
909
  data.assigned = data.Finalstores.length;
906
- data.assignedValue=[];
910
+ data.assignedValue = [];
907
911
  for ( let store of data.Finalstores ) {
908
912
  let obj = { storeName: store };
909
913
  data.assignedValue.push( obj );
@@ -974,17 +978,17 @@ export async function AddemailUserv2( req, res ) {
974
978
 
975
979
  export async function getOutsideUser( req, res ) {
976
980
  try {
977
- let response= {};
981
+ let response = {};
978
982
  let finduser = await findOnemailonlyuser( { _id: req.body.userId } );
979
983
  response.name = finduser.name;
980
984
  response.email = finduser.email;
981
985
  response.clusters = [];
982
986
  response.stores = [];
983
- if ( finduser&&finduser.stores&&finduser.stores.length>0 ) {
987
+ if ( finduser && finduser.stores && finduser.stores.length > 0 ) {
984
988
  let storeslist = await findStore( { storeId: { $in: finduser.stores } }, { storeId: 1, storeName: 1 } );
985
989
  response.stores = storeslist;
986
990
  }
987
- if ( finduser&&finduser.clusters&&finduser.clusters.length>0 ) {
991
+ if ( finduser && finduser.clusters && finduser.clusters.length > 0 ) {
988
992
  let result = await findcluster( { _id: { $in: finduser.clusters } }, { clusterName: 1 } );
989
993
  response.clusters = result;
990
994
  return res.sendSuccess( response );
@@ -1456,7 +1460,7 @@ export async function allCounts( req, res ) {
1456
1460
  let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
1457
1461
  let countQuery = [];
1458
1462
 
1459
- if ( req.user&&req.user.userType ==='client'&&req.user.role!='superadmin' ) {
1463
+ if ( req.user && req.user.userType === 'client' && req.user.role != 'superadmin' ) {
1460
1464
  countQuery.push(
1461
1465
  {
1462
1466
  $match: {
@@ -1550,7 +1554,7 @@ export async function infraTable( req, res ) {
1550
1554
  },
1551
1555
  } );
1552
1556
  }
1553
- if ( req.user&&req.user.userType ==='client'&&req.user.role!='superadmin' ) {
1557
+ if ( req.user && req.user.userType === 'client' && req.user.role != 'superadmin' ) {
1554
1558
  query.push(
1555
1559
  {
1556
1560
  $match: {
@@ -1847,8 +1851,8 @@ export async function infraTable( req, res ) {
1847
1851
  exportdata.push( {
1848
1852
  'Ticket ID': element.ticketId,
1849
1853
  'Created Date': dayjs( element.issueDate ).format( 'DD MMM, YYYY' ),
1850
- 'Created Time': dayjs( element.createdAt ).format( 'hh:mm a' ),
1851
- 'Closed Time': element.issueClosedDate? dayjs( element.issueClosedDate ).format( 'hh:mm a' ):'--',
1854
+ 'Created Time': dayjs( element.createdAt ).tz( 'Asia/Kolkata' ).format( 'hh:mm a' ),
1855
+ 'Closed Time': element.issueClosedDate ? dayjs( element.issueClosedDate ).tz( 'Asia/Kolkata' ).format( 'hh:mm a' ) : '--',
1852
1856
  'Brand Name': element.clientName,
1853
1857
  'Brand ID': element.clientId,
1854
1858
  'Store Name': element.storeName,
@@ -1899,7 +1903,7 @@ export async function installationTable( req, res ) {
1899
1903
  },
1900
1904
  } );
1901
1905
  }
1902
- if ( req.user&&req.user.userType ==='client'&&req.user.role!='superadmin' ) {
1906
+ if ( req.user && req.user.userType === 'client' && req.user.role != 'superadmin' ) {
1903
1907
  query.push(
1904
1908
  {
1905
1909
  $match: {
@@ -2375,7 +2379,7 @@ export async function storeFilter( req, res ) {
2375
2379
  'issueType': { '$in': [ 'highcount', 'lowcount' ] }, 'basicDetails.clientId': inputData.clientId, 'basicDetails.storeId': { $exists: true },
2376
2380
  };
2377
2381
  }
2378
- if ( req.user&&req.user.userType ==='client'&&req.user.role!='superadmin' ) {
2382
+ if ( req.user && req.user.userType === 'client' && req.user.role != 'superadmin' ) {
2379
2383
  query = { ...query, 'basicDetails.storeId': { $in: req.body.assignedStores } };
2380
2384
  }
2381
2385
 
@@ -2413,7 +2417,7 @@ export async function dataMismatchTable( req, res ) {
2413
2417
  },
2414
2418
 
2415
2419
  ];
2416
- if ( req.user&&req.user.userType ==='client'&&req.user.role!='superadmin' ) {
2420
+ if ( req.user && req.user.userType === 'client' && req.user.role != 'superadmin' ) {
2417
2421
  countFilter.push(
2418
2422
  { 'basicDetails.storeId': { $in: req.body.assignedStores } },
2419
2423
  );
@@ -2483,7 +2487,7 @@ export async function dataMismatchTable( req, res ) {
2483
2487
  { 'basicDetails.clientId': { $in: inputData.clientId } },
2484
2488
  { issueType: { $in: [ 'highcount', 'lowcount' ] } },
2485
2489
  ];
2486
- if ( req.user&&req.user.userType ==='client'&&req.user.role!='superadmin' ) {
2490
+ if ( req.user && req.user.userType === 'client' && req.user.role != 'superadmin' ) {
2487
2491
  filter.push(
2488
2492
  { 'basicDetails.storeId': { $in: req.body.assignedStores } },
2489
2493
  );
@@ -2824,3 +2828,269 @@ export async function checkPermission( req, res, next ) {
2824
2828
  res.sendError( 'Internal Server Error', 500 );
2825
2829
  }
2826
2830
  };
2831
+
2832
+ export async function userMetricscard( req, res ) {
2833
+ try {
2834
+ let auditMetrics= await aggreagteUserAudit( [
2835
+ {
2836
+ $match: {
2837
+ 'auditType': 'Audit',
2838
+ 'auditStatus': 'completed',
2839
+ 'userId': new mongoose.Types.ObjectId( req.query.userId ),
2840
+ },
2841
+ },
2842
+ {
2843
+ $project: {
2844
+ beforeCount: 1,
2845
+ afterCount: 1,
2846
+ },
2847
+ },
2848
+ {
2849
+ $group: {
2850
+ _id: null,
2851
+ total: { $sum: 1 },
2852
+ beforeCount: { $sum: '$beforeCount' },
2853
+ afterCount: { $sum: '$afterCount' },
2854
+ },
2855
+ },
2856
+ {
2857
+ $project: {
2858
+ _id: 0,
2859
+ total: 1,
2860
+ beforeCount: 1,
2861
+ afterCount: 1,
2862
+ mappingPercentage: {
2863
+ $round: [
2864
+ { $multiply: [ { $divide: [ '$afterCount', '$beforeCount' ] }, 100 ] },
2865
+ 2,
2866
+ ],
2867
+ },
2868
+ },
2869
+ },
2870
+ ] );
2871
+ let reauditMetrics= await aggreagteUserAudit( [
2872
+ {
2873
+ $match: {
2874
+ 'auditType': 'ReAudit',
2875
+ 'auditStatus': 'completed',
2876
+ 'userId': new mongoose.Types.ObjectId( req.query.userId ),
2877
+ },
2878
+ },
2879
+ {
2880
+ $project: {
2881
+ beforeCount: 1,
2882
+ afterCount: 1,
2883
+ },
2884
+ },
2885
+ {
2886
+ $group: {
2887
+ _id: null,
2888
+ total: { $sum: 1 },
2889
+ beforeCount: { $sum: '$beforeCount' },
2890
+ afterCount: { $sum: '$afterCount' },
2891
+ },
2892
+ },
2893
+ {
2894
+ $project: {
2895
+ _id: 0,
2896
+ total: 1,
2897
+ beforeCount: 1,
2898
+ afterCount: 1,
2899
+ mappingPercentage: {
2900
+ $round: [
2901
+ { $multiply: [ { $divide: [ '$afterCount', '$beforeCount' ] }, 100 ] },
2902
+ 2,
2903
+ ],
2904
+ },
2905
+ },
2906
+ },
2907
+ ] );
2908
+ let installation= await aggregateTangoTicket( [
2909
+ {
2910
+ $match: {
2911
+ 'issueType': 'installation',
2912
+ 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.query.userId ),
2913
+ },
2914
+ },
2915
+ {
2916
+ $project: {
2917
+ status: 1,
2918
+ onboarded: {
2919
+ $cond: [ { $and: [ { $eq: [ '$ticketDetails.installationStatus', 'onboarded' ] } ] }, 1, 0 ],
2920
+ },
2921
+ paired: {
2922
+ $cond: [ { $and: [ { $eq: [ '$ticketDetails.installationStatus', 'paired' ] } ] }, 1, 0 ],
2923
+ },
2924
+ deployed: {
2925
+ $cond: [ { $and: [ { $eq: [ '$ticketDetails.installationStatus', 'deployed' ] } ] }, 1, 0 ],
2926
+ },
2927
+ },
2928
+ },
2929
+ {
2930
+ $group: {
2931
+ _id: null,
2932
+ onboardedCount: { $sum: '$onboarded' },
2933
+ pairedCount: { $sum: '$paired' },
2934
+ deployedCount: { $sum: '$deployed' },
2935
+ },
2936
+ },
2937
+ {
2938
+ $project: {
2939
+ _id: 0,
2940
+ total: { $add: [ '$onboardedCount', '$pairedCount', '$deployedCount' ] },
2941
+ onboardedCount: 1,
2942
+ pairedCount: 1,
2943
+ deployedCount: 1,
2944
+ },
2945
+ },
2946
+ ] );
2947
+ let infra= await aggregateTangoTicket( [
2948
+ {
2949
+ $match: {
2950
+ 'issueType': 'infra',
2951
+ 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.query.userId ),
2952
+ },
2953
+ },
2954
+ {
2955
+ $project: {
2956
+ status: 1,
2957
+ open: {
2958
+ $cond: [ { $and: [ { $eq: [ '$status', 'open' ] } ] }, 1, 0 ],
2959
+ },
2960
+ inprogress: {
2961
+ $cond: [ { $and: [ { $eq: [ '$status', 'inprogress' ] } ] }, 1, 0 ],
2962
+ },
2963
+ closed: {
2964
+ $cond: [ { $and: [ { $eq: [ '$status', 'closed' ] } ] }, 1, 0 ],
2965
+ },
2966
+ },
2967
+ },
2968
+ {
2969
+ $group: {
2970
+ _id: null,
2971
+ openCount: { $sum: '$open' },
2972
+ inprogressCount: { $sum: '$inprogress' },
2973
+ closedCount: { $sum: '$closed' },
2974
+ },
2975
+ },
2976
+ {
2977
+ $project: {
2978
+ _id: 0,
2979
+ total: { $add: [ '$openCount', '$inprogressCount', '$closedCount' ] },
2980
+ openCount: 1,
2981
+ inprogressCount: 1,
2982
+ closedCount: 1,
2983
+ },
2984
+ },
2985
+ ] );
2986
+ let dataMismatch= await aggregateTangoTicket( [
2987
+ {
2988
+ $match: {
2989
+ 'issueType': { $in: [ 'highcount', 'lowcount' ] },
2990
+ 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.query.userId ),
2991
+ },
2992
+ },
2993
+ {
2994
+ $project: {
2995
+ status: 1,
2996
+ open: {
2997
+ $cond: [ { $and: [ { $eq: [ '$status', 'open' ] } ] }, 1, 0 ],
2998
+ },
2999
+ inprogress: {
3000
+ $cond: [ { $and: [ { $eq: [ '$status', 'inprogress' ] } ] }, 1, 0 ],
3001
+ },
3002
+ closed: {
3003
+ $cond: [ { $and: [ { $eq: [ '$status', 'closed' ] } ] }, 1, 0 ],
3004
+ },
3005
+ },
3006
+ },
3007
+ {
3008
+ $group: {
3009
+ _id: null,
3010
+ openCount: { $sum: '$open' },
3011
+ inprogressCount: { $sum: '$inprogress' },
3012
+ closedCount: { $sum: '$closed' },
3013
+ },
3014
+ },
3015
+ {
3016
+ $project: {
3017
+ _id: 0,
3018
+ total: { $add: [ '$openCount', '$inprogressCount', '$closedCount' ] },
3019
+ openCount: 1,
3020
+ inprogressCount: 1,
3021
+ closedCount: 1,
3022
+ },
3023
+ },
3024
+ ] );
3025
+ let mat= await aggregateTangoTicket( [
3026
+ {
3027
+ $match: {
3028
+ 'issueType': 'mat',
3029
+ 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.query.userId ),
3030
+ },
3031
+ },
3032
+ {
3033
+ $project: {
3034
+ status: 1,
3035
+ open: {
3036
+ $cond: [ { $and: [ { $eq: [ '$status', 'open' ] } ] }, 1, 0 ],
3037
+ },
3038
+ inprogress: {
3039
+ $cond: [ { $and: [ { $eq: [ '$status', 'inprogress' ] } ] }, 1, 0 ],
3040
+ },
3041
+ closed: {
3042
+ $cond: [ { $and: [ { $eq: [ '$status', 'closed' ] } ] }, 1, 0 ],
3043
+ },
3044
+ },
3045
+ },
3046
+ {
3047
+ $group: {
3048
+ _id: null,
3049
+ openCount: { $sum: '$open' },
3050
+ inprogressCount: { $sum: '$inprogress' },
3051
+ closedCount: { $sum: '$closed' },
3052
+ },
3053
+ },
3054
+ {
3055
+ $project: {
3056
+ _id: 0,
3057
+ total: { $add: [ '$openCount', '$inprogressCount', '$closedCount' ] },
3058
+ openCount: 1,
3059
+ inprogressCount: 1,
3060
+ closedCount: 1,
3061
+ },
3062
+ },
3063
+ ] );
3064
+
3065
+
3066
+ res.sendSuccess( { auditMetrics: auditMetrics, reauditMetrics: reauditMetrics, installation: installation, infra: infra, dataMismatch: dataMismatch, mat: mat } );
3067
+ } catch ( error ) {
3068
+ logger.error( { error: error, function: 'userMetricscard' } );
3069
+ res.sendError( 'Internal Server Error', 500 );
3070
+ }
3071
+ };
3072
+
3073
+ export async function userMetricsticketTable( req, res ) {
3074
+ try {
3075
+ let tableData= await aggregateTangoTicket( [
3076
+ {
3077
+ $match: {
3078
+ 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ),
3079
+ },
3080
+ },
3081
+ {
3082
+ $project: {
3083
+ ticketId: 1,
3084
+ createdAt: 1,
3085
+ brandName: '$t',
3086
+ },
3087
+ },
3088
+ ] );
3089
+
3090
+
3091
+ res.sendSuccess( tableData );
3092
+ } catch ( error ) {
3093
+ logger.error( { error: error, function: 'userMetricsticketTable' } );
3094
+ res.sendError( 'Internal Server Error', 500 );
3095
+ }
3096
+ };
@@ -592,6 +592,7 @@ export async function emailUserListv2( req, res ) {
592
592
  email: 1,
593
593
  role: 1,
594
594
  userType: 1,
595
+ assignedStores: 1,
595
596
  },
596
597
  },
597
598
  ],
@@ -613,8 +614,7 @@ export async function emailUserListv2( req, res ) {
613
614
  'userName': '$user.userName',
614
615
  'role': '$user.role',
615
616
  'userType': '$user.userType',
616
-
617
-
617
+ 'assignedStores': '$user.assignedStores',
618
618
  },
619
619
  },
620
620
  {
@@ -626,6 +626,7 @@ export async function emailUserListv2( req, res ) {
626
626
  'userName': { $first: '$userName' },
627
627
  'role': { $first: '$role' },
628
628
  'userType': { $first: '$userType' },
629
+ 'assignedStores': { $first: '$assignedStores' },
629
630
 
630
631
 
631
632
  },
@@ -687,11 +688,11 @@ export async function emailUserListv2( req, res ) {
687
688
  }
688
689
  for ( let cluster of user.clusters ) {
689
690
  let clusterdata = await findOneCluster( { '_id': cluster, 'clientId': req.query.clientId } );
690
- console.log( clusterdata );
691
+
691
692
  if ( clusterdata&&clusterdata.stores ) {
692
693
  let stores = clusterdata.stores.map( ( data ) => data.storeId );
693
694
  let storelist = await findStore( { 'storeId': { $in: stores }, 'status': 'active', 'edge.firstFile': true }, { 'storeId': 1, 'storeProfile.timeZone': 1 } );
694
- console.log( storelist );
695
+
695
696
  obj.storeList = [ ...obj.storeList, ...storelist ];
696
697
  }
697
698
  }
@@ -765,6 +766,7 @@ export async function emailUserListv2( req, res ) {
765
766
  }
766
767
  }
767
768
  }
769
+
768
770
  user.assigned = Array.from( storeIds );
769
771
  let storeList = await findStore( { clientId: user.clientId, storeId: { $in: user.assigned }, status: 'active' }, { storeId: 1, storeName: 1, storeProfile: 1 } );
770
772
  user.assigned = storeList.length;
@@ -1020,13 +1022,14 @@ export async function infraReportSent( req, res ) {
1020
1022
 
1021
1023
  let attachments = null;
1022
1024
  let buffer = await download( exportdata );
1025
+ let reportDate = dayjs().format( 'DD-MM-YYYY' );
1023
1026
  attachments = {
1024
- filename: `dailyInfraReport- ${date}.xlsx`,
1027
+ filename: `dailyInfraReport- ${reportDate}.xlsx`,
1025
1028
  content: buffer,
1026
1029
  contentType: 'application/xlsx', // e.g., 'application/pdf'
1027
1030
  };
1028
1031
 
1029
- const subject = `${client.clientName} Daily Digest - Infra Downtime Report - ${date}`;
1032
+ const subject = `${client.clientName} Daily Digest - Infra Downtime Report - ${reportDate}`;
1030
1033
  const fileContent = readFileSync( join() + '/src/hbs/dailyInfraReport.hbs', 'utf8' );
1031
1034
  const htmlContent = handlebars.compile( fileContent );
1032
1035
  let Uidomain = `${JSON.parse( process.env.URL ).domain}`;
@@ -46,6 +46,7 @@ export async function storeTicketList( req, res ) {
46
46
  storeId: '$basicDetails.storeId',
47
47
  status: 1,
48
48
  issueDate: '$issueDate',
49
+ createdAt: 1,
49
50
  Date: { $dateToString: { format: '%d-%m-%Y', date: '$createdAt' } },
50
51
  issueClosedDate: 1,
51
52
  ticketId: 1,
@@ -108,6 +109,7 @@ export async function storeTicketList( req, res ) {
108
109
  ticketId: 1,
109
110
  issueStatus: 1,
110
111
  ticketType: 1,
112
+ createdAt: 1,
111
113
  comments: { $size: '$comments' },
112
114
  issueDate: 1,
113
115
  commentText: '$primaryIssue.comment',
@@ -121,6 +123,7 @@ export async function storeTicketList( req, res ) {
121
123
  _id: '$ticketId',
122
124
  storeId: { $first: '$storeId' },
123
125
  Date: { $first: '$Date' },
126
+ createdAt: { $first: '$createdAt' },
124
127
  issueClosedDate: { $first: '$issueClosedDate' },
125
128
  status: { $first: '$status' },
126
129
  issueDate: { $first: '$issueDate' },
@@ -156,7 +159,7 @@ export async function storeTicketList( req, res ) {
156
159
  exportdata.push( {
157
160
  'STORE ID': element.storeId,
158
161
  'TICKET ID': element.ticketId,
159
- 'DATE': dayjs( element.Date ).format( 'DD MMM, YYYY' ),
162
+ 'DATE': dayjs( element.createdAt ).format( 'DD MMM, YYYY' ),
160
163
  'ISSUE CLOSED DATE': dayjs( element.issueClosedDate ).format( 'DD MMM, YYYY' ),
161
164
  'PRIMARY ISSUE': element.primaryIssue,
162
165
  'SECONDARY ISSUE': element.secondaryIssue,
@@ -7,6 +7,9 @@ import { findOneGroup } from '../services/group.service.js';
7
7
  import { findUserAssignedStore } from '../services/userAssignedStore.service.js';
8
8
  import mongoose from 'mongoose';
9
9
  import dayjs from 'dayjs';
10
+ import { countDocumentsUserAudit } from '../services/userAudit.service.js';
11
+ import { countDocumentsUserEmpDetection } from '../services/userEmpDetection.service.js';
12
+ import { countDocumentsBinaryAudit } from '../services/binaryAudit.service.js';
10
13
 
11
14
  export async function userTakeTicket( req, res ) {
12
15
  try {
@@ -333,6 +336,10 @@ export async function basicDetails( req, res ) {
333
336
  let installationCount = await countDocumentsTangoTicket( { 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ), 'issueType': 'installation' } );
334
337
  let dataMismatchCount = await countDocumentsTangoTicket( { 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ), 'issueType': { $in: [ 'highcount', 'lowcount' ] } } );
335
338
  let employeeTrainingCount = await countDocumentsTangoTicket( { 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ), 'issueType': 'mat' } );
339
+ let tangoAuditCount = await countDocumentsUserAudit( { userId: new mongoose.Types.ObjectId( req.body.userId ), auditStatus: 'completed' } );
340
+ let mappingAudit = await countDocumentsUserEmpDetection( { userId: new mongoose.Types.ObjectId( req.body.userId ), auditStatus: 'completed' } );
341
+ let binaryAudit = await countDocumentsBinaryAudit( { userId: new mongoose.Types.ObjectId( req.body.userId ), auditStatus: 'completed' } );
342
+ let traxAudit = mappingAudit + binaryAudit;
336
343
  res.sendSuccess( {
337
344
  userName: user.userName,
338
345
  userType: user.userType,
@@ -342,6 +349,8 @@ export async function basicDetails( req, res ) {
342
349
  dataMismatchCount: dataMismatchCount,
343
350
  auditCount: 0,
344
351
  employeeTrainingCount: employeeTrainingCount,
352
+ traxAudit: traxAudit,
353
+ tangoAuditCount: tangoAuditCount,
345
354
  } );
346
355
  } catch ( error ) {
347
356
  logger.error( { error: error, function: 'userTakeTicket' } );
@@ -4,7 +4,7 @@ import { isAllowedSessionHandler, validate, getAssinedStore } from 'tango-app-ap
4
4
  import { validateDetails, bulkvalidateDetails, validateTicket, bulkvalidateTicket, validateTicketstatus, ticketExists, infraReasonExists, InfrastepstoResolve, InfraAlert } from '../validations/infra.validation.js';
5
5
  import { createTicket, bulkcreateTicket, updateStatus, createReason, PrimaryReasons, matTable, removeAttachment,
6
6
  secondaryReason, updateTicketIssue, viewTicket, AlertTicketReply, uploadAttachments, getInfraIssues, AddemailUser, OutsideUserList, emailUserListv2, OutsideUserListv2, AddemailUserv2, getOutsideUser, deleteOutsideUser, editemailUser,
7
- updateInstallationTicket, emailUserList, saveInfraEmailConfig, invoice, allCounts, infraTable, dataMismatchTable, storeFilter, assignTicket, installationTable } from '../controllers/infra.controllers.js';
7
+ updateInstallationTicket, emailUserList, saveInfraEmailConfig, invoice, allCounts, infraTable, dataMismatchTable, storeFilter, assignTicket, installationTable, userMetricscard, userMetricsticketTable } from '../controllers/infra.controllers.js';
8
8
  import { getInfraIssueValid } from '../dtos/infra.dtos.js';
9
9
 
10
10
 
@@ -47,4 +47,7 @@ infraRouter.post( '/dataMismatchTable', isAllowedSessionHandler, getAssinedStore
47
47
  infraRouter.post( '/assignTicket', isAllowedSessionHandler, assignTicket );
48
48
  infraRouter.post( '/storeFilter', isAllowedSessionHandler, getAssinedStore, storeFilter );
49
49
  infraRouter.post( '/get-infra-issues', isAllowedSessionHandler, validate( getInfraIssueValid ), getInfraIssues );
50
+ infraRouter.get( '/userMetricscard', userMetricscard );
51
+ infraRouter.post( '/userMetricsticketTable', userMetricsticketTable );
52
+
50
53
 
@@ -0,0 +1,5 @@
1
+ import binaryAuditModel from 'tango-api-schema/schema/binaryAudit.model.js';
2
+
3
+ export async function countDocumentsBinaryAudit( query, data ) {
4
+ return await binaryAuditModel.countDocuments( query );
5
+ }
@@ -0,0 +1,9 @@
1
+ import userAuditModel from 'tango-api-schema/schema/userAudit.model.js';
2
+
3
+ export async function countDocumentsUserAudit( query ) {
4
+ return await userAuditModel.countDocuments( query );
5
+ }
6
+
7
+ export async function aggreagteUserAudit( query ) {
8
+ return await userAuditModel.aggregate( query );
9
+ }
@@ -0,0 +1,5 @@
1
+ import userEmpDetectionModel from 'tango-api-schema/schema/userEmpDetection.model.js';
2
+
3
+ export async function countDocumentsUserEmpDetection( query, data ) {
4
+ return await userEmpDetectionModel.countDocuments( query );
5
+ }