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

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.10",
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 );
@@ -648,19 +658,19 @@ export async function infraIssuesTable( req, res ) {
648
658
  const exportdata = result.map( ( element ) => {
649
659
  if ( req.body.infrafilterIssue === 'Live Stores' || req.body.infrafilterIssue === 'Total Stores' ) {
650
660
  return {
651
- 'Created On': element.createdAt,
661
+ 'Created On': dayjs( element.createdAt ).format( 'DD MMM, YYYY' ),
652
662
  'StoreID': element.storeId,
653
663
  'StoreName': element.storeName,
654
664
  'Status': element.status,
655
665
  };
656
666
  } else {
657
667
  return {
658
- 'Created On': element.createdAt,
668
+ 'Created On': dayjs( element.createdAt ).format( 'DD MMM, YYYY' ),
659
669
  'StoreID': element.storeId,
660
670
  'StoreName': element.storeName,
661
671
  'Primary Issue': element.primaryIssue,
662
672
  'Sub Issue': element.secondaryIssue,
663
- 'Issue Identified on': element.issueIdentifiedDate ? dayjs( element.issueIdentifiedDate ).tz( 'Asia/Kolkata' ).format( 'YYYY-MM-DD HH:mm A' ) : '',
673
+ 'Issue Identified on': element.issueIdentifiedDate ? dayjs( element.issueIdentifiedDate ).format( 'DD MMM, YYYY' ) : '',
664
674
  'Status': element.status,
665
675
  };
666
676
  }
@@ -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( {
@@ -1310,7 +1331,7 @@ export async function infraTable( req, res ) {
1310
1331
  'Store ID': element.storeId,
1311
1332
  'Resloved By': element.userName,
1312
1333
  'Status': element.status,
1313
- 'Primary Issues': element.primaryIssue,
1334
+ 'Primary Issues': element.primaryIssue=='-'?'Issue not identified':element.primaryIssue,
1314
1335
  'Secondary Issues': element.secondaryIssue,
1315
1336
  'Comment': element.otherscomment ? element.otherscomment : ( element.commentText ? element.commentText : '-' ),
1316
1337
  } );
@@ -1323,7 +1344,7 @@ export async function infraTable( req, res ) {
1323
1344
  'Store Name': element.storeName,
1324
1345
  'Store ID': element.storeId,
1325
1346
  'Status': element.status,
1326
- 'Primary Issues': element.primaryIssue,
1347
+ 'Primary Issues': element.primaryIssue=='-'?'Issue not identified':element.primaryIssue,
1327
1348
  'Secondary Issues': element.secondaryIssue,
1328
1349
  'Comment': element.otherscomment ? element.otherscomment : ( element.commentText ? element.commentText : '-' ),
1329
1350
  } );
@@ -1957,6 +1978,7 @@ export async function dataMismatchTable( req, res ) {
1957
1978
  clientId: '$basicDetails.clientId',
1958
1979
  storeName: '$basicDetails.storeName',
1959
1980
  storeId: '$basicDetails.storeId',
1981
+ type: '$dataMismatch.showToClient',
1960
1982
  userId: { $ifNull: [ '$ticketDetails.addressingUser', '$$REMOVE' ] },
1961
1983
  issueType: 1,
1962
1984
  status: 1,
@@ -2017,6 +2039,7 @@ export async function dataMismatchTable( req, res ) {
2017
2039
  userInfo: { $first: '$userInfo' },
2018
2040
  issueType: { $first: '$issueType' },
2019
2041
  status: { $first: '$status' },
2042
+ type: { $first: '$type' },
2020
2043
  otherscomment: { $last: '$otherscomment.comment' },
2021
2044
  },
2022
2045
  },
@@ -2031,7 +2054,7 @@ export async function dataMismatchTable( req, res ) {
2031
2054
  storeId: 1,
2032
2055
  userName: { $ifNull: [ '$userInfo.userName', '' ] },
2033
2056
  email: { $ifNull: [ '$userInfo.email', '' ] },
2034
- type: { $ifNull: [ { $cond: [ { $eq: [ '$userInfo.userType', 'client' ] }, 'external', { $cond: [ { $eq: [ '$userInfo.userType', 'tango' ] }, 'internal', '' ] } ] }, '' ] },
2057
+ type: { $ifNull: [ { $cond: [ { $eq: [ '$type', false ] }, 'internal', { $cond: [ { $eq: [ '$type', true ] }, 'external', '' ] } ] }, '' ] },
2035
2058
  issueType: 1,
2036
2059
  status: 1,
2037
2060
  otherscomment: 1,
@@ -91,7 +91,7 @@ export async function basicList( req, res ) {
91
91
  for ( let client of clientList ) {
92
92
  clients.push( client.clientId );
93
93
  }
94
- let storeList = await findStore( { 'clientId': { $in: clients }, 'status': 'active', 'edge.firstFile': true },
94
+ let storeList = await findStore( { 'clientId': { $in: clients }, 'status': 'active', 'edge.firstFile': true, 'storeProfile.open': { $exists: true }, 'storeProfile.close': { $exists: true }, 'storeProfile.timeZone': { $exists: true } },
95
95
  { 'storeName': 1, 'storeId': 1, 'ticketConfigs': 1, 'clientId': 1, 'storeProfile.open': 1, 'storeProfile.close': 1, 'storeProfile.timeZone': 1 } );
96
96
  logger.info( { 'storeList': storeList, 'message': 'storeList' } );
97
97
 
@@ -757,7 +757,7 @@ export async function edgeApplogsCheck( req, res ) {
757
757
  for ( let ticket of ticketList ) {
758
758
  req.body.date = dayjs( ticket.createdAt ).format( 'YYYY-MM-DD' );
759
759
  let errorLog = {
760
- 'size': 500,
760
+ 'size': 5000,
761
761
  'query': {
762
762
  'bool': {
763
763
  'must': [
@@ -770,7 +770,7 @@ export async function edgeApplogsCheck( req, res ) {
770
770
  },
771
771
  {
772
772
  'term': {
773
- 'store_date.keyword': dayjs( ticket.createdAt ).format( 'DD-MM-YYYY' ),
773
+ 'store_date.keyword': dayjs( req.body.date ).format( 'DD-MM-YYYY' ),
774
774
  },
775
775
  },
776
776
  {
@@ -787,125 +787,54 @@ export async function edgeApplogsCheck( req, res ) {
787
787
  { 'timestamp': { 'order': 'desc' } },
788
788
  ],
789
789
  };
790
+
790
791
  const errorLogList = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, errorLog );
791
792
 
792
793
  let result = [];
793
-
794
+ function createLogCheck( error ) {
795
+ return {
796
+ code: error._source.log_code,
797
+ edgelog: error._source.data,
798
+ };
799
+ }
794
800
  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 );
801
+ const logCode = error._source.log_code;
802
+ const relevantCodes = [ 1003, 1011, 1022, 1024, 1025, 1026, 1000 ];
803
+ if ( relevantCodes.includes( Number( logCode ) ) ) {
804
+ result.push( createLogCheck( error ) );
801
805
  }
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,
806
+ let internetSlowcount = [];
814
807
 
815
- // };
816
- // result.push( logCheck );
817
- // }
818
- if ( error._source.log_code == '1005' ) {
808
+ if ( logCode === '1005' ) {
819
809
  const bytes = error._source.data.upload_Speed.split( '.' )[0];
820
810
  const megabytes = bytesToMB( bytes );
821
811
  if ( megabytes < 2 ) {
822
- let logCheck = {
823
- code: error._source.log_code,
824
- edgelog: error._source.data,
825
-
826
- };
827
- result.push( logCheck );
812
+ internetSlowcount.push(error)
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 ) {
818
+ result.push( createLogCheck( error ) );
897
819
  }
898
820
  }
821
+
899
822
  let findissueEdgeApp = {};
900
823
  if ( result.length > 0 ) {
824
+ let logincount = [];
825
+ let appcrashcount = [];
826
+
827
+
901
828
  for ( let findissue of result ) {
902
829
  const istTimestamp = dayjs.utc( ticket.createdAt ).tz( 'Asia/Kolkata' ).format( 'HH:mm:ss' );
903
-
904
830
  if ( findissue.code == '1003' ) {
905
831
  const occurringTimeParsed = dayjs( `${req.body.date} ${findissue.edgelog.occuringTime}` );
906
832
  const ticketCreatedParsed = dayjs( `${req.body.date} ${istTimestamp}` );
907
833
  const isOccurringTimeEarlier = occurringTimeParsed.isBefore( ticketCreatedParsed );
908
- if ( isOccurringTimeEarlier ) {
834
+ const existsInArray = finalresult.some( ( item ) =>
835
+ item.ticketId === ticket.ticketId,
836
+ );
837
+ if ( isOccurringTimeEarlier&&!existsInArray ) {
909
838
  findissueEdgeApp = {
910
839
  ticketId: ticket.ticketId,
911
840
  edgelog: findissue,
@@ -916,11 +845,92 @@ export async function edgeApplogsCheck( req, res ) {
916
845
  updateIssue( findissueEdgeApp );
917
846
  finalresult.push( findissueEdgeApp );
918
847
  }
848
+ } if ( findissue.code == '2004' ) {
849
+ let store = await findOneStore( { storeId: ticket.basicDetails.storeId } );
850
+ const occurringTimeParsed = dayjs( `${req.body.date} ${findissue.edgelog.occuringTime}` );
851
+ const ticketCreatedParsed = dayjs( `${req.body.date} ${istTimestamp}` );
852
+ const stroreopenTime = dayjs( `${req.body.date} ${store.storeProfile.open}` );
853
+ const isOccurringTimeEarlier = occurringTimeParsed.isBefore( ticketCreatedParsed );
854
+ const afterStoreOpen = occurringTimeParsed.isAfter( stroreopenTime );
855
+ const existsInArray = finalresult.some( ( item ) =>
856
+ item.ticketId === ticket.ticketId,
857
+ );
858
+ if ( isOccurringTimeEarlier&&afterStoreOpen&&!existsInArray ) {
859
+ logincount.push( findissue.edgelog.occuringTime );
860
+ if ( logincount.length >3 ) {
861
+ findissueEdgeApp = {
862
+ ticketId: ticket.ticketId,
863
+ edgelog: findissue,
864
+ storeId: ticket.basicDetails.storeId,
865
+ primary: 'Internet Issues',
866
+ secondary: [ 'Internet not working' ],
867
+ };
868
+ updateIssue( findissueEdgeApp );
869
+ finalresult.push( findissueEdgeApp );
870
+ }
871
+ }
872
+ } else if ( findissue.code == '2024' ) {
873
+ const occurringTimeParsed = dayjs( `${req.body.date} ${findissue.edgelog.occuringTime}` );
874
+ const ticketCreatedParsed = dayjs( `${req.body.date} ${istTimestamp}` );
875
+ const isOccurringTimeEarlier = occurringTimeParsed.isBefore( ticketCreatedParsed );
876
+ const existsInArray = finalresult.some( ( item ) =>
877
+ item.ticketId === ticket.ticketId,
878
+ );
879
+ if ( isOccurringTimeEarlier && !existsInArray ) {
880
+ findissueEdgeApp = {
881
+ ticketId: ticket.ticketId,
882
+ storeId: ticket.basicDetails.storeId,
883
+ edgelog: findissue.edgelog,
884
+ primary: 'Camera Issues',
885
+ secondary: [ 'Internet and camera not working' ],
886
+ };
887
+ updateIssue( findissueEdgeApp );
888
+ finalresult.push( findissueEdgeApp );
889
+ }
919
890
  } else if ( findissue.code == '1024' ) {
920
891
  const occurringTimeParsed = dayjs( `${req.body.date} ${findissue.edgelog.data.occuringTime}` );
921
892
  const ticketCreatedParsed = dayjs( `${req.body.date} ${istTimestamp}` );
922
893
  const isOccurringTimeEarlier = occurringTimeParsed.isBefore( ticketCreatedParsed );
923
894
 
895
+ const existsInArray = finalresult.some( ( item ) =>
896
+ item.ticketId === ticket.ticketId,
897
+ );
898
+ if ( isOccurringTimeEarlier && !existsInArray ) {
899
+ const pingOutput =findissue.edgelog.data.message;
900
+ const regex = /Sent = (\d+), Received = (\d+), Lost = (\d+)/;
901
+ const match = pingOutput.match( regex );
902
+
903
+ if ( match ) {
904
+ // const sent = match[1];
905
+ const received = match[2];
906
+ // const lost = match[3];
907
+
908
+ if ( Number( received )<2 ) {
909
+ findissueEdgeApp = {
910
+ ticketId: ticket.ticketId,
911
+ storeId: ticket.basicDetails.storeId,
912
+ edgelog: findissue.edgelog.data,
913
+ primary: 'Camera Issues',
914
+ secondary: [ 'IP not pinging / Camera not working' ],
915
+ };
916
+ } else if ( Number( received )>2 ) {
917
+ findissueEdgeApp = {
918
+ ticketId: ticket.ticketId,
919
+ storeId: ticket.basicDetails.storeId,
920
+ edgelog: findissue.edgelog.data,
921
+ primary: 'Camera Issues',
922
+ secondary: [ 'Rtsp/url not supported/Camera credential changed' ],
923
+ };
924
+ }
925
+ updateIssue( findissueEdgeApp );
926
+ finalresult.push( findissueEdgeApp );
927
+ }
928
+ }
929
+ } else if ( findissue.code == '1025' ) {
930
+ const occurringTimeParsed = dayjs( `${req.body.date} ${findissue.edgelog.occuringTime}` );
931
+ const ticketCreatedParsed = dayjs( `${req.body.date} ${istTimestamp}` );
932
+ const isOccurringTimeEarlier = occurringTimeParsed.isBefore( ticketCreatedParsed );
933
+
924
934
  const existsInArray = finalresult.some( ( item ) =>
925
935
  item.ticketId === ticket.ticketId,
926
936
  );
@@ -928,9 +938,9 @@ export async function edgeApplogsCheck( req, res ) {
928
938
  findissueEdgeApp = {
929
939
  ticketId: ticket.ticketId,
930
940
  storeId: ticket.basicDetails.storeId,
931
- edgelog: findissue.edgelog.data,
932
- primary: 'Camera Issues',
933
- secondary: [ 'Camera not working' ],
941
+ edgelog: findissue.edgelog,
942
+ primary: 'Application Issues',
943
+ secondary: [ 'App without stream' ],
934
944
  };
935
945
  updateIssue( findissueEdgeApp );
936
946
  finalresult.push( findissueEdgeApp );
@@ -939,8 +949,10 @@ export async function edgeApplogsCheck( req, res ) {
939
949
  const occurringTimeParsed = dayjs( `${req.body.date} ${findissue.edgelog.occuringTime}` );
940
950
  const ticketCreatedParsed = dayjs( `${req.body.date} ${istTimestamp}` );
941
951
  const isOccurringTimeEarlier = occurringTimeParsed.isBefore( ticketCreatedParsed );
942
-
943
- if ( isOccurringTimeEarlier ) {
952
+ const existsInArray = finalresult.some( ( item ) =>
953
+ item.ticketId === ticket.ticketId,
954
+ );
955
+ if ( isOccurringTimeEarlier&&!existsInArray ) {
944
956
  findissueEdgeApp = {
945
957
  ticketId: ticket.ticketId,
946
958
  edgelog: findissue,
@@ -951,21 +963,65 @@ export async function edgeApplogsCheck( req, res ) {
951
963
  updateIssue( findissueEdgeApp );
952
964
  finalresult.push( findissueEdgeApp );
953
965
  }
954
- } else if ( findissue.code === '1005' ) {
966
+ } else if ( findissue.code == '1026' ) {
955
967
  const occurringTimeParsed = dayjs( `${req.body.date} ${findissue.edgelog.occuringTime}` );
956
968
  const ticketCreatedParsed = dayjs( `${req.body.date} ${istTimestamp}` );
957
969
  const isOccurringTimeEarlier = occurringTimeParsed.isBefore( ticketCreatedParsed );
958
- if ( isOccurringTimeEarlier ) {
970
+ const existsInArray = finalresult.some( ( item ) =>
971
+ item.ticketId === ticket.ticketId,
972
+ );
973
+ if ( isOccurringTimeEarlier &&!existsInArray ) {
974
+ if ( ( Number( findissue.edgelog.files_generated )-Number( findissue.edgelog.files_pushed ) )>3 &&internetSlowcount.length==1) {
975
+ findissueEdgeApp = {
976
+ ticketId: ticket.ticketId,
977
+ edgelog: findissue,
978
+ storeId: ticket.basicDetails.storeId,
979
+ primary: 'Internet Issues',
980
+ secondary: [ 'Internet slow' ],
981
+ };
982
+ }
983
+ updateIssue( findissueEdgeApp );
984
+ finalresult.push( findissueEdgeApp );
985
+ }
986
+ } else if ( findissue.code == '1016' ) {
987
+ const occurringTimeParsed = dayjs( `${req.body.date} ${findissue.edgelog.occuringTime}` );
988
+ const ticketCreatedParsed = dayjs( `${req.body.date} ${istTimestamp}` );
989
+ const isOccurringTimeEarlier = occurringTimeParsed.isBefore( ticketCreatedParsed );
990
+ const existsInArray = finalresult.some( ( item ) =>
991
+ item.ticketId === ticket.ticketId,
992
+ );
993
+ if ( isOccurringTimeEarlier&&!existsInArray ) {
959
994
  findissueEdgeApp = {
960
995
  ticketId: ticket.ticketId,
961
996
  edgelog: findissue,
962
997
  storeId: ticket.basicDetails.storeId,
963
- primary: 'Internet Issues',
964
- secondary: [ 'Internet slow' ],
998
+ primary: 'Application Issues',
999
+ secondary: [ 'App login issue' ],
965
1000
  };
966
1001
  updateIssue( findissueEdgeApp );
967
1002
  finalresult.push( findissueEdgeApp );
968
1003
  }
1004
+ } else if ( findissue.code == '1000' ) {
1005
+ const occurringTimeParsed = dayjs( `${req.body.date} ${findissue.edgelog.occuringTime}` );
1006
+ const ticketCreatedParsed = dayjs( `${req.body.date} ${istTimestamp}` );
1007
+ const isOccurringTimeEarlier = occurringTimeParsed.isBefore( ticketCreatedParsed );
1008
+ const existsInArray = finalresult.some( ( item ) =>
1009
+ item.ticketId === ticket.ticketId,
1010
+ );
1011
+ if ( isOccurringTimeEarlier&&!existsInArray ) {
1012
+ appcrashcount.push(findissue)
1013
+ if(appcrashcount.length>3){
1014
+ findissueEdgeApp = {
1015
+ ticketId: ticket.ticketId,
1016
+ edgelog: findissue,
1017
+ storeId: ticket.basicDetails.storeId,
1018
+ primary: 'Application Issues',
1019
+ secondary: [ 'Application crashed' ],
1020
+ };
1021
+ updateIssue( findissueEdgeApp );
1022
+ finalresult.push( findissueEdgeApp );
1023
+ }
1024
+ }
969
1025
  }
970
1026
  }
971
1027
  }
@@ -987,89 +1043,75 @@ export async function updateIssue( data ) {
987
1043
  ticketId: data.ticketId,
988
1044
  },
989
1045
  );
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 );
1046
+ if ( Ticket ) {
1047
+ data.issueType = Ticket.issueType;
1048
+ data.basicDetails = Ticket.basicDetails;
1049
+ data.ticketDetails = Ticket.ticketDetails;
1050
+ data.ticketActivity = Ticket.ticketActivity;
1051
+ if ( data.primary && data.secondary && data.secondary.length ) {
1052
+ let primaryReason = await findOneinfraReason( { name: data.primary } );
1053
+ if ( !primaryReason ) {
1054
+ return res.sendError( 'Primary Reason Not exists in database', 500 );
1006
1055
  }
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,
1056
+ const secondary = [];
1057
+ const steptoReslove = [];
1058
+ for ( let i = 0; i < data.secondary.length; i++ ) {
1059
+ let secondaryReason = await findOneinfraReason( { name: data.secondary[i] } );
1060
+ if ( !secondaryReason ) {
1061
+ return res.sendError( `secondary Reason - ${data.secondary[i]} Not exists in database`, 500 );
1062
+ }
1063
+ secondary.push( {
1064
+ name: secondaryReason.name,
1065
+ } );
1066
+ let resolveSteps = [];
1067
+ for ( let i = 0; i < secondaryReason.stepstoResolve.length; i++ ) {
1068
+ resolveSteps.push( {
1069
+ name: secondaryReason.stepstoResolve[i].name,
1070
+ } );
1071
+ }
1072
+ steptoReslove.push( {
1073
+ primaryIssue: secondaryReason.name,
1074
+ secondaryIsssue: [ ...resolveSteps ],
1014
1075
  } );
1015
1076
  }
1016
- steptoReslove.push( {
1017
- primaryIssue: secondaryReason.name,
1018
- secondaryIsssue: [ ...resolveSteps ],
1019
- } );
1020
- }
1021
1077
 
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
1078
  data.ticketActivity.push( {
1036
1079
  actionType: 'issueUpdate',
1037
1080
  actionBy: 'automated',
1038
- timeStamp: new Date(),
1039
1081
  IdentifiedBy: 'Tango',
1082
+ timeStamp: new Date(),
1040
1083
  reasons: [ {
1041
- primaryIssue: data.primary,
1042
- secondaryIssue: [],
1084
+ primaryIssue: primaryReason.name,
1085
+ secondaryIssue: secondary,
1043
1086
  } ],
1044
1087
  },
1045
1088
  );
1046
1089
  }
1090
+ if ( data.issueType == 'infra' ) {
1091
+ let client = await findOneClient( { clientId: data.basicDetails.clientId }, { ticketConfigs: 1 } );
1092
+ let statusCheckAlertTime = dayjs().add( client.ticketConfigs.statusCheckAlert, 'hours' ).format( 'YYYY-MM-DD hh:mm' );
1093
+ data.ticketActivity.push( {
1094
+ actionType: 'statusCheck',
1095
+ timeStamp: statusCheckAlertTime,
1096
+ actionBy: 'Tango',
1097
+ IdentifiedBy: 'Tango',
1098
+ statusCheckAlertTime: statusCheckAlertTime,
1099
+ } );
1100
+ }
1101
+ let client = await findOneClient( { clientId: data.basicDetails.clientId } );
1102
+ let refreshdate = dayjs().add( client.ticketConfigs.refreshAlert, 'days' );
1103
+
1104
+ let query = {
1105
+ 'ticketActivity': data.ticketActivity,
1106
+ 'ticketDetails.issueIdentifiedDate': new Date(),
1107
+ 'ticketDetails.issueStatus': 'identified',
1108
+ 'status': 'inprogress',
1109
+ 'ticketDetails.ticketRefreshTime': new Date( dayjs( refreshdate ).format( 'YYYY-MM-DD' ) ),
1110
+ };
1111
+ await updateOneTangoTicket( { ticketId: data.ticketId }, query );
1047
1112
  }
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
1113
  } catch ( error ) {
1071
1114
  logger.error( { error: error, function: 'updateAutomaticIssue' } );
1072
- res.sendError( error, 500 );
1073
1115
  }
1074
1116
  }
1075
1117
 
@@ -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 ) {
@@ -20,12 +20,14 @@ export async function userTakeTicket( req, res ) {
20
20
  assignedClients.push( client.clientId );
21
21
  }
22
22
  }
23
+ if ( req.body.clientId.length ===1 ) {
24
+ assignedClients =req.body.clientId;
25
+ }
23
26
  let userTicket = '';
24
27
  if ( req.body.issueType == 'infra' ) {
25
28
  let query = {
26
29
  'status': { $ne: 'closed' },
27
30
  'issueType': 'infra',
28
- 'ticketDetails.assigntoUser': true,
29
31
  'ticketDetails.addressingUser': { $exists: false },
30
32
  'ticketDetails.issueStatus': 'notidentified',
31
33
  'ticketDetails.addressingClient': { $exists: false },
@@ -41,6 +43,8 @@ export async function userTakeTicket( req, res ) {
41
43
  'issueType': 'infra',
42
44
  'ticketDetails.ticketType': 'refreshticket',
43
45
  'ticketDetails.refreshTicketStatus': 'notidentified',
46
+ 'ticketDetails.addressingUser': { $exists: false },
47
+ 'ticketDetails.addressingClient': { $exists: false },
44
48
  };
45
49
 
46
50
  if ( assignedClients.length > 0 ) {
@@ -238,6 +242,7 @@ export async function userTicketList( req, res ) {
238
242
  { issueStatus: { $in: req.body.filter } },
239
243
  { infraIssue: { $in: req.body.filter } },
240
244
  { issueType: { $in: req.body.filter } },
245
+ { ticketType: { $in: req.body.filter } },
241
246
  ],
242
247
  },
243
248
  } );
@@ -786,6 +791,7 @@ export async function pendingTicket( req, res ) {
786
791
  $and: [
787
792
  { 'basicDetails.clientId': { $in: req.body.clientId } },
788
793
  { createdAt: { $lte: date.end } },
794
+ { 'ticketDetails.addressingUser': { $exists: false } },
789
795
  ],
790
796
  },
791
797
  },