tango-app-api-infra 3.0.57-dev → 3.0.59-dev

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.0.57-dev",
3
+ "version": "3.0.59-dev",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -24,7 +24,7 @@
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",
27
+ "tango-api-schema": "^2.0.93",
28
28
  "tango-app-api-middleware": "^1.0.60-dev",
29
29
  "winston": "^3.12.0",
30
30
  "winston-daily-rotate-file": "^5.0.0"
@@ -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
+ }
@@ -3,7 +3,7 @@
3
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, getUTC } 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';
@@ -825,7 +825,17 @@ export async function infraTable( req, res ) {
825
825
  const exportdata = [];
826
826
  result.forEach( ( element ) => {
827
827
  exportdata.push( {
828
-
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,
829
839
  } );
830
840
  } );
831
841
  await download( exportdata, res );
@@ -911,7 +921,7 @@ export async function installationTable( req, res ) {
911
921
  createdAt: 1,
912
922
  ticketId: 1,
913
923
  addressingUser: 1,
914
- installationStatus: 1,
924
+ installationStatus: { $ifNull: [ '$installationStatus', '-' ] },
915
925
  issueDate: { $ifNull: [ '$issueDate', '' ] },
916
926
  status: 1,
917
927
  primaryIssue: { $ifNull: [ '$primaryIssue.reasons.primaryIssue', '-' ] },
@@ -1051,7 +1061,17 @@ export async function installationTable( req, res ) {
1051
1061
  const exportdata = [];
1052
1062
  result.forEach( ( element ) => {
1053
1063
  exportdata.push( {
1054
-
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,
1055
1075
  } );
1056
1076
  } );
1057
1077
  await download( exportdata, res );
@@ -1071,6 +1091,171 @@ export async function installationTable( req, res ) {
1071
1091
  return res.sendError( error, 500 );
1072
1092
  }
1073
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
+ }
1074
1259
  export async function assignTicket( req, res ) {
1075
1260
  try {
1076
1261
  let tickets = await updateManyTangoTicket( { ticketId: { $in: req.body.tickets } }, { 'ticketDetails.assigntoUser': true, 'ticketDetails.addressingUser': req.body.user } );
@@ -1084,16 +1269,17 @@ export async function assignTicket( req, res ) {
1084
1269
  }
1085
1270
  export async function storeFilter( req, res ) {
1086
1271
  try {
1087
- let stores = await findTangoTicket( { 'issueType': req.body.issueType, 'basicDetails.storeId': { $exists: true } }, { 'basicDetails.storeId': 1 } );
1272
+ let stores = await findTangoTicket( { 'issueType': req.body.issueType, 'basicDetails.clientId': req.body.clientId, 'basicDetails.storeId': { $exists: true } }, { 'basicDetails.storeId': 1 } );
1088
1273
  const uniqueStoreIds = [ ...new Set( stores.map( ( store ) => store.basicDetails.storeId ) ) ];
1089
1274
  const uniqueStoreObjects = uniqueStoreIds.map( ( storeId ) => ( { 'storeId': storeId } ) );
1090
1275
 
1091
1276
  if ( uniqueStoreObjects.length>0 ) {
1092
1277
  res.sendSuccess( { count: uniqueStoreObjects.length, data: uniqueStoreObjects } );
1093
1278
  } else {
1094
- res.sendError( 'No data' );
1279
+ res.sendError( 'No data', 204 );
1095
1280
  }
1096
1281
  } catch ( error ) {
1282
+ // console.log( error );
1097
1283
  logger.error( { error: error, function: 'storeFilter' } );
1098
1284
  return res.sendError( error, 500 );
1099
1285
  }
@@ -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,7 +697,7 @@ 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 ) {
@@ -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;
@@ -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,7 +2,7 @@
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
7
  updateInstallationTicket, emailUserList, saveInfraEmailConfig, invoice, infraTable, storeFilter, assignTicket, installationTable } from '../controllers/infra.controllers.js';
8
8
 
@@ -63,11 +63,15 @@ infraRouter.post( '/installationTable', isAllowedSessionHandler, authorize( {
63
63
  userType: [ 'client', 'tango' ], access: [
64
64
  { featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
65
65
  } ), installationTable );
66
+ infraRouter.post( '/matTable', isAllowedSessionHandler, authorize( {
67
+ userType: [ 'client', 'tango' ], access: [
68
+ { featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
69
+ } ), matTable );
66
70
  infraRouter.post( '/assignTicket', isAllowedSessionHandler, authorize( {
67
71
  userType: [ 'client', 'tango' ], access: [
68
72
  { featureName: 'manage', name: 'tickets', permissions: [ 'isEdit', 'isView' ] } ],
69
73
  } ), assignTicket );
70
74
  infraRouter.post( '/storeFilter', isAllowedSessionHandler, authorize( {
71
- userType: [ 'tango' ], access: [
75
+ userType: [ 'client', 'tango' ], access: [
72
76
  { featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
73
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