tango-app-api-infra 3.1.34-beta.0 → 3.1.34-beta.2

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.0",
3
+ "version": "3.1.34-beta.2",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -82,6 +82,9 @@ export async function infraCard( req, res ) {
82
82
  identifiedcount: {
83
83
  $cond: [ { $eq: [ '$ticketDetails.issueStatus', 'identified' ] }, 1, 0 ],
84
84
  },
85
+ notidentifiedcount: {
86
+ $cond: [ { $eq: [ '$ticketDetails.issueStatus', 'notidentified' ] }, 1, 0 ],
87
+ },
85
88
  },
86
89
  },
87
90
  {
@@ -89,6 +92,8 @@ export async function infraCard( req, res ) {
89
92
  _id: '$storeId',
90
93
  infraCount: { $sum: 1 },
91
94
  identifiedcount: { $sum: '$identifiedcount' },
95
+ notidentifiedcount: { $sum: '$notidentifiedcount' },
96
+
92
97
  },
93
98
  },
94
99
  {
@@ -96,6 +101,8 @@ export async function infraCard( req, res ) {
96
101
  _id: null,
97
102
  infraCount: { $sum: '$infraCount' },
98
103
  identifiedcount: { $sum: '$identifiedcount' },
104
+ notidentifiedcount: { $sum: '$notidentifiedcount' },
105
+
99
106
  },
100
107
  },
101
108
  ] );
