tango-app-api-infra 3.1.5 → 3.1.7

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/index.js CHANGED
@@ -5,6 +5,8 @@ import { internalInfraRouter } from './src/routes/internalInfra.routes.js';
5
5
  import { userInfraRouter } from './src/routes/userInfra.routes.js';
6
6
  import { storeInfraRouter } from './src/routes/storeInfra.routes.js';
7
7
  import { clientInfraRouter } from './src/routes/clientInfra.routes.js';
8
- export { infraRouter, internalInfraRouter, userInfraRouter, storeInfraRouter, clientInfraRouter };
8
+ import { employeeTrainigRouter } from './src/routes/employeetrainig.routes.js';
9
+
10
+ export { infraRouter, internalInfraRouter, userInfraRouter, storeInfraRouter, clientInfraRouter, employeeTrainigRouter };
9
11
 
10
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-infra",
3
- "version": "3.1.5",
3
+ "version": "3.1.7",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -24,8 +24,8 @@
24
24
  "html-pdf-node": "^1.0.8",
25
25
  "mongodb": "^6.4.0",
26
26
  "nodemon": "^3.1.0",
27
- "tango-api-schema": "^2.0.90",
28
- "tango-app-api-middleware": "^3.1.3",
27
+ "tango-api-schema": "^2.0.93",
28
+ "tango-app-api-middleware": "^3.1.7",
29
29
  "winston": "^3.12.0",
30
30
  "winston-daily-rotate-file": "^5.0.0"
31
31
  },
@@ -211,10 +211,10 @@ export async function installationCard( req, res ) {
211
211
  $group: {
212
212
  _id: '$ticketId',
213
213
  ticketId: { $first: '$ticketId' },
214
- issueStatus: { $first: '$issueStatus' },
215
- ticketType: { $first: '$ticketType' },
216
- issueIdentifiedBy: { $first: '$issueIdentifiedBy' },
217
- primaryIssue: { $first: '$primaryIssue' },
214
+ issueStatus: { $last: '$issueStatus' },
215
+ ticketType: { $last: '$ticketType' },
216
+ issueIdentifiedBy: { $last: '$issueIdentifiedBy' },
217
+ primaryIssue: { $last: '$primaryIssue' },
218
218
  },
219
219
  },
220
220
  ];
@@ -461,8 +461,8 @@ export async function InstallationIssuesTable( req, res ) {
461
461
  storeId: { $first: '$storeId' },
462
462
  clientId: { $first: '$clientId' },
463
463
  storeName: { $first: '$storeName' },
464
- status: { $first: '$status' },
465
- primaryIssue: { $first: '$primaryIssue' },
464
+ status: { $last: '$status' },
465
+ primaryIssue: { $last: '$primaryIssue' },
466
466
  },
467
467
  },
468
468
  ];
@@ -0,0 +1,54 @@
1
+
2
+ import { createTangoTicket, findOneTangoTicket, updateOneTangoTicket } from '../services/tangoTicket.service.js';
3
+ import { logger } from 'tango-app-api-middleware';
4
+ export async function createTicket( req, res ) {
5
+ console.log( req.body );
6
+ try {
7
+ let ticketExist = await findOneTangoTicket( { 'issueType': req.body.issueType, 'basicDetails.storeId': req.body.storeId } );
8
+ if ( ticketExist ) {
9
+ return res.sendSuccess( 'MAT Ticket Already Exists for the store' );
10
+ }
11
+
12
+ req.body.issueDate = new Date( req.body.Date );
13
+ req.body.ticketId = 'TE_MAT_' + new Date().valueOf();
14
+ let create = await createTangoTicket( req.body );
15
+ console.log( create );
16
+ if ( create ) {
17
+ res.sendSuccess( 'Ticket Created Successfully' );
18
+ }
19
+ } catch ( error ) {
20
+ logger.error( { error: error, function: 'createTicket mat' } );
21
+ return res.sendError( error, 500 );
22
+ }
23
+ }
24
+
25
+ export async function updatecomment( req, res ) {
26
+ console.log( req.body );
27
+ try {
28
+ if ( req.body.comment != '' ) {
29
+ req.body.ticketActivity.push( {
30
+ actionType: 'comment',
31
+ actionBy: 'Tango',
32
+ timeStamp: new Date(),
33
+ IdentifiedBy: req.user.userName,
34
+ comment: req.body.comment,
35
+ } );
36
+ }
37
+ let updateTicket = await updateOneTangoTicket( { ticketId: req.body.ticketId }, { ticketActivity: req.body.ticketActivity } );
38
+ if ( updateTicket ) {
39
+ res.sendSuccess( 'Ticket Updated Successfully' );
40
+ }
41
+ } catch ( error ) {
42
+ logger.error( { error: error, function: 'updatecomment mat' } );
43
+ return res.sendError( error, 500 );
44
+ }
45
+ }
46
+ export async function activityLog( req, res ) {
47
+ console.log( req.body );
48
+ try {
49
+ res.sendSuccess( req.body );
50
+ } catch ( error ) {
51
+ logger.error( { error: error, function: 'activityLog mat' } );
52
+ return res.sendError( error, 500 );
53
+ }
54
+ }
@@ -1,9 +1,9 @@
1
1
 
2
2
 
3
- import { createTangoTicket, findOneTangoTicket, updateOneTangoTicket } from '../services/tangoTicket.service.js';
3
+ import { aggregateTangoTicket, createTangoTicket, findOneTangoTicket, updateOneTangoTicket, updateManyTangoTicket, findTangoTicket } from '../services/tangoTicket.service.js';
4
4
  import { createinfraReason, findinfraReason } from '../services/infraReason.service.js';
5
5
  import { updateOneStore, findStore } from '../services/store.service.js';
6
- import { logger, fileUpload, signedUrl, sendEmailWithSES, getOpenSearchData, appConfig } from 'tango-app-api-middleware';
6
+ import { logger, fileUpload, signedUrl, sendEmailWithSES, getOpenSearchData, download, appConfig, getUTC } from 'tango-app-api-middleware';
7
7
  import { aggregateUser, updateOneUser } from '../services/user.service.js';
8
8
  import { updateoneClient } from '../services/client.service.js';
9
9
  import dayjs from 'dayjs';
