tango-app-api-infra 3.0.108-dev → 3.0.109-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.108-dev",
3
+ "version": "3.0.109-dev",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -314,21 +314,20 @@ export async function installationCard( req, res ) {
314
314
  export async function infraIssuesTable( req, res ) {
315
315
  try {
316
316
  let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
317
- let issueStatus = [ 'identified' ];
317
+ let issueStatus = [ 'notidentified', 'identified' ];
318
+
318
319
  if ( req.body.infrafilterIssue == 'Issues Not Identified' ) {
319
320
  issueStatus = [ 'notidentified' ];
320
321
  };
321
- if ( req.body.infrafilterIssue == 'All Issues' ) {
322
- issueStatus = [ 'notidentified', 'identified' ];
323
- };
324
- if ( req.body.infrafilterIssue == 'Live Stores' ) {
325
- issueStatus = [ 'notidentified', 'identified' ];
322
+ if ( req.body.infrafilterIssue == 'Identified Issues' ) {
323
+ issueStatus = [ 'identified' ];
326
324
  };
325
+
326
+
327
327
  let totalstores = await aggregateStore( [ {
328
328
  $match: {
329
329
  '$and': [
330
330
  { 'clientId': { $in: req.body.clientId } },
331
- { 'edge.firstFile': true },
332
331
  { 'status': 'active' },
333
332
  { 'createdAt': { $lte: date.end } },
334
333
  ],
@@ -338,6 +337,23 @@ export async function infraIssuesTable( req, res ) {
338
337
  for ( let store of totalstores ) {
339
338
  totalnumberstores.push( store.storeId );
340
339
  }
340
+ let pendingquery = [];
341
+ pendingquery.push( {
342
+ $match: {
343
+ $and: [
344
+ { issueType: 'installation' },
345
+ { 'status': { $ne: 'closed' } },
346
+ { 'basicDetails.clientId': { $in: req.body.clientId } },
347
+ { createdAt: { $lte: date.end } },
348
+ ],
349
+ },
350
+ } );
351
+ let pendingstorecount = await aggregateTangoTicket( pendingquery );
352
+ let installpendingticket = [];
353
+ for ( let store of pendingstorecount ) {
354
+ installpendingticket.push( store.basicDetails.storeId );
355
+ }
356
+
341
357
  let query = [ {
342
358
  $match: {
343
359
  $and: [
@@ -346,7 +362,6 @@ export async function infraIssuesTable( req, res ) {
346
362
  { 'basicDetails.clientId': { $in: req.body.clientId } },
347
363
  { 'basicDetails.storeId': { $in: totalnumberstores } },
348
364
  { 'ticketDetails.issueStatus': { $in: issueStatus } },
349
- // { createdAt: { $gte: date.start } },
350
365
  { createdAt: { $lte: date.end } },
351
366
  ],
352
367
  },
@@ -426,8 +441,8 @@ export async function infraIssuesTable( req, res ) {
426
441
  $match: {
427
442
  '$and': [
428
443
  { 'clientId': { $in: req.body.clientId } },
429
- { 'edge.firstFile': true },
430
444
  { 'status': 'active' },
445
+ { 'storeId': { $nin: installpendingticket } },
431
446
  { 'createdAt': { $lte: date.end } },
432
447
  ],
433
448
  },
@@ -442,7 +457,7 @@ export async function infraIssuesTable( req, res ) {
442
457
  }
443
458
  let result = [];
444
459
  for ( let data of totalnumberstores ) {
445
- if ( infraissueStore.length > 0 && !infraissueStore.includes( data ) ) {
460
+ if ( infraissueStore.length > 0 && !infraissueStore.includes( data )&&!installpendingticket.includes( data ) ) {
446
461
  result.push( data );
447
462
  }
448
463
  }
@@ -563,15 +578,24 @@ export async function infraIssuesTable( req, res ) {
563
578
  if ( req.body.export && result.length > 0 ) {
564
579
  const exportdata = [];
565
580
  result.forEach( ( element ) => {
566
- exportdata.push( {
567
- 'Created On': element.createdAt,
568
- 'StoreID': element.storeId,
569
- 'StoreName': element.storeName,
570
- 'Primary Issue': element.primaryIssue,
571
- 'Sub Issue': element.secondaryIssue,
572
- 'Issue Identified on': element.issueIdentifiedDate? dayjs( element.issueIdentifiedDate ).tz( 'Asia/Kolkata' ).format( 'YYYY-MM-DD HH:mm A' ):'',
573
- 'Status': element.status,
574
- } );
581
+ if ( req.body.infrafilterIssue == 'Live Stores' || req.body.infrafilterIssue == 'Total Stores' ) {
582
+ exportdata.push( {
583
+ 'Created On': element.createdAt,
584
+ 'StoreID': element.storeId,
585
+ 'StoreName': element.storeName,
586
+ 'Status': element.status,
587
+ } );
588
+ } else {
589
+ exportdata.push( {
590
+ 'Created On': element.createdAt,
591
+ 'StoreID': element.storeId,
592
+ 'StoreName': element.storeName,
593
+ 'Primary Issue': element.primaryIssue,
594
+ 'Sub Issue': element.secondaryIssue,
595
+ 'Issue Identified on': element.issueIdentifiedDate? dayjs( element.issueIdentifiedDate ).tz( 'Asia/Kolkata' ).format( 'YYYY-MM-DD HH:mm A' ):'',
596
+ 'Status': element.status,
597
+ } );
598
+ }
575
599
  } );
576
600
  await download( exportdata, res );
577
601
  return;