tango-app-api-infra 3.0.100-dev → 3.0.102-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-infra",
3
- "version": "3.0.100-dev",
3
+ "version": "3.0.102-dev",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -215,7 +215,6 @@ export async function installationCard( req, res ) {
215
215
  $and: [
216
216
  { issueType: 'installation' },
217
217
  { 'status': { $ne: 'closed' } },
218
- { 'ticketDetails.issueStatus': 'notidentified' },
219
218
  { 'basicDetails.clientId': { $in: req.body.clientId } },
220
219
  { createdAt: { $lte: date.end } },
221
220
  ],
@@ -1155,7 +1154,7 @@ function downStoresCheck( data, inputData ) {
1155
1154
  for ( const obj of TimeSlots ) {
1156
1155
  obj.startTime = dayjs( obj.from ).format( 'hh:mm A' );
1157
1156
  obj.endTime = dayjs( obj.to ).format( 'hh:mm A' );
1158
- const downTime = await getOpenSearchData( 'live_downtime_hourly',
1157
+ const downTime = await getOpenSearchData( 'live_downtime_hourly_test1',
1159
1158
  {
1160
1159
  'size': 1,
1161
1160
  'query': {
@@ -58,7 +58,7 @@ export async function createTicket( req, res ) {
58
58
  },
59
59
  };
60
60
  let downtimetotal;
61
- const downtime = await getOpenSearchData( 'live_downtime_hourly', downTimeQuery );
61
+ const downtime = await getOpenSearchData( 'live_downtime_hourly_test1', downTimeQuery );
62
62
  let streamwiseDowntime = downtime.body.hits.hits.length > 0 ? downtime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
63
63
  if ( streamwiseDowntime.length > 0 ) {
64
64
  const sum = streamwiseDowntime.reduce( ( accumulator, currentValue ) => {
@@ -759,7 +759,7 @@ export async function getInfraIssues( req, res ) {
759
759
  return res.sendError( 'NO Data Found', 204 );
760
760
  }
761
761
  for ( let i =0; i< mergeValue.length; i++ ) {
762
- const downTime = await getOpenSearchData( 'live_downtime_hourly',
762
+ const downTime = await getOpenSearchData( 'live_downtime_hourly_test1',
763
763
  {
764
764
  'size': 100,
765
765
  'query': {
@@ -180,7 +180,7 @@ export async function updateRefreshTicket( req, res ) {
180
180
  },
181
181
  };
182
182
  let downtimetotal;
183
- const downtime = await getOpenSearchData( 'live_downtime_hourly', downTimeQuery );
183
+ const downtime = await getOpenSearchData( 'live_downtime_hourly_test1', downTimeQuery );
184
184
  let streamwiseDowntime = downtime.body.hits.hits.length > 0 ? downtime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
185
185
  if ( streamwiseDowntime.length > 0 ) {
186
186
  const sum = streamwiseDowntime.reduce( ( accumulator, currentValue ) => {
@@ -261,7 +261,7 @@ export async function closeTicket( req, res ) {
261
261
  },
262
262
  };
263
263
  let downtimetotal;
264
- const downtime = await getOpenSearchData( 'live_downtime_hourly', downTimeQuery );
264
+ const downtime = await getOpenSearchData( 'live_downtime_hourly_test1', downTimeQuery );
265
265
  let streamwiseDowntime = downtime.body.hits.hits.length > 0 ? downtime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
266
266
  if ( streamwiseDowntime.length > 0 ) {
267
267
  const sum = streamwiseDowntime.reduce( ( accumulator, currentValue ) => {
@@ -294,7 +294,6 @@ export async function edgeAppLogTable( req, res ) {
294
294
  obj.startTime = dayjs( obj.from ).format( 'hh:mm A' );
295
295
  obj.endTime = dayjs( obj.to ).format( 'hh:mm A' );
296
296
  let internetSpeedQuery = {
297
- 'size': 1,
298
297
  'query': {
299
298
  'bool': {
300
299
  'must': [
@@ -305,24 +304,20 @@ export async function edgeAppLogTable( req, res ) {
305
304
  },
306
305
  {
307
306
  'term': {
308
- 'storeId.keyword': req.body.storeId,
307
+ 'store_date.keyword': dayjs( obj.from ).format( 'DD-MM-YYYY' ),
309
308
  },
310
309
  },
311
310
  {
312
- 'terms': {
313
- 'log_subtype.keyword': [ 'Speed_Test' ],
311
+ 'term': {
312
+ 'storeId.keyword': req.body.storeId,
314
313
  },
315
314
  },
316
315
  {
317
- range: {
318
- 'timestamp': {
319
- gte: obj.from,
320
- lte: obj.to,
321
- },
316
+ 'term': {
317
+ 'log_subtype.keyword': 'Speed_Test',
322
318
  },
323
319
  },
324
320
  ],
325
-
326
321
  },
327
322
  },
328
323
  'sort': [
@@ -330,28 +325,41 @@ export async function edgeAppLogTable( req, res ) {
330
325
  ],
331
326
  };
332
327
  let speedTest = await getOpenSearchData( 'edgeapp_systemlogs', internetSpeedQuery );
333
- if ( speedTest.body.hits && speedTest.body.hits.hits.length > 0 && speedTest.body.hits.hits[0]._source ) {
334
- const megabytes = bytesToMB( speedTest.body.hits.hits[0]._source.data.upload_Speed.split( '.' )[0] ).toFixed( 2 );
335
- obj.Internetspeed = megabytes+ ' MB/sec';
328
+ if ( speedTest&& speedTest.body.hits && speedTest.body.hits.hits.length > 0 ) {
329
+ for ( const sourcedata of speedTest.body.hits.hits ) {
330
+ if ( sourcedata._source ) {
331
+ if ( Number( sourcedata._source.data.occuringTime.split( ':' )[0] )==obj.hour ) {
332
+ const megabytes = bytesToMB( sourcedata._source.data.upload_Speed.split( '.' )[0] ).toFixed( 2 );
333
+ obj.Internetspeed = megabytes+ ' MB/sec';
334
+ }
335
+ }
336
+ }
336
337
  } else {
337
338
  obj.Internetspeed = '';
338
339
  }
339
340
  let FileCountQuery = {
341
+ 'size': 1000,
340
342
  'query': {
341
343
  'bool': {
342
344
  'must': [
343
-
344
345
  {
345
346
  'term': {
346
- 'store_id.keyword': req.body.storeId,
347
+ 'log_type.keyword': 'Application',
347
348
  },
348
349
  },
349
350
  {
350
- range: {
351
- 'timestamp': {
352
- gte: obj.from,
353
- lte: obj.to,
354
- },
351
+ 'term': {
352
+ 'store_date.keyword': dayjs( obj.from ).format( 'DD-MM-YYYY' ),
353
+ },
354
+ },
355
+ {
356
+ 'term': {
357
+ 'storeId.keyword': req.body.storeId,
358
+ },
359
+ },
360
+ {
361
+ 'term': {
362
+ 'log_subtype.keyword': 'Zip_File_Count',
355
363
  },
356
364
  },
357
365
  ],
@@ -363,14 +371,23 @@ export async function edgeAppLogTable( req, res ) {
363
371
  { 'timestamp': { 'order': 'desc' } },
364
372
  ],
365
373
  };
366
- let newFilesCount = await getOpenSearchData( 'edgeapp_filelogs', FileCountQuery );
367
-
368
- obj.files_pushed = newFilesCount.body.hits.total.value;
369
- if ( obj.files_pushed > 0 ) {
370
- obj.hourStatus = 'live';
374
+ let newFilesCount = await getOpenSearchData( 'edgeapp_systemlogs', FileCountQuery );
375
+ if ( newFilesCount&& newFilesCount.body.hits && newFilesCount.body.hits.hits.length > 0 ) {
376
+ obj.files_pushed = 0;
377
+ obj.files_genrated = 0;
378
+ for ( let sourcedata of newFilesCount.body.hits.hits ) {
379
+ if ( sourcedata._source ) {
380
+ if ( Number( sourcedata._source.data.occuringTime.split( ':' )[0] )==obj.hour ) {
381
+ obj.files_pushed = obj.files_pushed+Number( sourcedata._source.data.files_pushed );
382
+ obj.files_genrated = obj.files_generated+Number( sourcedata._source.data.files_generated );
383
+ }
384
+ }
385
+ }
371
386
  } else {
372
- obj.hourStatus = 'Not live';
387
+ obj.files_pushed = '';
388
+ obj.files_genrated = '';
373
389
  }
390
+
374
391
  let downTimeQuery = {
375
392
  'size': 1,
376
393
  'query': {
@@ -396,7 +413,7 @@ export async function edgeAppLogTable( req, res ) {
396
413
  },
397
414
  },
398
415
  };
399
- const downtime = await getOpenSearchData( 'live_downtime_hourly', downTimeQuery );
416
+ const downtime = await getOpenSearchData( 'live_downtime_hourly_test1', downTimeQuery );
400
417
  let streamwiseDowntime = downtime.body.hits.hits.length > 0 ? downtime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
401
418
  if ( streamwiseDowntime.length > 0 ) {
402
419
  const sum = streamwiseDowntime.reduce( ( accumulator, currentValue ) => {
@@ -407,44 +424,6 @@ export async function edgeAppLogTable( req, res ) {
407
424
  } else {
408
425
  obj.downtime = '';
409
426
  }
410
- let appStatusQuery = {
411
- 'size': 1,
412
- 'query': {
413
- 'bool': {
414
- 'must': [
415
- {
416
- 'term': {
417
- 'log_type.keyword': 'Application',
418
- },
419
- },
420
- {
421
- 'term': {
422
- 'storeId.keyword': req.body.storeId,
423
- },
424
- },
425
- {
426
- 'terms': {
427
- 'log_subtype.keyword': [ 'Online_Status' ],
428
- },
429
- },
430
- {
431
- range: {
432
- 'timestamp': {
433
- gte: obj.from,
434
- lte: obj.to,
435
- },
436
- },
437
- },
438
- ],
439
-
440
- },
441
- },
442
- 'sort': [
443
- { 'timestamp': { 'order': 'desc' } },
444
- ],
445
- };
446
- const appStatus = await getOpenSearchData( 'edgeapp_systemlogs', appStatusQuery );
447
- obj.appStatus = appStatus.body.hits.hits.length > 0 ? appStatus.body.hits.hits[0]._source.data.message : '';
448
427
  }
449
428
  if ( req.body.export ) {
450
429
  await download( timeSlots, res );
@@ -485,6 +464,16 @@ function generateTimeSlots( startHour, endHour, interval, req ) {
485
464
  }
486
465
  };
487
466
 
467
+ function getTimeDifference( start, end ) {
468
+ console.log( start, end );
469
+ let startTime = new Date( `1970-01-01T${start}Z` );
470
+ let endTime = new Date( `1970-01-01T${end}Z` );
471
+ let differenceInMilliseconds = endTime - startTime;
472
+ let differenceInSeconds = Math.floor( differenceInMilliseconds / 1000 );
473
+ let minutes = Math.floor( differenceInSeconds / 60 );
474
+ let seconds = differenceInSeconds % 60;
475
+ return { minutes, seconds };
476
+ }
488
477
 
489
478
  export async function viewedgeAppLog( req, res ) {
490
479
  try {
@@ -496,13 +485,10 @@ export async function viewedgeAppLog( req, res ) {
496
485
  const fromTime = req.body.from;
497
486
  const toTime = req.body.to;
498
487
  let response = {};
499
- const fromDateTime = dayjs( `${inputDate} ${fromTime}`, 'YYYY-MM-DD hh:mm A' );
500
- const toDateTime = dayjs( `${inputDate} ${toTime}`, 'YYYY-MM-DD hh:mm A' );
501
488
 
502
- const isoFromDateTime = fromDateTime.toISOString();
503
- const isoToDateTime = toDateTime.toISOString();
489
+
504
490
  let appStartTimeQuery = {
505
- 'size': 1,
491
+ 'size': 1000,
506
492
  'query': {
507
493
  'bool': {
508
494
  'must': [
@@ -513,29 +499,26 @@ export async function viewedgeAppLog( req, res ) {
513
499
  },
514
500
  {
515
501
  'term': {
516
- 'storeId.keyword': req.body.storeId,
502
+ 'store_date.keyword': dayjs( inputDate ).format( 'DD-MM-YYYY' ),
517
503
  },
518
504
  },
519
505
  {
520
- 'terms': {
521
- 'log_subtype.keyword': [ 'AppStart_Time' ],
506
+ 'term': {
507
+ 'store_id.keyword': req.body.storeId,
522
508
  },
523
509
  },
524
510
  {
525
- range: {
526
- 'timestamp': {
527
- gte: isoFromDateTime,
528
- lte: isoToDateTime,
529
- },
511
+ 'term': {
512
+ 'log_subtype.keyword': 'AppStart_Time',
530
513
  },
531
514
  },
532
515
  ],
533
516
 
534
517
  },
535
518
  },
536
-
537
519
  };
538
520
  const appStartTime = await getOpenSearchData( 'edgeapp_systemlogs', appStartTimeQuery );
521
+ response.appStartTime = appStartTime.body.hits.hits.length > 0 ? appStartTime.body.hits.hits[0]._source.data.occuringTime : '';
539
522
 
540
523
  let appQuitTimeQuery = {
541
524
  'size': 1,
@@ -549,20 +532,17 @@ export async function viewedgeAppLog( req, res ) {
549
532
  },
550
533
  {
551
534
  'term': {
552
- 'store_id.keyword': req.body.storeId,
535
+ 'store_date.keyword': dayjs( inputDate ).format( 'DD-MM-YYYY' ),
553
536
  },
554
537
  },
555
538
  {
556
- 'terms': {
557
- 'log_subtype.keyword': [ 'App_Quit' ],
539
+ 'term': {
540
+ 'store_id.keyword': req.body.storeId,
558
541
  },
559
542
  },
560
543
  {
561
- range: {
562
- 'timestamp': {
563
- gte: isoFromDateTime,
564
- lte: isoToDateTime,
565
- },
544
+ 'term': {
545
+ 'log_subtype.keyword': 'App_Quit',
566
546
  },
567
547
  },
568
548
  ],
@@ -574,7 +554,13 @@ export async function viewedgeAppLog( req, res ) {
574
554
  ],
575
555
  };
576
556
  const appQuitTime = await getOpenSearchData( 'edgeapp_systemlogs', appQuitTimeQuery );
577
-
557
+ if ( appQuitTime.body.hits.hits&&appQuitTime.body.hits.hits.length > 0 ) {
558
+ for ( const sourceData of appQuitTime.body.hits.hits ) {
559
+ if ( Number( sourceData._source.data.occuringTime.split( ':' )[0] )== Number( fromTime.split( ':' )[0] ) ) {
560
+ response.appQuitTime = appQuitTime.body.hits.hits.length > 0 ? sourceData._source.data.occuringTime : '';
561
+ }
562
+ }
563
+ }
578
564
  let appCrashTimeQuery = {
579
565
  'size': 1,
580
566
  'query': {
@@ -587,20 +573,17 @@ export async function viewedgeAppLog( req, res ) {
587
573
  },
588
574
  {
589
575
  'term': {
590
- 'store_id.keyword': req.body.storeId,
576
+ 'store_date.keyword': dayjs( inputDate ).format( 'DD-MM-YYYY' ),
591
577
  },
592
578
  },
593
579
  {
594
- 'terms': {
595
- 'log_subtype.keyword': [ 'App_Crash' ],
580
+ 'term': {
581
+ 'store_id.keyword': req.body.storeId,
596
582
  },
597
583
  },
598
584
  {
599
- range: {
600
- 'timestamp': {
601
- gte: isoFromDateTime,
602
- lte: isoToDateTime,
603
- },
585
+ 'term': {
586
+ 'log_subtype.keyword': 'App_Crash',
604
587
  },
605
588
  },
606
589
  ],
@@ -611,9 +594,17 @@ export async function viewedgeAppLog( req, res ) {
611
594
  { 'timestamp': { 'order': 'desc' } },
612
595
  ],
613
596
  };
597
+
614
598
  const appCrashTime = await getOpenSearchData( 'edgeapp_systemlogs', appCrashTimeQuery );
599
+ if ( appCrashTime.body.hits.hits&&appCrashTime.body.hits.hits.length > 0 ) {
600
+ for ( const sourceData of appCrashTime.body.hits.hits ) {
601
+ if ( Number( sourceData._source.data.occuringTime.split( ':' )[0] )== Number( fromTime.split( ':' )[0] ) ) {
602
+ response.AppCrashtime = appCrashTime.body.hits.hits.length > 0 ? sourceData._source.data.occuringTime : '';
603
+ }
604
+ }
605
+ }
615
606
  const screenStatus = await getOpenSearchData( 'edgeapp_systemlogs', {
616
-
607
+ 'size': 1000,
617
608
  'query': {
618
609
  'bool': {
619
610
  'must': [
@@ -624,20 +615,17 @@ export async function viewedgeAppLog( req, res ) {
624
615
  },
625
616
  {
626
617
  'term': {
627
- 'storeId.keyword': req.body.storeId,
618
+ 'store_date.keyword': dayjs( inputDate ).format( 'DD-MM-YYYY' ),
628
619
  },
629
620
  },
630
621
  {
631
- 'terms': {
632
- 'log_subtype.keyword': [ 'System_Status' ],
622
+ 'term': {
623
+ 'store_id.keyword': req.body.storeId,
633
624
  },
634
625
  },
635
626
  {
636
- range: {
637
- 'timestamp': {
638
- gte: isoFromDateTime,
639
- lte: isoToDateTime,
640
- },
627
+ 'term': {
628
+ 'log_subtype.keyword': 'System_Status',
641
629
  },
642
630
  },
643
631
  ],
@@ -645,12 +633,42 @@ export async function viewedgeAppLog( req, res ) {
645
633
  },
646
634
  },
647
635
  'sort': [
648
- { 'timestamp': { 'order': 'desc' } },
636
+ { 'timestamp': { 'order': 'asc' } },
649
637
  ],
650
638
 
651
639
  } );
652
- const appStatus = await getOpenSearchData( 'edgeapp_systemlogs', {
653
- 'size': 1,
640
+ if ( screenStatus&& screenStatus.body.hits.hits&&screenStatus.body.hits.hits.length > 0 ) {
641
+ console.log( '==========', screenStatus.body.hits.hits.length );
642
+ let suspendedTime;
643
+ let resumedTime;
644
+ const differences = [];
645
+
646
+ for ( const sourceData of screenStatus.body.hits.hits ) {
647
+ console.log( sourceData._source.data.occuringTime );
648
+ if ( Number( sourceData._source.data.occuringTime.split( ':' )[0] )== Number( fromTime.split( ':' )[0] ) ) {
649
+ if ( sourceData._source.data.message.trim() === 'SYSTEM SUSPENDED' ) {
650
+ suspendedTime = sourceData._source.data.occuringTime;
651
+ } else if ( sourceData._source.data.message.trim() === 'SYSTEM RESUMED' ) {
652
+ resumedTime = sourceData._source.data.occuringTime;
653
+ if ( suspendedTime ) {
654
+ const difference = getTimeDifference( suspendedTime, resumedTime );
655
+ differences.push( difference );
656
+ suspendedTime = null;
657
+ }
658
+ } else {
659
+ if ( suspendedTime ) {
660
+ const difference = getTimeDifference( suspendedTime, `${toTime}:00` );
661
+ differences.push( difference );
662
+ suspendedTime = null;
663
+ }
664
+ }
665
+ }
666
+ }
667
+ console.log( differences );
668
+ response.screenStatus = differences.length>0?`${differences[0].minutes}Mins ${differences[0].seconds}Sec`:'';
669
+ }
670
+ const FileCountQuery = {
671
+ 'size': 1000,
654
672
  'query': {
655
673
  'bool': {
656
674
  'must': [
@@ -661,97 +679,45 @@ export async function viewedgeAppLog( req, res ) {
661
679
  },
662
680
  {
663
681
  'term': {
664
- 'store_id.keyword': req.body.storeId,
682
+ 'store_date.keyword': dayjs( inputDate ).format( 'DD-MM-YYYY' ),
665
683
  },
666
684
  },
667
685
  {
668
- 'terms': {
669
- 'log_subtype.keyword': [ 'Online_Status' ],
686
+ 'term': {
687
+ 'storeId.keyword': req.body.storeId,
670
688
  },
671
689
  },
672
690
  {
673
- range: {
674
- 'timestamp': {
675
- gte: isoFromDateTime,
676
- lte: isoToDateTime,
677
- },
691
+ 'term': {
692
+ 'log_subtype.keyword': 'Zip_File_Count',
678
693
  },
679
694
  },
680
695
  ],
681
696
 
682
697
  },
683
698
  },
699
+
684
700
  'sort': [
685
701
  { 'timestamp': { 'order': 'desc' } },
686
702
  ],
687
- } );
688
-
689
- const newFilesCount = await getOpenSearchData( 'edgeapp_filelogs',
690
- {
691
- // 'size': 1,
692
- 'query': {
693
- 'bool': {
694
- 'must': [
695
- {
696
- 'term': {
697
- 'store_id.keyword': req.body.storeId,
698
- },
699
- },
700
- {
701
- range: {
702
- 'timestamp': {
703
- gte: isoFromDateTime,
704
- lte: isoToDateTime,
705
- },
706
- },
707
- },
708
- ],
709
-
710
- },
711
- },
712
-
713
- 'sort': [
714
- { 'timestamp': { 'order': 'desc' } },
715
- ],
716
- } );
717
- const speedTest = await getOpenSearchData( 'edgeapp_systemlogs',
718
- {
719
- 'size': 1,
720
- 'query': {
721
- 'bool': {
722
- 'must': [
723
- {
724
- 'term': {
725
- 'log_type.keyword': 'Application',
726
- },
727
- },
728
- {
729
- 'term': {
730
- 'storeId.keyword': req.body.storeId,
731
- },
732
- },
733
- {
734
- 'terms': {
735
- 'log_subtype.keyword': [ 'Speed_Test' ],
736
- },
737
- },
738
- {
739
- range: {
740
- 'timestamp': {
741
- gte: isoFromDateTime,
742
- lte: isoToDateTime,
743
- },
744
- },
745
- },
746
- ],
703
+ };
704
+ const newFilesCount = await getOpenSearchData( 'edgeapp_systemlogs', FileCountQuery );
705
+ if ( newFilesCount&& newFilesCount.body.hits && newFilesCount.body.hits.hits.length > 0 ) {
706
+ response.files_pushed = 0;
707
+ response.files_genrated = 0;
708
+ for ( const sourcedata of newFilesCount.body.hits.hits ) {
709
+ if ( sourcedata._source ) {
710
+ if ( Number( sourcedata._source.data.occuringTime.split( ':' )[0] )==response.hour ) {
711
+ response.files_pushed = response.files_pushed+Number( sourcedata._source.data.files_pushed );
712
+ response.files_genrated = response.files_generated+Number( sourcedata._source.data.files_generated );
713
+ }
714
+ }
715
+ }
716
+ } else {
717
+ response.files_pushed = '';
718
+ response.files_genrated = '';
719
+ }
747
720
 
748
- },
749
- },
750
- 'sort': [
751
- { 'timestamp': { 'order': 'desc' } },
752
- ],
753
- },
754
- );
755
721
 
756
722
  const antiVirus = await getOpenSearchData( 'edgeapp_systemlogs', {
757
723
  'size': 1,
@@ -769,16 +735,13 @@ export async function viewedgeAppLog( req, res ) {
769
735
  },
770
736
  },
771
737
  {
772
- 'terms': {
773
- 'log_subtype.keyword': [ 'Anti_Virus' ],
738
+ 'term': {
739
+ 'store_date.keyword': dayjs( inputDate ).format( 'DD-MM-YYYY' ),
774
740
  },
775
741
  },
776
742
  {
777
- range: {
778
- 'timestamp': {
779
- gte: isoFromDateTime,
780
- lte: isoToDateTime,
781
- },
743
+ 'term': {
744
+ 'log_subtype.keyword': 'Anti_Virus',
782
745
  },
783
746
  },
784
747
  ],
@@ -790,57 +753,9 @@ export async function viewedgeAppLog( req, res ) {
790
753
  ],
791
754
  },
792
755
  );
793
- const downTime = await getOpenSearchData( 'live_downtime_hourly',
794
- {
795
- 'size': 1,
796
- 'query': {
797
- 'bool': {
798
- 'must': [
799
- {
800
- 'term': {
801
- 'doc.date.keyword': dayjs( req.body.Date ).format( 'DD-MM-YYYY' ),
802
- },
803
- },
804
- {
805
- 'term': {
806
- 'doc.store_id.keyword': req.body.storeId,
807
- },
808
- },
809
- {
810
- 'terms': {
811
- 'doc.hour.keyword': [ req.body.from.split( ':' )[0] ],
812
- },
813
- },
814
- ],
815
-
816
- },
817
- },
756
+ response.antiVirus = antiVirus.body.hits.hits.length > 0 && antiVirus.body.hits.hits[0]._source.data.message == 'st-launch-1.0.exe is deleted' ? antiVirus.body.hits.hits[0]._source.data.occuringTime : '';
818
757
 
819
- } );
820
- let streamwiseDowntime = downTime.body.hits.hits.length > 0 ? downTime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
821
- if ( streamwiseDowntime.length > 0 ) {
822
- const sum = streamwiseDowntime.reduce( ( accumulator, currentValue ) => {
823
- return accumulator + currentValue.down_time;
824
- }, 0 );
825
758
 
826
- // Calculate the average
827
- const average = sum / streamwiseDowntime.length;
828
- response.downTime = Math.round( average );
829
- } else {
830
- response.downTime = 0;
831
- }
832
- response.filesPushed = newFilesCount.body.hits.total.value;
833
- if ( speedTest.body.hits && speedTest.body.hits.hits.length > 0 && speedTest.body.hits.hits[0]._source ) {
834
- response.Internetspeed = speedTest.body.hits.hits[0]._source.data.upload_Speed;
835
- } else {
836
- response.Internetspeed = '';
837
- }
838
- response.antiVirus = antiVirus.body.hits.hits.length > 0 && antiVirus.body.hits.hits[0]._source.data.message == 'st-launch-1.0.exe is deleted' ? antiVirus.body.hits.hits[0]._source.data.occuringTime : '';
839
- response.appStartTime = appStartTime.body.hits.hits.length > 0 ? appStartTime.body.hits.hits[0]._source.data.occuringTime : '';
840
- response.appQuitTime = appQuitTime.body.hits.hits.length > 0 ? appQuitTime.body.hits.hits[0]._source.data.occuringTime : '';
841
- response.AppCrashtime = appCrashTime.body.hits.hits.length > 0 ? appCrashTime.body.hits.hits[0]._source.data.occuringTime : '';
842
- response.screenStatus = screenStatus.body.hits.hits.length > 0 ? screenStatus.body.hits.hits[0]._source.data.message : '';
843
- response.appStatus = appStatus.body.hits.hits.length > 0 ? appStatus.body.hits.hits[0]._source.data.message : '';
844
759
  res.sendSuccess( response );
845
760
  } catch ( error ) {
846
761
  logger.error( { error: error, function: 'viewedgeAppLog' } );
@@ -909,9 +824,9 @@ export async function cameraAngleChange( req, res ) {
909
824
  }
910
825
  }
911
826
  function getDatesArray( fromDate, toDate ) {
912
- let dates = [];
913
- let currentDate = new Date( fromDate );
914
- let endDate = new Date( toDate );
827
+ const dates = [];
828
+ const currentDate = new Date( fromDate );
829
+ const endDate = new Date( toDate );
915
830
 
916
831
  while ( currentDate <= endDate ) {
917
832
  dates.push( currentDate.toISOString().split( 'T' )[0] ); // Convert Date to string format YYYY-MM-DD
@@ -994,7 +909,7 @@ export async function streamwiseDowntime( req, res ) {
994
909
  },
995
910
  },
996
911
  };
997
- const downtime = await getOpenSearchData( 'live_downtime_hourly', downTimeQuery );
912
+ const downtime = await getOpenSearchData( 'live_downtime_hourly_test1', downTimeQuery );
998
913
 
999
914
  let streamwiseDowntime = downtime.body.hits.hits.length > 0 ? downtime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
1000
915
  if ( streamwiseDowntime.length > 0 ) {
@@ -1051,7 +966,7 @@ export async function livecountCheck( inputData, req ) {
1051
966
  },
1052
967
  },
1053
968
  };
1054
- const downtime = await getOpenSearchData( 'live_downtime_hourly', downTimeQuery );
969
+ const downtime = await getOpenSearchData( 'live_downtime_hourly_test1', downTimeQuery );
1055
970
  let streamwiseDowntime = downtime.body.hits.hits.length > 0 ? downtime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
1056
971
  if ( streamwiseDowntime.length > 0 ) {
1057
972
  const sum = streamwiseDowntime.reduce( ( accumulator, currentValue ) => {