tango-app-api-infra 3.0.43-dev → 3.0.44-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.43-dev",
3
+ "version": "3.0.44-dev",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -10,7 +10,7 @@ import handlebars from 'handlebars';
10
10
  dayjs.extend( utc );
11
11
  dayjs.extend( timezone );
12
12
  import { sendEmailWithSES } from 'tango-app-api-middleware';
13
- import { createClient, findClient, aggregateClient } from '../services/client.service.js';
13
+ import { createClient, findClient, aggregateClient, findOneClient } from '../services/client.service.js';
14
14
  import { createStore, findStore, updateOneStore, findOneStore } from '../services/store.service.js';
15
15
  import { findTangoTicket, findOneTangoTicket, countDocumentsTangoTicket, aggregateTangoTicket, updateOneTangoTicket } from '../services/tangoTicket.service.js';
16
16
  import { findOneGroup } from '../services/group.service.js';
@@ -435,17 +435,15 @@ export async function infraReportSent( req, res ) {
435
435
  let date;
436
436
  if ( req.body.type == 'start' ) {
437
437
  date = dayjs().subtract( 1, 'day' ).format( 'YYYY-MM-DD' );
438
- } else if ( req.body.storeList == 'start' ) {
438
+ } else if ( req.body.type == 'end' ) {
439
439
  date = dayjs().format( 'YYYY-MM-DD' );
440
440
  };
441
-
442
441
  let query = [ {
443
442
  $match: {
444
443
  $and: [
445
444
  { issueDate: new Date( date ) },
446
445
  { 'basicDetails.storeId': { $in: req.body.storeList } },
447
446
  { issueType: 'infra' },
448
- { 'ticketDetails.issueStatus': 'identified' },
449
447
  ],
450
448
  },
451
449
  },
@@ -530,57 +528,16 @@ export async function infraReportSent( req, res ) {
530
528
  'Activity Log': '',
531
529
  } );
532
530
  }
533
- let issueCount = await countDocumentsTangoTicket( {
534
531
 
532
+ let issueCount = await countDocumentsTangoTicket( {
535
533
  $and: [
536
534
  { issueDate: new Date( date ) },
537
535
  { 'basicDetails.storeId': { $in: req.body.storeList } },
538
536
  { issueType: 'infra' },
539
- { 'ticketDetails.issueStatus': 'identified' },
540
537
  ],
541
-
542
538
  } );
543
- let finalcount = 0;
544
- for ( let storedata of req.body.storeList ) {
545
- let downTimeQuery = {
546
- 'size': 1,
547
- 'query': {
548
- 'bool': {
549
- 'must': [
550
- {
551
- 'term': {
552
- 'doc.date.keyword': dayjs( date ).format( 'DD-MM-YYYY' ),
553
- },
554
- },
555
- {
556
- 'term': {
557
- 'doc.store_id.keyword': storedata,
558
- },
559
- },
560
-
561
- ],
562
-
563
- },
564
- },
565
- };
566
- let downtimetotal;
567
- const downtime = await getOpenSearchData( 'live_downtime_hourly', downTimeQuery );
568
- let streamwiseDowntime = downtime.body.hits.hits.length > 0 ? downtime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
569
- if ( streamwiseDowntime.length > 0 ) {
570
- const sum = streamwiseDowntime.reduce( ( accumulator, currentValue ) => {
571
- return accumulator + currentValue.down_time;
572
- }, 0 );
573
- const average = sum / streamwiseDowntime.length;
574
- downtimetotal = Math.round( average );
575
- } else {
576
- downtimetotal = 0;
577
- }
578
-
579
- finalcount = finalcount + downtimetotal;
580
- }
581
- let avgDownTime = Math.round( finalcount / req.body.storeList.length );
582
-
583
-
539
+ let client = await findOneClient( { clientId: req.body.clientId } );
540
+ let avgDownTime = client.ticketConfigs.infraDownTime*60;
584
541
  let issueList = await findinfraReason( { parentId: { '$exists': false } } );
585
542
  const categoryCounts = {};
586
543
  let response;