@@ -75,7 +75,7 @@ export async function createTicket( req, res ) {
75
75
  let Uidomain = `${appConfig.url.domain}/manage/stores/infra-ticket?storeId=${req.body.basicDetails.storeId}`;
76
76
 
77
77
  const html = htmlContent( { ...req.body, Uidomain: Uidomain, domain: appConfig.url.apiDomain, date: dayjs( req.body.issueDate ).format( 'YYYY-MM-DD' ), downtimetotal: downtimetotal, Timestamp: Timestamp } );
78
- if ( req.body.emailAlert&&req.body.spocEmail&&req.body.issueType == 'infra'&&isValidEmail( req.body.spocEmail ) ) {
78
+ if ( req.body.emailAlert && req.body.spocEmail && req.body.issueType == 'infra' && isValidEmail( req.body.spocEmail ) ) {
79
79
  await sendEmailWithSES( req.body.spocEmail, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
80
80
  }
81
81
  if ( create ) {
@@ -621,3 +621,666 @@ function inWords( num ) {
621
621
 
622
622
  return str.toLowerCase().split( ' ' ).map( ( word ) => word.charAt( 0 ).toUpperCase() + word.slice( 1 ) ).join( ' ' );
623
623
  }
624
+
625
+
626
+ export async function infraTable( req, res ) {
627
+ try {
628
+ let query = [];
629
+ let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
630
+ if ( req.body.clientId && req.body.clientId.length > 0 ) {
631
+ query.push( {
632
+ $match: {
633
+ 'basicDetails.clientId': { $in: req.body.clientId },
634
+ },
635
+ } );
636
+ }
637
+ query.push( {
638
+ $match: {
639
+ $and: [
640
+ { issueType: 'infra' },
641
+ { createdAt: { $gte: date.start } },
642
+ { createdAt: { $lte: date.end } },
643
+ ],
644
+ },
645
+ }, {
646
+ $project: {
647
+ storeId: '$basicDetails.storeId',
648
+ clientId: '$basicDetails.clientId',
649
+ ticketId: 1,
650
+ storeName: '$basicDetails.storeName',
651
+ clientName: '$basicDetails.clientName',
652
+ status: 1,
653
+ createdAt: 1,
654
+ issueDate: 1,
655
+ addressingUser: { $toObjectId: '$ticketDetails.addressingUser' },
656
+ primaryIssue: {
657
+ $filter: {
658
+ input: '$ticketActivity',
659
+ as: 'item',
660
+ cond: { $eq: [ '$$item.actionType', 'issueUpdate' ] },
661
+ },
662
+ },
663
+ },
664
+ },
665
+ {
666
+ $unwind: {
667
+ path: '$primaryIssue', preserveNullAndEmptyArrays: true,
668
+ },
669
+ },
670
+ {
671
+ $unwind: {
672
+ path: '$primaryIssue.reasons', preserveNullAndEmptyArrays: true,
673
+ },
674
+ },
675
+ {
676
+ $unwind: {
677
+ path: '$primaryIssue.reasons.secondaryIssue', preserveNullAndEmptyArrays: true,
678
+ },
679
+ },
680
+ {
681
+ $project: {
682
+ storeId: 1,
683
+ clientId: 1,
684
+ storeName: 1,
685
+ clientName: 1,
686
+ createdAt: 1,
687
+ addressingUser: 1,
688
+ ticketId: 1,
689
+ issueDate: { $ifNull: [ '$issueDate', '' ] },
690
+ status: 1,
691
+ primaryIssue: { $ifNull: [ '$primaryIssue.reasons.primaryIssue', '-' ] },
692
+ secondaryIssue: { $ifNull: [ '$primaryIssue.reasons.secondaryIssue.name', '-' ] },
693
+ },
694
+ },
695
+ {
696
+ '$lookup': {
697
+ 'from': 'users',
698
+ 'let': { 'userId': '$addressingUser' },
699
+ 'pipeline': [
700
+ {
701
+ '$match': {
702
+ '$expr': {
703
+ '$eq': [ '$_id', '$$userId' ],
704
+ },
705
+ },
706
+ },
707
+ {
708
+ '$project': {
709
+ 'userName': 1,
710
+ 'email': 1,
711
+ 'role': 1,
712
+ },
713
+ },
714
+ ],
715
+ 'as': 'user',
716
+ },
717
+ },
718
+
719
+ {
720
+ $unwind: {
721
+ path: '$user',
722
+ preserveNullAndEmptyArrays: true,
723
+ },
724
+ },
725
+ {
726
+ $group: {
727
+ _id: '$ticketId',
728
+ storeId: { $first: '$storeId' },
729
+ clientId: { $first: '$clientId' },
730
+ ticketId: { $first: '$ticketId' },
731
+ storeName: { $first: '$storeName' },
732
+ userName: { $first: { $ifNull: [ '$user.userName', '-' ] } },
733
+ userEmail: { $first: { $ifNull: [ '$user.email', '-' ] } },
734
+ clientName: { $first: '$clientName' },
735
+ createdAt: { $first: '$createdAt' },
736
+ issueDate: { $last: '$issueDate' },
737
+ status: { $last: '$status' },
738
+ primaryIssue: { $last: '$primaryIssue' },
739
+ secondaryIssue: { $last: '$secondaryIssue' },
740
+ },
741
+ },
742
+ );
743
+ if ( req.body.sortColumName && req.body.sortColumName !== '' && req.body.sortBy ) {
744
+ query.push( {
745
+ $sort: { [req.body.sortColumName]: req.body.sortBy },
746
+ } );
747
+ }
748
+ if ( req.body.storeIdFilter && req.body.storeIdFilter.length > 0 ) {
749
+ query.push( {
750
+ $match: {
751
+ storeId: { $in: req.body.storeIdFilter },
752
+ },
753
+ } );
754
+ }
755
+ if ( req.body.statusFilter && req.body.statusFilter.length > 0 ) {
756
+ query.push( {
757
+ $match: {
758
+ status: { $in: req.body.statusFilter },
759
+ },
760
+ } );
761
+ }
762
+ if ( req.body.userFilter && req.body.userFilter.length > 0 ) {
763
+ query.push( {
764
+ $match: {
765
+ userEmail: { $in: req.body.userFilter },
766
+ },
767
+ } );
768
+ }
769
+ let ticketList = await aggregateTangoTicket( query );
770
+ let issueList = await findinfraReason( { parentId: { '$exists': false } } );
771
+ const categoryCounts = {};
772
+ let response;
773
+ if ( ticketList.length > 0 ) {
774
+ ticketList.forEach( ( item ) => {
775
+ const categoryName = item.primaryIssue;
776
+ if ( categoryCounts[categoryName] ) {
777
+ categoryCounts[categoryName]++;
778
+ } else {
779
+ categoryCounts[categoryName] = 1;
780
+ }
781
+ } );
782
+ response = issueList.map( ( category ) => ( {
783
+ name: category.name,
784
+ count: categoryCounts[category.name] || 0,
785
+ } ) );
786
+ } else {
787
+ response = issueList.map( ( category ) => ( {
788
+ name: category.name,
789
+ count: 0,
790
+ } ) );
791
+ }
792
+ response.push( {
793
+ 'name': 'total',
794
+ 'count': ticketList.length,
795
+
796
+ } );
797
+ if ( req.body.filterIssue && req.body.filterIssue != '' && req.body.filterIssue != 'total' ) {
798
+ query.push( {
799
+ $match: {
800
+ primaryIssue: req.body.filterIssue,
801
+ },
802
+ } );
803
+ }
804
+
805
+ if ( req.body.searchValue && req.body.searchValue != '' ) {
806
+ query.push( {
807
+ $match: {
808
+ $or: [
809
+ { storeId: { $regex: req.body.searchValue, $options: 'i' } },
810
+ { storeName: { $regex: req.body.searchValue, $options: 'i' } },
811
+ ],
812
+ },
813
+ } );
814
+ }
815
+ let count = await aggregateTangoTicket( query );
816
+
817
+ if ( req.body.limit && req.body.offset && !req.body.export ) {
818
+ query.push(
819
+ { $skip: ( req.body.offset - 1 ) * req.body.limit },
820
+ { $limit: Number( req.body.limit ) },
821
+ );
822
+ }
823
+ let result = await aggregateTangoTicket( query );
824
+ if ( req.body.export && result.length > 0 ) {
825
+ const exportdata = [];
826
+ result.forEach( ( element ) => {
827
+ exportdata.push( {
828
+ 'ticketId': element.ticketId,
829
+ 'issueDate': dayjs( element.issueDate ).format( 'DD-MM-YYYY' ),
830
+ 'storeId': element.storeId,
831
+ 'storeName': element.storeName,
832
+ 'clientId': element.clientId,
833
+ 'clientName': element.clientName,
834
+ 'userName': element.userName,
835
+ 'userEmail': element.userEmail,
836
+ 'Status': element.status,
837
+ 'StatusDetails': element.primaryIssue,
838
+ 'SubIssue': element.secondaryIssue,
839
+ } );
840
+ } );
841
+ await download( exportdata, res );
842
+ return;
843
+ }
844
+ if ( result.length > 0 ) {
845
+ res.sendSuccess( {
846
+ response: response,
847
+ count: count.length,
848
+ result: result,
849
+ } );
850
+ } else {
851
+ res.sendError( 'no data', 204 );
852
+ }
853
+ } catch ( error ) {
854
+ logger.error( { error: error, function: 'infraTable' } );
855
+ return res.sendError( error, 500 );
856
+ }
857
+ }
858
+ export async function installationTable( req, res ) {
859
+ try {
860
+ let query = [];
861
+ let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
862
+ if ( req.body.clientId && req.body.clientId.length > 0 ) {
863
+ query.push( {
864
+ $match: {
865
+ 'basicDetails.clientId': { $in: req.body.clientId },
866
+ },
867
+ } );
868
+ }
869
+
870
+ query.push( {
871
+ $match: {
872
+ $and: [
873
+ { issueType: 'installation' },
874
+ { createdAt: { $gte: date.start } },
875
+ { createdAt: { $lte: date.end } },
876
+ ],
877
+ },
878
+ },
879
+ {
880
+ $project: {
881
+ storeId: '$basicDetails.storeId',
882
+ clientId: '$basicDetails.clientId',
883
+ ticketId: 1,
884
+ storeName: '$basicDetails.storeName',
885
+ clientName: '$basicDetails.clientName',
886
+ status: 1,
887
+ createdAt: 1,
888
+ addressingUser: '$ticketDetails.addressingUser',
889
+ installationStatus: '$ticketDetails.installationStatus',
890
+ issueDate: 1,
891
+ primaryIssue: {
892
+ $filter: {
893
+ input: '$ticketActivity',
894
+ as: 'item',
895
+ cond: { $eq: [ '$$item.actionType', 'issueUpdate' ] },
896
+ },
897
+ },
898
+ },
899
+ },
900
+ {
901
+ $unwind: {
902
+ path: '$primaryIssue', preserveNullAndEmptyArrays: true,
903
+ },
904
+ },
905
+ {
906
+ $unwind: {
907
+ path: '$primaryIssue.reasons', preserveNullAndEmptyArrays: true,
908
+ },
909
+ },
910
+ {
911
+ $unwind: {
912
+ path: '$primaryIssue.reasons.secondaryIssue', preserveNullAndEmptyArrays: true,
913
+ },
914
+ },
915
+ {
916
+ $project: {
917
+ storeId: 1,
918
+ clientId: 1,
919
+ storeName: 1,
920
+ clientName: 1,
921
+ createdAt: 1,
922
+ ticketId: 1,
923
+ addressingUser: 1,
924
+ installationStatus: { $ifNull: [ '$installationStatus', '-' ] },
925
+ issueDate: { $ifNull: [ '$issueDate', '' ] },
926
+ status: 1,
927
+ primaryIssue: { $ifNull: [ '$primaryIssue.reasons.primaryIssue', '-' ] },
928
+ secondaryIssue: { $ifNull: [ '$primaryIssue.reasons.secondaryIssue.name', '-' ] },
929
+ },
930
+ },
931
+ {
932
+ '$lookup': {
933
+ 'from': 'users',
934
+ 'let': { 'userId': '$addressingUser' },
935
+ 'pipeline': [
936
+ {
937
+ '$match': {
938
+ '$expr': {
939
+ '$eq': [ '$_id', '$$userId' ],
940
+ },
941
+ },
942
+ },
943
+ {
944
+ '$project': {
945
+ 'userName': 1,
946
+ 'email': 1,
947
+ 'role': 1,
948
+ },
949
+ },
950
+ ],
951
+ 'as': 'user',
952
+ },
953
+ },
954
+
955
+ {
956
+ $unwind: {
957
+ path: '$user',
958
+ preserveNullAndEmptyArrays: true,
959
+ },
960
+ },
961
+ {
962
+ $group: {
963
+ _id: '$ticketId',
964
+ storeId: { $first: '$storeId' },
965
+ clientId: { $first: '$clientId' },
966
+ ticketId: { $first: '$ticketId' },
967
+ storeName: { $first: '$storeName' },
968
+ userName: { $first: { $ifNull: [ '$user.userName', '-' ] } },
969
+ userEmail: { $first: { $ifNull: [ '$user.email', '-' ] } },
970
+ clientName: { $first: '$clientName' },
971
+ createdAt: { $first: '$createdAt' },
972
+ issueDate: { $last: '$issueDate' },
973
+ installationStatus: { $last: '$installationStatus' },
974
+ status: { $last: '$status' },
975
+ primaryIssue: { $last: '$primaryIssue' },
976
+ secondaryIssue: { $last: '$secondaryIssue' },
977
+ },
978
+ },
979
+ );
980
+ if ( req.body.sortColumName && req.body.sortColumName !== '' && req.body.sortBy ) {
981
+ query.push( {
982
+ $sort: { [req.body.sortColumName]: req.body.sortBy },
983
+ } );
984
+ }
985
+ if ( req.body.storeIdFilter && req.body.storeIdFilter.length > 0 ) {
986
+ query.push( {
987
+ $match: {
988
+ storeId: { $in: req.body.storeIdFilter },
989
+ },
990
+ } );
991
+ }
992
+ if ( req.body.statusFilter && req.body.statusFilter.length > 0 ) {
993
+ query.push( {
994
+ $match: {
995
+ installationStatus: { $in: req.body.statusFilter },
996
+ },
997
+ } );
998
+ }
999
+ if ( req.body.userFilter && req.body.userFilter.length > 0 ) {
1000
+ query.push( {
1001
+ $match: {
1002
+ userEmail: { $in: req.body.userFilter },
1003
+ },
1004
+ } );
1005
+ }
1006
+ let ticketList = await aggregateTangoTicket( query );
1007
+ let issueList = await findinfraReason( { parentId: { '$exists': false } } );
1008
+ const categoryCounts = {};
1009
+ let response;
1010
+ if ( ticketList.length > 0 ) {
1011
+ ticketList.forEach( ( item ) => {
1012
+ const categoryName = item.primaryIssue;
1013
+ if ( categoryCounts[categoryName] ) {
1014
+ categoryCounts[categoryName]++;
1015
+ } else {
1016
+ categoryCounts[categoryName] = 1;
1017
+ }
1018
+ } );
1019
+ response = issueList.map( ( category ) => ( {
1020
+ name: category.name,
1021
+ count: categoryCounts[category.name] || 0,
1022
+ } ) );
1023
+ } else {
1024
+ response = issueList.map( ( category ) => ( {
1025
+ name: category.name,
1026
+ count: 0,
1027
+ } ) );
1028
+ }
1029
+ response.push( {
1030
+ 'name': 'total',
1031
+ 'count': ticketList.length,
1032
+
1033
+ } );
1034
+ if ( req.body.filterIssue && req.body.filterIssue != '' && req.body.filterIssue != 'total' ) {
1035
+ query.push( {
1036
+ $match: {
1037
+ primaryIssue: req.body.filterIssue,
1038
+ },
1039
+ } );
1040
+ }
1041
+ if ( req.body.searchValue && req.body.searchValue != '' ) {
1042
+ query.push( {
1043
+ $match: {
1044
+ $or: [
1045
+ { storeId: { $regex: req.body.searchValue, $options: 'i' } },
1046
+ { storeName: { $regex: req.body.searchValue, $options: 'i' } },
1047
+ ],
1048
+ },
1049
+ } );
1050
+ }
1051
+ let count = await aggregateTangoTicket( query );
1052
+ if ( req.body.limit && req.body.offset && !req.body.export ) {
1053
+ query.push(
1054
+ { $skip: ( req.body.offset - 1 ) * req.body.limit },
1055
+ { $limit: Number( req.body.limit ) },
1056
+ );
1057
+ }
1058
+ let result = await aggregateTangoTicket( query );
1059
+
1060
+ if ( req.body.export && result.length > 0 ) {
1061
+ const exportdata = [];
1062
+ result.forEach( ( element ) => {
1063
+ exportdata.push( {
1064
+ 'ticketId': element.ticketId,
1065
+ 'issueDate': dayjs( element.issueDate ).format( 'DD-MM-YYYY' ),
1066
+ 'storeId': element.storeId,
1067
+ 'storeName': element.storeName,
1068
+ 'clientId': element.clientId,
1069
+ 'clientName': element.clientName,
1070
+ 'userName': element.userName,
1071
+ 'userEmail': element.userEmail,
1072
+ 'Status': element.installationStatus,
1073
+ 'StatusDetails': element.primaryIssue,
1074
+ 'SubIssue': element.secondaryIssue,
1075
+ } );
1076
+ } );
1077
+ await download( exportdata, res );
1078
+ return;
1079
+ }
1080
+ if ( result.length > 0 ) {
1081
+ res.sendSuccess( {
1082
+ response: response,
1083
+ count: count.length,
1084
+ result: result,
1085
+ } );
1086
+ } else {
1087
+ res.sendError( 'no data', 204 );
1088
+ }
1089
+ } catch ( error ) {
1090
+ logger.error( { error: error, function: 'installationTable' } );
1091
+ return res.sendError( error, 500 );
1092
+ }
1093
+ }
1094
+ export async function matTable( req, res ) {
1095
+ try {
1096
+ let query = [];
1097
+ let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
1098
+ if ( req.body.clientId && req.body.clientId.length > 0 ) {
1099
+ query.push( {
1100
+ $match: {
1101
+ 'basicDetails.clientId': { $in: req.body.clientId },
1102
+ },
1103
+ } );
1104
+ }
1105
+
1106
+ query.push( {
1107
+ $match: {
1108
+ $and: [
1109
+ { issueType: 'mat' },
1110
+ { createdAt: { $gte: date.start } },
1111
+ { createdAt: { $lte: date.end } },
1112
+ ],
1113
+ },
1114
+ },
1115
+ {
1116
+ $project: {
1117
+ storeId: '$basicDetails.storeId',
1118
+ clientId: '$basicDetails.clientId',
1119
+ ticketId: 1,
1120
+ storeName: '$basicDetails.storeName',
1121
+ clientName: '$basicDetails.clientName',
1122
+ status: 1,
1123
+ createdAt: 1,
1124
+ addressingUser: '$ticketDetails.addressingUser',
1125
+ issueDate: 1,
1126
+ },
1127
+ },
1128
+
1129
+ {
1130
+ '$lookup': {
1131
+ 'from': 'users',
1132
+ 'let': { 'userId': '$addressingUser' },
1133
+ 'pipeline': [
1134
+ {
1135
+ '$match': {
1136
+ '$expr': {
1137
+ '$eq': [ '$_id', '$$userId' ],
1138
+ },
1139
+ },
1140
+ },
1141
+ {
1142
+ '$project': {
1143
+ 'userName': 1,
1144
+ 'email': 1,
1145
+ 'role': 1,
1146
+ },
1147
+ },
1148
+ ],
1149
+ 'as': 'user',
1150
+ },
1151
+ },
1152
+
1153
+ {
1154
+ $unwind: {
1155
+ path: '$user',
1156
+ preserveNullAndEmptyArrays: true,
1157
+ },
1158
+ },
1159
+ {
1160
+ $group: {
1161
+ _id: '$ticketId',
1162
+ storeId: { $first: '$storeId' },
1163
+ clientId: { $first: '$clientId' },
1164
+ ticketId: { $first: '$ticketId' },
1165
+ storeName: { $first: '$storeName' },
1166
+ userName: { $first: { $ifNull: [ '$user.userName', '-' ] } },
1167
+ userEmail: { $first: { $ifNull: [ '$user.email', '-' ] } },
1168
+ clientName: { $first: '$clientName' },
1169
+ createdAt: { $first: '$createdAt' },
1170
+ issueDate: { $last: '$issueDate' },
1171
+ status: { $last: '$status' },
1172
+ },
1173
+ },
1174
+ );
1175
+ if ( req.body.sortColumName && req.body.sortColumName !== '' && req.body.sortBy ) {
1176
+ query.push( {
1177
+ $sort: { [req.body.sortColumName]: req.body.sortBy },
1178
+ } );
1179
+ }
1180
+ if ( req.body.storeIdFilter && req.body.storeIdFilter.length > 0 ) {
1181
+ query.push( {
1182
+ $match: {
1183
+ storeId: { $in: req.body.storeIdFilter },
1184
+ },
1185
+ } );
1186
+ }
1187
+ if ( req.body.statusFilter && req.body.statusFilter.length > 0 ) {
1188
+ query.push( {
1189
+ $match: {
1190
+ status: { $in: req.body.statusFilter },
1191
+ },
1192
+ } );
1193
+ }
1194
+ if ( req.body.userFilter && req.body.userFilter.length > 0 ) {
1195
+ query.push( {
1196
+ $match: {
1197
+ userEmail: { $in: req.body.userFilter },
1198
+ },
1199
+ } );
1200
+ }
1201
+
1202
+ if ( req.body.filterIssue && req.body.filterIssue != '' && req.body.filterIssue != 'total' ) {
1203
+ query.push( {
1204
+ $match: {
1205
+ primaryIssue: req.body.filterIssue,
1206
+ },
1207
+ } );
1208
+ }
1209
+ if ( req.body.searchValue && req.body.searchValue != '' ) {
1210
+ query.push( {
1211
+ $match: {
1212
+ $or: [
1213
+ { storeId: { $regex: req.body.searchValue, $options: 'i' } },
1214
+ { storeName: { $regex: req.body.searchValue, $options: 'i' } },
1215
+ ],
1216
+ },
1217
+ } );
1218
+ }
1219
+ let count = await aggregateTangoTicket( query );
1220
+ if ( req.body.limit && req.body.offset && !req.body.export ) {
1221
+ query.push(
1222
+ { $skip: ( req.body.offset - 1 ) * req.body.limit },
1223
+ { $limit: Number( req.body.limit ) },
1224
+ );
1225
+ }
1226
+ let result = await aggregateTangoTicket( query );
1227
+
1228
+ if ( req.body.export && result.length > 0 ) {
1229
+ const exportdata = [];
1230
+ result.forEach( ( element ) => {
1231
+ exportdata.push( {
1232
+ 'ticketId': element.ticketId,
1233
+ 'issueDate': dayjs( element.issueDate ).format( 'DD-MM-YYYY' ),
1234
+ 'storeId': element.storeId,
1235
+ 'storeName': element.storeName,
1236
+ 'clientId': element.clientId,
1237
+ 'clientName': element.clientName,
1238
+ 'userName': element.userName,
1239
+ 'userEmail': element.userEmail,
1240
+ 'Status': element.installationStatus,
1241
+ } );
1242
+ } );
1243
+ await download( exportdata, res );
1244
+ return;
1245
+ }
1246
+ if ( result.length > 0 ) {
1247
+ res.sendSuccess( {
1248
+ count: count.length,
1249
+ result: result,
1250
+ } );
1251
+ } else {
1252
+ res.sendError( 'no data', 204 );
1253
+ }
1254
+ } catch ( error ) {
1255
+ logger.error( { error: error, function: 'installationTable' } );
1256
+ return res.sendError( error, 500 );
1257
+ }
1258
+ }
1259
+ export async function assignTicket( req, res ) {
1260
+ try {
1261
+ let tickets = await updateManyTangoTicket( { ticketId: { $in: req.body.tickets } }, { 'ticketDetails.assigntoUser': true, 'ticketDetails.addressingUser': req.body.user } );
1262
+ if ( tickets ) {
1263
+ res.sendSuccess( 'Ticket Assigned Successfully' );
1264
+ }
1265
+ } catch ( error ) {
1266
+ logger.error( { error: error, function: 'assignTicket' } );
1267
+ return res.sendError( error, 500 );
1268
+ }
1269
+ }
1270
+ export async function storeFilter( req, res ) {
1271
+ try {
1272
+ let stores = await findTangoTicket( { 'issueType': req.body.issueType, 'basicDetails.clientId': req.body.clientId, 'basicDetails.storeId': { $exists: true } }, { 'basicDetails.storeId': 1 } );
1273
+ const uniqueStoreIds = [ ...new Set( stores.map( ( store ) => store.basicDetails.storeId ) ) ];
1274
+ const uniqueStoreObjects = uniqueStoreIds.map( ( storeId ) => ( { 'storeId': storeId } ) );
1275
+
1276
+ if ( uniqueStoreObjects.length>0 ) {
1277
+ res.sendSuccess( { count: uniqueStoreObjects.length, data: uniqueStoreObjects } );
1278
+ } else {
1279
+ res.sendError( 'No data', 204 );
1280
+ }
1281
+ } catch ( error ) {
1282
+ // console.log( error );
1283
+ logger.error( { error: error, function: 'storeFilter' } );
1284
+ return res.sendError( error, 500 );
1285
+ }
1286
+ }
@@ -17,7 +17,7 @@ import { findOneGroup } from '../services/group.service.js';
17
17
  import { findinfraReason } from '../services/infraReason.service.js';
18
18
  import { findOneUser } from '../services/user.service.js';
19
19
  import xl from 'excel4node';
20
-
20
+ import { findOneinfraReason } from '../services/infraReason.service.js';
21
21
  export async function migrateClient() {
22
22
  try {
23
23
  let oldclient = [];
@@ -123,7 +123,7 @@ export async function downStoresList( req, res ) {
123
123
  }
124
124
  export async function openTicketList( req, res ) {
125
125
  try {
126
- let openTicketList = await findTangoTicket( { status: { $ne: 'closed' } }, { ticketId: 1, basicDetails: 1, createdAt: 1, updateAt: 1, ticketDetails: 1 } );
126
+ let openTicketList = await findTangoTicket( { 'issueType': 'infra', 'status': { $ne: 'closed' } }, { issueType: 1, ticketId: 1, basicDetails: 1, createdAt: 1, updateAt: 1, ticketDetails: 1 } );
127
127
  if ( openTicketList.length ) {
128
128
  res.sendSuccess( {
129
129
  count: openTicketList.length,
@@ -446,11 +446,11 @@ export async function emailUserList( req, res ) {
446
446
  export async function infraReportSent( req, res ) {
447
447
  try {
448
448
  let date;
449
- if ( req.body.type == 'start' ) {
450
- date = dayjs().subtract( 1, 'day' ).format( 'YYYY-MM-DD' );
451
- } else if ( req.body.type == 'end' ) {
452
- date = dayjs().format( 'YYYY-MM-DD' );
453
- };
449
+ // if ( req.body.type == 'start' ) {
450
+ // date = dayjs().subtract( 1, 'day' ).format( 'YYYY-MM-DD' );
451
+ // } else if ( req.body.type == 'end' ) {
452
+ date = dayjs().format( 'YYYY-MM-DD' );
453
+ // };
454
454
  let query = [ {
455
455
  $match: {
456
456
  $and: [
@@ -697,14 +697,14 @@ export async function camAngleChangeReport( req, res ) {
697
697
  content: buffer,
698
698
  contentType: 'application/xlsx', // e.g., 'application/pdf'
699
699
  };
700
- let subject =`Camera Angle Modified - ${formattedPreviousDay}`;
700
+ let subject = `Camera Angle Modified - ${formattedPreviousDay}`;
701
701
  let html = `<div>We wanted to inform you that the camera angle in your stores has been adjusted recently.</div>`;
702
702
  let result = await sendEmailWithSES( req.body.toMail, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
703
703
  if ( result ) {
704
704
  res.sendSuccess( 'Email send successfully' );
705
705
  }
706
706
  } else {
707
- res.sendSuccess( 'No changes' );
707
+ res.sendSuccess( 'No changes in camera Angle' );
708
708
  }
709
709
  } catch ( error ) {
710
710
  logger.error( { error: error, function: 'camAngleChangeList' } );
@@ -737,3 +737,329 @@ export async function download( data ) {
737
737
  }
738
738
  return await wb.writeToBuffer();
739
739
  }
740
+ export async function edgeApplogsCheck( req, res ) {
741
+ try {
742
+ let finalresult= [];
743
+ let ticketList = await findTangoTicket( { 'issueDate': new Date( req.body.issueDate ), 'status': { $ne: 'closed' }, 'ticketDetails.issueStatus': 'notidentified', 'issueType': 'infra' } );
744
+ for ( let ticket of ticketList ) {
745
+ req.body.date = dayjs( ticket.createdAt ).format( 'YYYY-MM-DD' );
746
+ let errorLog = {
747
+ 'size': 500,
748
+ 'query': {
749
+ 'bool': {
750
+ 'must': [
751
+ {
752
+ 'range': {
753
+ 'log_code': {
754
+ 'gte': 1000,
755
+ },
756
+ },
757
+ },
758
+ {
759
+ 'term': {
760
+ 'store_date.keyword': dayjs( ticket.createdAt ).format( 'DD-MM-YYYY' ),
761
+ },
762
+ },
763
+ {
764
+ 'term': {
765
+ 'storeId.keyword': ticket.basicDetails.storeId,
766
+ },
767
+ },
768
+
769
+ ],
770
+
771
+ },
772
+ },
773
+ 'sort': [
774
+ { 'timestamp': { 'order': 'desc' } },
775
+ ],
776
+ };
777
+ const errorLogList = await getOpenSearchData( 'edgeapp_systemlogs', errorLog );
778
+
779
+ let result = [];
780
+
781
+ for ( let error of errorLogList.body.hits.hits ) {
782
+ if ( error._source.log_code == '1003' ) {
783
+ let logCheck = {
784
+ code: error._source.log_code,
785
+ edgelog: error._source.data,
786
+ };
787
+ result.push( logCheck );
788
+ }
789
+ // if ( error._source.log_code == '1001' ) {
790
+ // let logCheck = {
791
+ // code: error._source.log_code,
792
+ // edgelog: error._source.data,
793
+ // };
794
+ // result.push( logCheck );
795
+ // }
796
+
797
+ // if ( error._source.log_code == '1004' ) {
798
+ // let logCheck = {
799
+ // code: error._source.log_code,
800
+ // edgelog: error._source.data,
801
+
802
+ // };
803
+ // result.push( logCheck );
804
+ // }
805
+ if ( error._source.log_code == '1005' ) {
806
+ const bytes = error._source.data.upload_Speed.split( '.' )[0];
807
+ const megabytes = bytesToMB( bytes );
808
+ if ( megabytes < 2 ) {
809
+ let logCheck = {
810
+ code: error._source.log_code,
811
+ edgelog: error._source.data,
812
+
813
+ };
814
+ result.push( logCheck );
815
+ }
816
+ }
817
+
818
+
819
+ if ( error._source.log_code == '1011' ) {
820
+ let logCheck = {
821
+ code: error._source.log_code,
822
+ edgelog: error._source.data,
823
+
824
+ };
825
+ result.push( logCheck );
826
+ }
827
+ if ( error._source.log_code == '1022' ) {
828
+ let logCheck = {
829
+ code: error._source.log_code,
830
+ edgelog: error._source.data,
831
+
832
+ };
833
+ result.push( logCheck );
834
+ }
835
+ if ( error._source.log_code == '1024' ) {
836
+ let logCheck = {
837
+ code: error._source.log_code,
838
+ edgelog: error._source.data,
839
+
840
+ };
841
+ result.push( logCheck );
842
+ }
843
+ if ( error._source.log_code == '1025' ) {
844
+ let logCheck = {
845
+ code: error._source.log_code,
846
+ edgelog: error._source.data,
847
+
848
+ };
849
+ result.push( logCheck );
850
+ }
851
+
852
+ if ( error._source.log_code == '1000' ) {
853
+ let logCheck = {
854
+ code: error._source.log_code,
855
+ edgelog: error._source.data,
856
+
857
+ };
858
+ result.push( logCheck );
859
+ }
860
+
861
+ if ( error._source.log_code == '1007' ) {
862
+ let logCheck = {
863
+ code: error._source.log_code,
864
+ edgelog: error._source.data,
865
+
866
+ };
867
+ result.push( logCheck );
868
+ }
869
+ if ( error._source.log_code == '1034' ) {
870
+ let logCheck = {
871
+ code: error._source.log_code,
872
+ edgelog: error._source.data,
873
+
874
+ };
875
+ result.push( logCheck );
876
+ }
877
+
878
+ if ( Number( error._source.log_code ) > 2000 ) {
879
+ let logCheck = {
880
+ code: error._source.log_code,
881
+ edgelog: error._source.data,
882
+ };
883
+ result.push( logCheck );
884
+ }
885
+ }
886
+ let findissueEdgeApp = {};
887
+ if ( result.length>0 ) {
888
+ for ( let findissue of result ) {
889
+ // console.log( ticket.ticketId );
890
+ const istTimestamp = dayjs.utc( ticket.createdAt ).tz( 'Asia/Kolkata' ).format( 'HH:mm:ss' );
891
+
892
+ if ( findissue.code == '1003' ) {
893
+ // Compare the times
894
+ const occurringTimeParsed = dayjs( `${req.body.date} ${findissue.edgelog.occuringTime}` );
895
+ const ticketCreatedParsed = dayjs( `${req.body.date} ${istTimestamp}` );
896
+ const isOccurringTimeEarlier = occurringTimeParsed.isBefore( ticketCreatedParsed );
897
+ if ( isOccurringTimeEarlier ) {
898
+ findissueEdgeApp = {
899
+ ticketId: ticket.ticketId,
900
+ edgelog: findissue,
901
+ storeId: ticket.basicDetails.storeId,
902
+ primary: 'System Issues',
903
+ secondary: [ 'Malware or Viruses' ],
904
+ };
905
+ updateIssue( findissueEdgeApp );
906
+ finalresult.push( findissueEdgeApp );
907
+ // console.log( findissueEdgeApp );
908
+ }
909
+ } else if ( findissue.code == '1024' ) {
910
+ const occurringTimeParsed = dayjs( `${req.body.date} ${findissue.edgelog.data.occuringTime}` );
911
+ const ticketCreatedParsed = dayjs( `${req.body.date} ${istTimestamp}` );
912
+ const isOccurringTimeEarlier = occurringTimeParsed.isBefore( ticketCreatedParsed );
913
+
914
+ const existsInArray = finalresult.some( ( item ) =>
915
+ item.ticketId === ticket.ticketId,
916
+ );
917
+ if ( isOccurringTimeEarlier&&!existsInArray ) {
918
+ findissueEdgeApp = {
919
+ ticketId: ticket.ticketId,
920
+ storeId: ticket.basicDetails.storeId,
921
+ edgelog: findissue.edgelog.data,
922
+ primary: 'Camera Issues',
923
+ secondary: [ 'Camera Not working/RTSP port not working' ],
924
+ };
925
+ updateIssue( findissueEdgeApp );
926
+ finalresult.push( findissueEdgeApp );
927
+ }
928
+ } else if ( findissue.code == '1011' ) {
929
+ const occurringTimeParsed = dayjs( `${req.body.date} ${findissue.edgelog.occuringTime}` );
930
+ const ticketCreatedParsed = dayjs( `${req.body.date} ${istTimestamp}` );
931
+ const isOccurringTimeEarlier = occurringTimeParsed.isBefore( ticketCreatedParsed );
932
+
933
+ if ( isOccurringTimeEarlier ) {
934
+ findissueEdgeApp = {
935
+ ticketId: ticket.ticketId,
936
+ edgelog: findissue,
937
+ storeId: ticket.basicDetails.storeId,
938
+ primary: 'System Issues',
939
+ secondary: [ 'System is in Sleep Mode' ],
940
+ };
941
+ updateIssue( findissueEdgeApp );
942
+ finalresult.push( findissueEdgeApp );
943
+ // console.log( findissueEdgeApp );
944
+ }
945
+ } else if ( findissue.code ==='1005' ) {
946
+ const occurringTimeParsed = dayjs( `${req.body.date} ${findissue.edgelog.occuringTime}` );
947
+ const ticketCreatedParsed = dayjs( `${req.body.date} ${istTimestamp}` );
948
+ const isOccurringTimeEarlier = occurringTimeParsed.isBefore( ticketCreatedParsed );
949
+ if ( isOccurringTimeEarlier ) {
950
+ findissueEdgeApp = {
951
+ ticketId: ticket.ticketId,
952
+ edgelog: findissue,
953
+ storeId: ticket.basicDetails.storeId,
954
+ primary: 'Internet Issues',
955
+ secondary: [ 'Slow Internet Speed' ],
956
+ };
957
+ updateIssue( findissueEdgeApp );
958
+ finalresult.push( findissueEdgeApp );
959
+ // console.log( findissueEdgeApp );
960
+ }
961
+ }
962
+ }
963
+ }
964
+ }
965
+ res.sendSuccess( { count: finalresult.length, result: finalresult } );
966
+ } catch ( error ) {
967
+ logger.error( { error: error, function: 'camAngleChangeList' } );
968
+ res.sendError( error, 500 );
969
+ }
970
+ }
971
+ function bytesToMB( bytes ) {
972
+ return bytes / ( 1024 * 1024 );
973
+ }
974
+
975
+ export async function updateIssue( data ) {
976
+ try {
977
+ let Ticket = await findOneTangoTicket(
978
+ {
979
+ ticketId: data.ticketId,
980
+ },
981
+ );
982
+
983
+ data.issueType = Ticket.issueType;
984
+ data.basicDetails = Ticket.basicDetails;
985
+ data.ticketDetails = Ticket.ticketDetails;
986
+ data.ticketActivity = Ticket.ticketActivity;
987
+ if ( data.primary && data.secondary && data.secondary.length ) {
988
+ let primaryReason = await findOneinfraReason( { name: data.primary } );
989
+ if ( !primaryReason ) {
990
+ return res.sendError( 'Primary Reason Not exists in database', 500 );
991
+ }
992
+ const secondary = [];
993
+ const steptoReslove = [];
994
+ for ( let i = 0; i < data.secondary.length; i++ ) {
995
+ let secondaryReason = await findOneinfraReason( { name: data.secondary[i] } );
996
+ if ( !secondaryReason ) {
997
+ return res.sendError( `secondary Reason - ${data.secondary[i]} Not exists in database`, 500 );
998
+ }
999
+ secondary.push( {
1000
+ name: secondaryReason.name,
1001
+ } );
1002
+ let resolveSteps = [];
1003
+ for ( let i = 0; i < secondaryReason.stepstoResolve.length; i++ ) {
1004
+ resolveSteps.push( {
1005
+ name: secondaryReason.stepstoResolve[i].name,
1006
+ } );
1007
+ }
1008
+ steptoReslove.push( {
1009
+ primaryIssue: secondaryReason.name,
1010
+ secondaryIsssue: [ ...resolveSteps ],
1011
+ } );
1012
+ }
1013
+
1014
+ data.ticketActivity.push( {
1015
+ actionType: 'issueUpdate',
1016
+ actionBy: 'automated',
1017
+ IdentifiedBy: 'Tango',
1018
+ timeStamp: new Date(),
1019
+ reasons: [ {
1020
+ primaryIssue: primaryReason.name,
1021
+ secondaryIssue: secondary,
1022
+ } ],
1023
+ },
1024
+ );
1025
+ } else {
1026
+ if ( data.primary == 'Application Issues' ) {
1027
+ data.ticketActivity.push( {
1028
+ actionType: 'issueUpdate',
1029
+ actionBy: 'automated',
1030
+ timeStamp: new Date(),
1031
+ IdentifiedBy: 'Tango',
1032
+ reasons: [ {
1033
+ primaryIssue: data.primary,
1034
+ secondaryIssue: [],
1035
+ } ],
1036
+ },
1037
+ );
1038
+ }
1039
+ }
1040
+ if ( data.issueType == 'infra' ) {
1041
+ let client = await findOneClient( { clientId: data.basicDetails.clientId }, { ticketConfigs: 1 } );
1042
+ let statusCheckAlertTime = dayjs().add( client.ticketConfigs.statusCheckAlert, 'hours' ).format( 'YYYY-MM-DD hh:mm' );
1043
+ data.ticketActivity.push( {
1044
+ actionType: 'statusCheck',
1045
+ timeStamp: statusCheckAlertTime,
1046
+ actionBy: 'Tango',
1047
+ IdentifiedBy: 'Tango',
1048
+ timeStamp: new Date(),
1049
+ statusCheckAlertTime: statusCheckAlertTime,
1050
+ } );
1051
+ }
1052
+ let query = {
1053
+ 'ticketActivity': data.ticketActivity,
1054
+ 'ticketDetails.issueIdentifiedDate': new Date(),
1055
+ 'ticketDetails.issueStatus': 'identified',
1056
+ 'status': 'inprogress',
1057
+ };
1058
+ await updateOneTangoTicket( { ticketId: data.ticketId }, query );
1059
+ // console.log( data );
1060
+ } catch ( error ) {
1061
+ logger.error( { error: error, function: 'updateAutomaticIssue' } );
1062
+ res.sendError( error, 500 );
1063
+ }
1064
+ }
1065
+
@@ -330,6 +330,7 @@ export async function edgeAppLogTable( req, res ) {
330
330
  };
331
331
  const downtime = await getOpenSearchData( 'live_downtime_hourly', downTimeQuery );
332
332
  let streamwiseDowntime = downtime.body.hits.hits.length > 0 ? downtime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
333
+ // console.log( obj.hour, streamwiseDowntime );
333
334
  if ( streamwiseDowntime.length > 0 ) {
334
335
  const sum = streamwiseDowntime.reduce( ( accumulator, currentValue ) => {
335
336
  return accumulator + currentValue.down_time;
@@ -337,7 +338,7 @@ export async function edgeAppLogTable( req, res ) {
337
338
  const average = sum / streamwiseDowntime.length;
338
339
  obj.downtime = Math.round( average );
339
340
  } else {
340
- obj.downtime = 0;
341
+ obj.downtime ='';
341
342
  }
342
343
  let appStatusQuery = {
343
344
  'size': 1,
@@ -71,6 +71,15 @@ export async function userTakeTicket( req, res ) {
71
71
  }
72
72
  userTicket = await findOneTangoTicket( query );
73
73
  }
74
+ } else if ( req.body.issueType == 'mat' ) {
75
+ let query = {
76
+ 'status': { $ne: 'closed' },
77
+ 'issueType': 'mat',
78
+ };
79
+ if ( assignedClients.length > 0 ) {
80
+ query =( { ...query, ...{ 'basicDetails.clientId': { $in: assignedClients } } } );
81
+ }
82
+ userTicket = await findOneTangoTicket( query );
74
83
  }
75
84
  if ( userTicket ) {
76
85
  let assignTicket = await updateOneTangoTicket( { ticketId: userTicket.ticketId }, { 'ticketDetails.addressingUser': req.body.userId } );
@@ -202,6 +211,7 @@ export async function userTicketList( req, res ) {
202
211
  } );
203
212
  }
204
213
  let ticketList = await aggregateTangoTicket( query );
214
+ console.log( ticketList );
205
215
  if ( req.body.export ) {
206
216
  const exportdata = [];
207
217
  ticketList.forEach( ( element ) => {
@@ -437,16 +447,16 @@ export async function workHistory( req, res ) {
437
447
  const exportdata = [];
438
448
  result.forEach( ( element ) => {
439
449
  exportdata.push( {
440
- 'CREATED ON': element.createdAt,
450
+ 'CREATED ON': dayjs( element.issueDate ).format( 'DD-MM-YYYY' ),
441
451
  'TICKET ID': element.ticketId,
442
452
  'STORE ID': element.storeId,
443
453
  'STORE NAME': element.storeName,
444
454
  'CLIENT ID': element.clientId,
445
455
  'CLIENT NAME': element.clientName,
446
- 'CREATED STATUS': element.status,
447
456
  'ISSUE IDENTIFIED DATE': element.issueIdentifiedDate,
448
457
  'CLOSED ON': element.issueClosedDate,
449
- 'STATUS': element.status,
458
+ 'ISSUE': element.infraIssue?element.infraIssue:'-',
459
+
450
460
  } );
451
461
  } );
452
462
  await download( exportdata, res );
@@ -591,7 +601,7 @@ export async function storeInfraList( req, res ) {
591
601
  if ( installationcheck ) {
592
602
  store.ticketId = installationcheck.ticketId;
593
603
  store.status = installationcheck.ticketDetails.installationStatus;
594
- if ( store.status === 'onboareded' ) {
604
+ if ( store.status === 'onboarded' ) {
595
605
  store.statusDetail = 'Ready to pair';
596
606
  }
597
607
  if ( store.status === 'paired' ) {
@@ -0,0 +1,17 @@
1
+ import { createTicket, updatecomment, activityLog } from '../controllers/employeeTraning.controller.js';
2
+ import { ticketExists, validateDetails } from '../validations/infra.validation.js';
3
+ import express from 'express';
4
+ import { isAllowedSessionHandler, authorize } from 'tango-app-api-middleware';
5
+ export const employeeTrainigRouter = express.Router();
6
+
7
+
8
+ employeeTrainigRouter.post( '/createTicket', validateDetails, createTicket );
9
+ employeeTrainigRouter.post( '/updatecomment', isAllowedSessionHandler, authorize( {
10
+ userType: [ 'tango' ], access: [
11
+ { featureName: 'manage', name: 'tickets', permissions: [ 'isEdit' ] } ],
12
+ } ), ticketExists, updatecomment );
13
+
14
+ employeeTrainigRouter.post( '/activityLog', isAllowedSessionHandler, authorize( {
15
+ userType: [ 'tango' ], access: [
16
+ { featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
17
+ } ), ticketExists, activityLog );
@@ -2,9 +2,9 @@
2
2
  import express from 'express';
3
3
  import { isAllowedSessionHandler, authorize } from 'tango-app-api-middleware';
4
4
  import { validateDetails, bulkvalidateDetails, validateTicket, bulkvalidateTicket, ticketExists, infraReasonExists, InfrastepstoResolve, InfraAlert } from '../validations/infra.validation.js';
5
- import { createTicket, bulkcreateTicket, updateStatus, createReason, PrimaryReasons,
5
+ import { createTicket, bulkcreateTicket, updateStatus, createReason, PrimaryReasons, matTable,
6
6
  secondaryReason, updateTicketIssue, viewTicket, AlertTicketReply, uploadAttachments,
7
- updateInstallationTicket, emailUserList, saveInfraEmailConfig, invoice } from '../controllers/infra.controllers.js';
7
+ updateInstallationTicket, emailUserList, saveInfraEmailConfig, invoice, infraTable, storeFilter, assignTicket, installationTable } from '../controllers/infra.controllers.js';
8
8
 
9
9
 
10
10
  export const infraRouter = express.Router();
@@ -55,3 +55,23 @@ infraRouter.post( '/saveInfraEmailConfig', isAllowedSessionHandler, authorize( {
55
55
  { featureName: 'settings', name: 'configuration', permissions: [ 'isEdit', 'isView' ] } ],
56
56
  } ), saveInfraEmailConfig );
57
57
  infraRouter.post( '/invoice', invoice );
58
+ infraRouter.post( '/infraTable', isAllowedSessionHandler, authorize( {
59
+ userType: [ 'client', 'tango' ], access: [
60
+ { featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
61
+ } ), infraTable );
62
+ infraRouter.post( '/installationTable', isAllowedSessionHandler, authorize( {
63
+ userType: [ 'client', 'tango' ], access: [
64
+ { featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
65
+ } ), installationTable );
66
+ infraRouter.post( '/matTable', isAllowedSessionHandler, authorize( {
67
+ userType: [ 'client', 'tango' ], access: [
68
+ { featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
69
+ } ), matTable );
70
+ infraRouter.post( '/assignTicket', isAllowedSessionHandler, authorize( {
71
+ userType: [ 'client', 'tango' ], access: [
72
+ { featureName: 'manage', name: 'tickets', permissions: [ 'isEdit', 'isView' ] } ],
73
+ } ), assignTicket );
74
+ infraRouter.post( '/storeFilter', isAllowedSessionHandler, authorize( {
75
+ userType: [ 'client', 'tango' ], access: [
76
+ { featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
77
+ } ), storeFilter );
@@ -2,7 +2,7 @@
2
2
  import express from 'express';
3
3
  import {
4
4
  migrateClient, migrateStores, basicList, clientList, setTicketTime, downStoresList,
5
- openTicketList, assigntoUser, updateRefreshTicket, closeTicket, camAngleChangeReport, spocmailchange, emailUserList, infraReportSent,
5
+ openTicketList, assigntoUser, updateRefreshTicket, closeTicket, edgeApplogsCheck, camAngleChangeReport, spocmailchange, emailUserList, infraReportSent,
6
6
  } from '../controllers/internalInfra.controller.js';
7
7
 
8
8
  export const internalInfraRouter = express.Router();
@@ -21,5 +21,6 @@ internalInfraRouter.get( '/emailUserList', emailUserList );
21
21
  internalInfraRouter.post( '/infraReportSent', infraReportSent );
22
22
  internalInfraRouter.post( '/spocmailchange', spocmailchange );
23
23
  internalInfraRouter.post( '/camAngleChangeReport', camAngleChangeReport );
24
+ internalInfraRouter.post( '/edgeApplogsCheck', edgeApplogsCheck );
24
25
 
25
26
 
@@ -13,6 +13,9 @@ export async function findOneTangoTicket( query, project ) {
13
13
  export async function updateOneTangoTicket( query, data ) {
14
14
  return await dataModel.tangoTicketModel.updateOne( query, { $set: data } );
15
15
  }
16
+ export async function updateManyTangoTicket( query, data ) {
17
+ return await dataModel.tangoTicketModel.updateMany( query, { $set: data } );
18
+ }
16
19
  export async function countDocumentsTangoTicket( query, data ) {
17
20
  return await dataModel.tangoTicketModel.countDocuments( query );
18
21
  }
@@ -325,7 +325,6 @@ export async function InfraAlert( req, res, next ) {
325
325
  await updateOneStore( { storeId: req.body.basicDetails.storeId }, { 'ticketConfigs.hibernation': new Date( req.body.hibernationDays ) } );
326
326
 
327
327
  await updateOneTangoTicket( { ticketId: req.body.ticketId }, { 'hibernation': new Date( req.body.hibernationDays ) } );
328
- console.log( req.body.ticketActivity );
329
328
  } else {
330
329
  if ( req.body.issueType == 'infra' ) {
331
330
  let client = await findOneClient( { clientId: req.body.basicDetails.clientId }, { ticketConfigs: 1 } );