@@ -190,22 +197,22 @@ export async function infraCard( req, res ) {
190
197
 
191
198
  response.unshift( {
192
199
  name: 'Identified Issues',
193
- count: infraStoreCount.length > 0 ? infraStoreCount[0].identifiedcount : 0,
200
+ count: ticketList.length,
194
201
  } );
195
202
  response.unshift( {
196
203
  name: 'All Issues',
197
- count: infraStoreCount.length > 0 ? infraStoreCount[0].infraCount : 0,
204
+ count: infraStoreCount.length > 0 ? infraStoreCount[0].notidentifiedcount+ticketList.length: 0,
198
205
  } );
199
206
  response.push( {
200
207
  name: 'Issues Not Identified',
201
- count: infraStoreCount.length > 0 ? infraStoreCount[0].infraCount - infraStoreCount[0].identifiedcount : 0,
208
+ count: infraStoreCount.length > 0 ? infraStoreCount[0].notidentifiedcount : 0,
202
209
  } );
203
210
  res.sendSuccess( {
204
211
  total: storeCount,
205
212
  liveStoreCount: infraStoreCount.length > 0 ? storeCount - infraStoreCount[0].infraCount : storeCount,
206
- infraStoreCount: infraStoreCount.length > 0 ? infraStoreCount[0].infraCount : 0,
207
- identifiedcount: infraStoreCount.length > 0 ? infraStoreCount[0].identifiedcount : 0,
208
- notidentifiedcount: infraStoreCount.length > 0 ? infraStoreCount[0].infraCount - infraStoreCount[0].identifiedcount : 0,
213
+ infraStoreCount: infraStoreCount.length > 0 ? infraStoreCount[0].notidentifiedcount+ticketList.length : 0,
214
+ identifiedcount: infraStoreCount.length > 0 ? ticketList.length : 0,
215
+ notidentifiedcount: infraStoreCount.length > 0 ? infraStoreCount[0].notidentifiedcount : 0,
209
216
  infraIssues: response,
210
217
  } );
211
218
  } catch ( error ) {
@@ -457,7 +464,7 @@ export async function infraIssuesTable( req, res ) {
457
464
  createdAt: 1,
458
465
  ticketId: 1,
459
466
  clientName: 1,
460
- actionBy: '$primaryIssue.actionBy',
467
+ issueIdentifiedBy: { $ifNull: [ '$primaryIssue.actionBy', '' ] },
461
468
  issueIdentifiedDate: { $ifNull: [ '$issueIdentifiedDate', '' ] },
462
469
  issueClosedDate: { $ifNull: [ '$issueClosedDate', '' ] },
463
470
  status: 1,
@@ -471,7 +478,7 @@ export async function infraIssuesTable( req, res ) {
471
478
  storeId: { $first: '$storeId' },
472
479
  clientId: { $first: '$clientId' },
473
480
  ticketId: { $first: '$ticketId' },
474
- actionBy: { $first: '$actionBy' },
481
+ issueIdentifiedBy: { $first: '$issueIdentifiedBy' },
475
482
  storeName: { $first: '$storeName' },
476
483
  clientName: { $first: '$clientName' },
477
484
  createdAt: { $first: '$createdAt' },
@@ -563,15 +570,18 @@ export async function infraIssuesTable( req, res ) {
563
570
  storesQuery.push( searchCondition );
564
571
  }
565
572
 
573
+
566
574
  if ( req.body.filter && req.body.filter.length > 0 ) {
575
+ req.body.filter.push( '' );
567
576
  query.push(
568
577
  {
569
578
  $match: {
570
- actionBy: { $in: req.body.filter },
579
+ issueIdentifiedBy: { $in: req.body.filter },
571
580
  },
572
581
  },
573
582
  );
574
583
  }
584
+
575
585
  if ( req.body.sortColumName && req.body.sortColumName !== '' && req.body.sortBy ) {
576
586
  const sortOption = { $sort: { [req.body.sortColumName]: req.body.sortBy } };
577
587
  query.push( sortOption );
@@ -1208,7 +1218,7 @@ export async function hourWiseDownstores( req, res ) {
1208
1218
  createdAt: 1,
1209
1219
  ticketId: 1,
1210
1220
  clientName: 1,
1211
- actionBy: '$primaryIssue.actionBy',
1221
+ issueIdentifiedBy: { $ifNull: [ '$primaryIssue.actionBy', '' ] },
1212
1222
  issueIdentifiedDate: { $ifNull: [ '$issueIdentifiedDate', '' ] },
1213
1223
  issueClosedDate: { $ifNull: [ '$issueClosedDate', '' ] },
1214
1224
  status: 1,
@@ -1222,7 +1232,7 @@ export async function hourWiseDownstores( req, res ) {
1222
1232
  storeId: { $first: '$storeId' },
1223
1233
  clientId: { $first: '$clientId' },
1224
1234
  ticketId: { $first: '$ticketId' },
1225
- actionBy: { $first: '$actionBy' },
1235
+ issueIdentifiedBy: { $first: '$issueIdentifiedBy' },
1226
1236
  storeName: { $first: '$storeName' },
1227
1237
  clientName: { $first: '$clientName' },
1228
1238
  createdAt: { $first: '$createdAt' },
@@ -1314,10 +1324,11 @@ export async function hourWiseDownstores( req, res ) {
1314
1324
  }
1315
1325
 
1316
1326
  if ( req.body.filter && req.body.filter.length > 0 ) {
1327
+ req.body.filter.push( '' );
1317
1328
  query.push(
1318
1329
  {
1319
1330
  $match: {
1320
- actionBy: { $in: req.body.filter },
1331
+ issueIdentifiedBy: { $in: req.body.filter },
1321
1332
  },
1322
1333
  },
1323
1334
  );
@@ -1066,6 +1066,8 @@ export async function infraTable( req, res ) {
1066
1066
  storeName: '$basicDetails.storeName',
1067
1067
  clientName: '$basicDetails.clientName',
1068
1068
  ticketStatus: '$ticketDetails.issueStatus',
1069
+ ticketType: '$ticketDetails.ticketType',
1070
+ refreshTicketStatus: '$ticketDetails.refreshTicketStatus',
1069
1071
  status: 1,
1070
1072
  createdAt: 1,
1071
1073
  issueDate: 1,
@@ -1122,6 +1124,8 @@ export async function infraTable( req, res ) {
1122
1124
  createdAt: 1,
1123
1125
  addressingUser: 1,
1124
1126
  ticketStatus: 1,
1127
+ ticketType: 1,
1128
+ refreshTicketStatus: 1,
1125
1129
  ticketId: 1,
1126
1130
  issueDate: { $ifNull: [ '$issueDate', '' ] },
1127
1131
  status: 1,
@@ -1169,6 +1173,8 @@ export async function infraTable( req, res ) {
1169
1173
  ticketId: { $first: '$ticketId' },
1170
1174
  storeName: { $first: '$storeName' },
1171
1175
  ticketStatus: { $first: '$ticketStatus' },
1176
+ ticketType: { $first: '$ticketType' },
1177
+ refreshTicketStatus: { $first: '$refreshTicketStatus' },
1172
1178
  userName: { $first: { $ifNull: [ '$user.userName', '-' ] } },
1173
1179
  userEmail: { $first: { $ifNull: [ '$user.email', '-' ] } },
1174
1180
  clientName: { $first: '$clientName' },
@@ -1179,6 +1185,7 @@ export async function infraTable( req, res ) {
1179
1185
  otherscomment: { $last: '$otherscomment' },
1180
1186
  primaryIssue: { $last: '$primaryIssue' },
1181
1187
  secondaryIssue: { $last: '$secondaryIssue' },
1188
+
1182
1189
  },
1183
1190
  },
1184
1191
  {
@@ -1200,11 +1207,25 @@ export async function infraTable( req, res ) {
1200
1207
  } );
1201
1208
  }
1202
1209
  if ( req.body.statusFilter && req.body.statusFilter.length > 0 ) {
1203
- query.push( {
1204
- $match: {
1205
- status: { $in: req.body.statusFilter },
1206
- },
1207
- } );
1210
+ if ( req.body.statusFilter.includes( 'refreshticket' ) ) {
1211
+ req.body.statusFilter.push( 'inprogress' );
1212
+ query.push( {
1213
+ $match: {
1214
+ $and: [
1215
+ { status: { $in: req.body.statusFilter } },
1216
+ { ticketType: 'refreshticket' },
1217
+ { refreshTicketStatus: 'notidentified' },
1218
+ ],
1219
+
1220
+ },
1221
+ } );
1222
+ } else {
1223
+ query.push( {
1224
+ $match: {
1225
+ status: { $in: req.body.statusFilter },
1226
+ },
1227
+ } );
1228
+ }
1208
1229
  }
1209
1230
  if ( req.body.userFilter && req.body.userFilter.length > 0 ) {
1210
1231
  query.push( {
@@ -754,10 +754,12 @@ export async function edgeApplogsCheck( req, res ) {
754
754
  try {
755
755
  let finalresult = [];
756
756
  let ticketList = await findTangoTicket( { 'issueDate': new Date( req.body.issueDate ), 'status': { $ne: 'closed' }, 'ticketDetails.issueStatus': 'notidentified', 'issueType': 'infra' } );
757
+ let refreshTicket = await findTangoTicket( { 'ticketDetails.ticketRefreshTime': new Date( req.body.issueDate ), 'status': { $ne: 'closed' }, 'ticketDetails.ticketType': 'refreshticket', 'ticketDetails.refreshTicketStatus': 'notidentified', 'issueType': 'infra' } );
758
+ ticketList = [ ...refreshTicket, ...ticketList ];
757
759
  for ( let ticket of ticketList ) {
758
760
  req.body.date = dayjs( ticket.createdAt ).format( 'YYYY-MM-DD' );
759
761
  let errorLog = {
760
- 'size': 500,
762
+ 'size': 5000,
761
763
  'query': {
762
764
  'bool': {
763
765
  'must': [
@@ -770,7 +772,7 @@ export async function edgeApplogsCheck( req, res ) {
770
772
  },
771
773
  {
772
774
  'term': {
773
- 'store_date.keyword': dayjs( ticket.createdAt ).format( 'DD-MM-YYYY' ),
775
+ 'store_date.keyword': dayjs( req.body.date ).format( 'DD-MM-YYYY' ),
774
776
  },
775
777
  },
776
778
  {
@@ -787,121 +789,56 @@ export async function edgeApplogsCheck( req, res ) {
787
789
  { 'timestamp': { 'order': 'desc' } },
788
790
  ],
789
791
  };
792
+
790
793
  const errorLogList = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, errorLog );
791
794
 
792
795
  let result = [];
793
-
796
+ function createLogCheck( error ) {
797
+ return {
798
+ code: error._source.log_code,
799
+ edgelog: error._source.data,
800
+ };
801
+ }
794
802
  for ( let error of errorLogList.body.hits.hits ) {
795
- if ( error._source.log_code == '1003' ) {
796
- let logCheck = {
797
- code: error._source.log_code,
798
- edgelog: error._source.data,
799
- };
800
- result.push( logCheck );
803
+ const logCode = error._source.log_code;
804
+ const relevantCodes = [ 1003, 1011, 1022, 1024, 1025, 1000 ];
805
+ if ( relevantCodes.includes( Number( logCode ) ) ) {
806
+ result.push( createLogCheck( error ) );
801
807
  }
802
- // if ( error._source.log_code == '1001' ) {
803
- // let logCheck = {
804
- // code: error._source.log_code,
805
- // edgelog: error._source.data,
806
- // };
807
- // result.push( logCheck );
808
- // }
809
-
810
- // if ( error._source.log_code == '1004' ) {
811
- // let logCheck = {
812
- // code: error._source.log_code,
813
- // edgelog: error._source.data,
814
808
 
815
- // };
816
- // result.push( logCheck );
817
- // }
818
- if ( error._source.log_code == '1005' ) {
809
+ if ( logCode === '1005' ) {
819
810
  const bytes = error._source.data.upload_Speed.split( '.' )[0];
820
811
  const megabytes = bytesToMB( bytes );
821
812
  if ( megabytes < 2 ) {
822
- let logCheck = {
823
- code: error._source.log_code,
824
- edgelog: error._source.data,
825
-
826
- };
827
- result.push( logCheck );
813
+ result.push( createLogCheck( error ) );
828
814
  }
829
815
  }
830
816
 
831
-
832
- if ( error._source.log_code == '1011' ) {
833
- let logCheck = {
834
- code: error._source.log_code,
835
- edgelog: error._source.data,
836
-
837
- };
838
- result.push( logCheck );
839
- }
840
- if ( error._source.log_code == '1022' ) {
841
- let logCheck = {
842
- code: error._source.log_code,
843
- edgelog: error._source.data,
844
-
845
- };
846
- result.push( logCheck );
847
- }
848
- if ( error._source.log_code == '1024' ) {
849
- let logCheck = {
850
- code: error._source.log_code,
851
- edgelog: error._source.data,
852
-
853
- };
854
- result.push( logCheck );
855
- }
856
- if ( error._source.log_code == '1025' ) {
857
- let logCheck = {
858
- code: error._source.log_code,
859
- edgelog: error._source.data,
860
-
861
- };
862
- result.push( logCheck );
863
- }
864
-
865
- if ( error._source.log_code == '1000' ) {
866
- let logCheck = {
867
- code: error._source.log_code,
868
- edgelog: error._source.data,
869
-
870
- };
871
- result.push( logCheck );
872
- }
873
-
874
- if ( error._source.log_code == '1007' ) {
875
- let logCheck = {
876
- code: error._source.log_code,
877
- edgelog: error._source.data,
878
-
879
- };
880
- result.push( logCheck );
881
- }
882
- if ( error._source.log_code == '1034' ) {
883
- let logCheck = {
884
- code: error._source.log_code,
885
- edgelog: error._source.data,
886
-
887
- };
888
- result.push( logCheck );
889
- }
890
-
891
- if ( Number( error._source.log_code ) > 2000 ) {
892
- let logCheck = {
893
- code: error._source.log_code,
894
- edgelog: error._source.data,
895
- };
896
- result.push( logCheck );
817
+ if ( Number( logCode ) > 2000 && Number( logCode ) !== 2007&& Number( logCode ) !== 2014&& Number( logCode ) !== 2004 ) {
818
+ result.push( createLogCheck( error ) );
897
819
  }
898
820
  }
821
+
899
822
  let findissueEdgeApp = {};
900
823
  if ( result.length > 0 ) {
901
824
  for ( let findissue of result ) {
902
825
  const istTimestamp = dayjs.utc( ticket.createdAt ).tz( 'Asia/Kolkata' ).format( 'HH:mm:ss' );
903
-
904
- if ( findissue.code == '1003' ) {
826
+ if ( findissue.code == '1000' ) {
827
+ const occurringTimeParsed = dayjs( `${req.body.date} ${findissue.edgelog.occuringTime}` );
828
+ const ticketCreatedParsed = dayjs( `${req.body.date} ${istTimestamp}` );
829
+ const isOccurringTimeEarlier = occurringTimeParsed.isBefore( ticketCreatedParsed );
830
+ if ( isOccurringTimeEarlier ) {
831
+ findissueEdgeApp = {
832
+ ticketId: ticket.ticketId,
833
+ edgelog: findissue,
834
+ storeId: ticket.basicDetails.storeId,
835
+ primary: 'Application Issues',
836
+ secondary: [ 'Application crashed' ],
837
+ };
838
+ updateIssue( findissueEdgeApp );
839
+ finalresult.push( findissueEdgeApp );
840
+ }
841
+ } else if ( findissue.code == '1003' ) {
905
842
  const occurringTimeParsed = dayjs( `${req.body.date} ${findissue.edgelog.occuringTime}` );
906
843
  const ticketCreatedParsed = dayjs( `${req.body.date} ${istTimestamp}` );
907
844
  const isOccurringTimeEarlier = occurringTimeParsed.isBefore( ticketCreatedParsed );
@@ -916,11 +853,68 @@ export async function edgeApplogsCheck( req, res ) {
916
853
  updateIssue( findissueEdgeApp );
917
854
  finalresult.push( findissueEdgeApp );
918
855
  }
856
+ } else if ( findissue.code == '2024' ) {
857
+ const occurringTimeParsed = dayjs( `${req.body.date} ${findissue.edgelog.occuringTime}` );
858
+ const ticketCreatedParsed = dayjs( `${req.body.date} ${istTimestamp}` );
859
+ const isOccurringTimeEarlier = occurringTimeParsed.isBefore( ticketCreatedParsed );
860
+ const existsInArray = finalresult.some( ( item ) =>
861
+ item.ticketId === ticket.ticketId,
862
+ );
863
+ if ( isOccurringTimeEarlier && !existsInArray ) {
864
+ findissueEdgeApp = {
865
+ ticketId: ticket.ticketId,
866
+ storeId: ticket.basicDetails.storeId,
867
+ edgelog: findissue.edgelog,
868
+ primary: 'Camera Issues',
869
+ secondary: [ 'Internet and camera not working' ],
870
+ };
871
+ updateIssue( findissueEdgeApp );
872
+ finalresult.push( findissueEdgeApp );
873
+ }
919
874
  } else if ( findissue.code == '1024' ) {
920
875
  const occurringTimeParsed = dayjs( `${req.body.date} ${findissue.edgelog.data.occuringTime}` );
921
876
  const ticketCreatedParsed = dayjs( `${req.body.date} ${istTimestamp}` );
922
877
  const isOccurringTimeEarlier = occurringTimeParsed.isBefore( ticketCreatedParsed );
923
878
 
879
+ const existsInArray = finalresult.some( ( item ) =>
880
+ item.ticketId === ticket.ticketId,
881
+ );
882
+ if ( isOccurringTimeEarlier && !existsInArray ) {
883
+ const pingOutput =findissue.edgelog.data.message;
884
+ const regex = /Sent = (\d+), Received = (\d+), Lost = (\d+)/;
885
+ const match = pingOutput.match( regex );
886
+
887
+ if ( match ) {
888
+ // const sent = match[1];
889
+ const received = match[2];
890
+ // const lost = match[3];
891
+
892
+ if ( Number( received )<2 ) {
893
+ findissueEdgeApp = {
894
+ ticketId: ticket.ticketId,
895
+ storeId: ticket.basicDetails.storeId,
896
+ edgelog: findissue.edgelog.data,
897
+ primary: 'Camera Issues',
898
+ secondary: [ 'IP not pinging / Camera not working' ],
899
+ };
900
+ } else if ( Number( received )>2 ) {
901
+ findissueEdgeApp = {
902
+ ticketId: ticket.ticketId,
903
+ storeId: ticket.basicDetails.storeId,
904
+ edgelog: findissue.edgelog.data,
905
+ primary: 'Camera Issues',
906
+ secondary: [ 'Rtsp/url not supported/Camera credential changed' ],
907
+ };
908
+ }
909
+ updateIssue( findissueEdgeApp );
910
+ finalresult.push( findissueEdgeApp );
911
+ }
912
+ }
913
+ } else if ( findissue.code == '1025' ) {
914
+ const occurringTimeParsed = dayjs( `${req.body.date} ${findissue.edgelog.occuringTime}` );
915
+ const ticketCreatedParsed = dayjs( `${req.body.date} ${istTimestamp}` );
916
+ const isOccurringTimeEarlier = occurringTimeParsed.isBefore( ticketCreatedParsed );
917
+
924
918
  const existsInArray = finalresult.some( ( item ) =>
925
919
  item.ticketId === ticket.ticketId,
926
920
  );
@@ -928,9 +922,9 @@ export async function edgeApplogsCheck( req, res ) {
928
922
  findissueEdgeApp = {
929
923
  ticketId: ticket.ticketId,
930
924
  storeId: ticket.basicDetails.storeId,
931
- edgelog: findissue.edgelog.data,
932
- primary: 'Camera Issues',
933
- secondary: [ 'Camera not working' ],
925
+ edgelog: findissue.edgelog,
926
+ primary: 'Application Issues',
927
+ secondary: [ 'App without stream' ],
934
928
  };
935
929
  updateIssue( findissueEdgeApp );
936
930
  finalresult.push( findissueEdgeApp );
@@ -951,6 +945,21 @@ export async function edgeApplogsCheck( req, res ) {
951
945
  updateIssue( findissueEdgeApp );
952
946
  finalresult.push( findissueEdgeApp );
953
947
  }
948
+ } else if ( findissue.code === '1016' ) {
949
+ const occurringTimeParsed = dayjs( `${req.body.date} ${findissue.edgelog.occuringTime}` );
950
+ const ticketCreatedParsed = dayjs( `${req.body.date} ${istTimestamp}` );
951
+ const isOccurringTimeEarlier = occurringTimeParsed.isBefore( ticketCreatedParsed );
952
+ if ( isOccurringTimeEarlier ) {
953
+ findissueEdgeApp = {
954
+ ticketId: ticket.ticketId,
955
+ edgelog: findissue,
956
+ storeId: ticket.basicDetails.storeId,
957
+ primary: 'Application Issues',
958
+ secondary: [ 'App login issue' ],
959
+ };
960
+ updateIssue( findissueEdgeApp );
961
+ finalresult.push( findissueEdgeApp );
962
+ }
954
963
  } else if ( findissue.code === '1005' ) {
955
964
  const occurringTimeParsed = dayjs( `${req.body.date} ${findissue.edgelog.occuringTime}` );
956
965
  const ticketCreatedParsed = dayjs( `${req.body.date} ${istTimestamp}` );
@@ -987,89 +996,75 @@ export async function updateIssue( data ) {
987
996
  ticketId: data.ticketId,
988
997
  },
989
998
  );
990
-
991
- data.issueType = Ticket.issueType;
992
- data.basicDetails = Ticket.basicDetails;
993
- data.ticketDetails = Ticket.ticketDetails;
994
- data.ticketActivity = Ticket.ticketActivity;
995
- if ( data.primary && data.secondary && data.secondary.length ) {
996
- let primaryReason = await findOneinfraReason( { name: data.primary } );
997
- if ( !primaryReason ) {
998
- return res.sendError( 'Primary Reason Not exists in database', 500 );
999
- }
1000
- const secondary = [];
1001
- const steptoReslove = [];
1002
- for ( let i = 0; i < data.secondary.length; i++ ) {
1003
- let secondaryReason = await findOneinfraReason( { name: data.secondary[i] } );
1004
- if ( !secondaryReason ) {
1005
- return res.sendError( `secondary Reason - ${data.secondary[i]} Not exists in database`, 500 );
999
+ if ( Ticket ) {
1000
+ data.issueType = Ticket.issueType;
1001
+ data.basicDetails = Ticket.basicDetails;
1002
+ data.ticketDetails = Ticket.ticketDetails;
1003
+ data.ticketActivity = Ticket.ticketActivity;
1004
+ if ( data.primary && data.secondary && data.secondary.length ) {
1005
+ let primaryReason = await findOneinfraReason( { name: data.primary } );
1006
+ if ( !primaryReason ) {
1007
+ return res.sendError( 'Primary Reason Not exists in database', 500 );
1006
1008
  }
1007
- secondary.push( {
1008
- name: secondaryReason.name,
1009
- } );
1010
- let resolveSteps = [];
1011
- for ( let i = 0; i < secondaryReason.stepstoResolve.length; i++ ) {
1012
- resolveSteps.push( {
1013
- name: secondaryReason.stepstoResolve[i].name,
1009
+ const secondary = [];
1010
+ const steptoReslove = [];
1011
+ for ( let i = 0; i < data.secondary.length; i++ ) {
1012
+ let secondaryReason = await findOneinfraReason( { name: data.secondary[i] } );
1013
+ if ( !secondaryReason ) {
1014
+ return res.sendError( `secondary Reason - ${data.secondary[i]} Not exists in database`, 500 );
1015
+ }
1016
+ secondary.push( {
1017
+ name: secondaryReason.name,
1018
+ } );
1019
+ let resolveSteps = [];
1020
+ for ( let i = 0; i < secondaryReason.stepstoResolve.length; i++ ) {
1021
+ resolveSteps.push( {
1022
+ name: secondaryReason.stepstoResolve[i].name,
1023
+ } );
1024
+ }
1025
+ steptoReslove.push( {
1026
+ primaryIssue: secondaryReason.name,
1027
+ secondaryIsssue: [ ...resolveSteps ],
1014
1028
  } );
1015
1029
  }
1016
- steptoReslove.push( {
1017
- primaryIssue: secondaryReason.name,
1018
- secondaryIsssue: [ ...resolveSteps ],
1019
- } );
1020
- }
1021
1030
 
1022
- data.ticketActivity.push( {
1023
- actionType: 'issueUpdate',
1024
- actionBy: 'automated',
1025
- IdentifiedBy: 'Tango',
1026
- timeStamp: new Date(),
1027
- reasons: [ {
1028
- primaryIssue: primaryReason.name,
1029
- secondaryIssue: secondary,
1030
- } ],
1031
- },
1032
- );
1033
- } else {
1034
- if ( data.primary == 'Application Issues' ) {
1035
1031
  data.ticketActivity.push( {
1036
1032
  actionType: 'issueUpdate',
1037
1033
  actionBy: 'automated',
1038
- timeStamp: new Date(),
1039
1034
  IdentifiedBy: 'Tango',
1035
+ timeStamp: new Date(),
1040
1036
  reasons: [ {
1041
- primaryIssue: data.primary,
1042
- secondaryIssue: [],
1037
+ primaryIssue: primaryReason.name,
1038
+ secondaryIssue: secondary,
1043
1039
  } ],
1044
1040
  },
1045
1041
  );
1046
1042
  }
1043
+ if ( data.issueType == 'infra' ) {
1044
+ let client = await findOneClient( { clientId: data.basicDetails.clientId }, { ticketConfigs: 1 } );
1045
+ let statusCheckAlertTime = dayjs().add( client.ticketConfigs.statusCheckAlert, 'hours' ).format( 'YYYY-MM-DD hh:mm' );
1046
+ data.ticketActivity.push( {
1047
+ actionType: 'statusCheck',
1048
+ timeStamp: statusCheckAlertTime,
1049
+ actionBy: 'Tango',
1050
+ IdentifiedBy: 'Tango',
1051
+ statusCheckAlertTime: statusCheckAlertTime,
1052
+ } );
1053
+ }
1054
+ let client = await findOneClient( { clientId: data.basicDetails.clientId } );
1055
+ let refreshdate = dayjs().add( client.ticketConfigs.refreshAlert, 'days' );
1056
+
1057
+ let query = {
1058
+ 'ticketActivity': data.ticketActivity,
1059
+ 'ticketDetails.issueIdentifiedDate': new Date(),
1060
+ 'ticketDetails.issueStatus': 'identified',
1061
+ 'status': 'inprogress',
1062
+ 'ticketDetails.ticketRefreshTime': new Date( dayjs( refreshdate ).format( 'YYYY-MM-DD' ) ),
1063
+ };
1064
+ await updateOneTangoTicket( { ticketId: data.ticketId }, query );
1047
1065
  }
1048
- if ( data.issueType == 'infra' ) {
1049
- let client = await findOneClient( { clientId: data.basicDetails.clientId }, { ticketConfigs: 1 } );
1050
- let statusCheckAlertTime = dayjs().add( client.ticketConfigs.statusCheckAlert, 'hours' ).format( 'YYYY-MM-DD hh:mm' );
1051
- data.ticketActivity.push( {
1052
- actionType: 'statusCheck',
1053
- timeStamp: statusCheckAlertTime,
1054
- actionBy: 'Tango',
1055
- IdentifiedBy: 'Tango',
1056
- statusCheckAlertTime: statusCheckAlertTime,
1057
- } );
1058
- }
1059
- let client = await findOneClient( { clientId: data.basicDetails.clientId } );
1060
- let refreshdate = dayjs().add( client.ticketConfigs.refreshAlert, 'days' );
1061
-
1062
- let query = {
1063
- 'ticketActivity': data.ticketActivity,
1064
- 'ticketDetails.issueIdentifiedDate': new Date(),
1065
- 'ticketDetails.issueStatus': 'identified',
1066
- 'status': 'inprogress',
1067
- 'ticketDetails.ticketRefreshTime': new Date( dayjs( refreshdate ).format( 'YYYY-MM-DD' ) ),
1068
- };
1069
- await updateOneTangoTicket( { ticketId: data.ticketId }, query );
1070
1066
  } catch ( error ) {
1071
1067
  logger.error( { error: error, function: 'updateAutomaticIssue' } );
1072
- res.sendError( error, 500 );
1073
1068
  }
1074
1069
  }
1075
1070
 
@@ -367,7 +367,7 @@ export async function edgeAppLogTable( req, res ) {
367
367
  // Internet speed
368
368
 
369
369
  const speedTest = speedTestData.find(
370
- ( item ) => Number( item._source.data.occuringTime.split( ':' )[0] ) === hour,
370
+ ( item ) => Number( item._source.data.occuringTime.split( ':' )[0] ) === Number( hour ),
371
371
  );
372
372
  if ( speedTest&&speedTest._source.data.upload_Speed =='0 bytes' ) {
373
373
  obj.Internetspeed = '0 MB/sec';
@@ -378,15 +378,14 @@ export async function edgeAppLogTable( req, res ) {
378
378
 
379
379
  // File counts
380
380
  const fileCounts = fileCountData.filter(
381
- ( item ) => Number( item._source.data.occuringTime.split( ':' )[0] ) === hour,
381
+ ( item ) => Number( item._source.data.occuringTime.split( ':' )[0] ) === Number( hour ),
382
382
  );
383
+
383
384
  obj.files_pushed = fileCounts.reduce( ( sum, item ) => sum + Number( item._source.data.files_pushed ), 0 ) || '';
384
385
  obj.files_generated = fileCounts.reduce( ( sum, item ) => sum + Number( item._source.data.files_generated ), 0 ) || '';
385
386
 
386
387
  // Downtime
387
-
388
- const downtime = downtimeData.find( ( item ) => Number( item._source.doc.hour ) === hour );
389
-
388
+ const downtime = downtimeData.find( ( item ) => Number( item._source.doc.hour ) === Number( hour ) );
390
389
  if ( downtime ) {
391
390
  const streamwiseDowntime = downtime._source.doc.streamwise_downtime || [];
392
391
  if ( streamwiseDowntime.length > 0 ) {