tango-app-api-infra 3.0.89-dev → 3.0.90-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.89-dev",
3
+ "version": "3.0.90-dev",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -134,10 +134,15 @@ export async function infraCard( req, res ) {
134
134
  count: 0,
135
135
  } ) );
136
136
  }
137
+
137
138
  response.unshift( {
138
- name: 'All Issues',
139
+ name: 'Identified Issues',
139
140
  count: infraStoreCount.length > 0 ? infraStoreCount[0].identifiedcount : 0,
140
141
  } );
142
+ response.unshift( {
143
+ name: 'All Issues',
144
+ count: infraStoreCount.length > 0 ? infraStoreCount[0].infraCount : 0,
145
+ } );
141
146
  response.push( {
142
147
  name: 'Issues Not Identified',
143
148
  count: infraStoreCount.length > 0 ? infraStoreCount[0].infraCount - infraStoreCount[0].identifiedcount : 0,
@@ -279,9 +284,12 @@ export async function installationCard( req, res ) {
279
284
  export async function infraIssuesTable( req, res ) {
280
285
  try {
281
286
  let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
282
- let issueStatus = 'identified';
287
+ let issueStatus = [ 'identified' ];
283
288
  if ( req.body.filterIssue == 'Issues Not Identified' ) {
284
- issueStatus = 'notidentified';
289
+ issueStatus = [ 'notidentified' ];
290
+ };
291
+ if ( req.body.filterIssue == 'All Issues' ) {
292
+ issueStatus = [ 'notidentified', 'identified' ];
285
293
  };
286
294
  let query = [ {
287
295
  $match: {
@@ -289,7 +297,7 @@ export async function infraIssuesTable( req, res ) {
289
297
  { issueType: 'infra' },
290
298
  { status: { $ne: 'closed' } },
291
299
  { 'basicDetails.clientId': { $in: req.body.clientId } },
292
- { 'ticketDetails.issueStatus': issueStatus },
300
+ { 'ticketDetails.issueStatus': { $in: issueStatus } },
293
301
  // { createdAt: { $gte: date.start } },
294
302
  { createdAt: { $lte: date.end } },
295
303
  ],
@@ -361,7 +369,7 @@ export async function infraIssuesTable( req, res ) {
361
369
  },
362
370
  },
363
371
  ];
364
- if ( req.body.filterIssue && req.body.filterIssue != '' && req.body.filterIssue != 'All Issues' && req.body.filterIssue != 'Issues Not Identified' ) {
372
+ if ( req.body.filterIssue && req.body.filterIssue != '' && req.body.filterIssue != 'Identified Issues' && req.body.filterIssue != 'Issues Not Identified'&&req.body.filterIssue != 'All Issues' ) {
365
373
  query.push( {
366
374
  $match: {
367
375
  primaryIssue: req.body.filterIssue,
@@ -393,6 +401,7 @@ export async function infraIssuesTable( req, res ) {
393
401
  } );
394
402
  }
395
403
  let count = await aggregateTangoTicket( query );
404
+ console.log( count.length );
396
405
  if ( req.body.limit && req.body.offset && !req.body.export ) {
397
406
  query.push(
398
407
  { $skip: ( req.body.offset - 1 ) * req.body.limit },
@@ -407,9 +416,9 @@ export async function infraIssuesTable( req, res ) {
407
416
  'CREATED AT': element.createdAt,
408
417
  'STORE ID': element.storeId,
409
418
  'STORE NAME': element.storeName,
419
+ 'PRIMARY ISSUE': element.primaryIssue,
410
420
  'SUB ISSUE': element.secondaryIssue,
411
- 'ISSUE IDENTIFIED ON': element.issueIdentifiedDate,
412
- 'ISSUE CLOSED ON': element.issueClosedDate,
421
+ 'ISSUE IDENTIFIED ON': dayjs( element.issueIdentifiedDate ).tz( 'Asia/Kolkata' ).format( 'YYYY-MM-DD HH:mm A' ),
413
422
  'STATUS': element.status,
414
423
  } );
415
424
  } );
@@ -709,12 +718,20 @@ export async function hourWiseDownstores( req, res ) {
709
718
  try {
710
719
  let inputData = req.body;
711
720
  inputData.Date = dayjs( req.body.toDate ).format( 'YYYY-MM-DD' );
712
-
721
+ let issueStatus = [ 'identified' ];
722
+ if ( req.body.filterIssue == 'Issues Not Identified' ) {
723
+ issueStatus = [ 'notidentified' ];
724
+ };
725
+ if ( req.body.filterIssue == 'All Issues' ) {
726
+ issueStatus = [ 'notidentified', 'identified' ];
727
+ };
713
728
  let query = [ {
714
729
  $match: {
715
730
  $and: [
716
731
  { 'basicDetails.clientId': req.body.clientId },
717
732
  { 'status': { $ne: 'closed' } },
733
+ { issueType: 'infra' },
734
+ { 'ticketDetails.issueStatus': { $in: issueStatus } },
718
735
  { 'issueDate': { $lte: new Date( req.body.toDate ) } },
719
736
  ],
720
737
  },
@@ -773,7 +790,7 @@ export async function hourWiseDownstores( req, res ) {
773
790
  $sort: { [req.body.sortColumName]: req.body.sortBy },
774
791
  } );
775
792
  }
776
- if ( req.body.filterIssue && req.body.filterIssue != '' && req.body.filterIssue != 'All Issues' && req.body.filterIssue != 'Issues Not Identified' ) {
793
+ if ( req.body.filterIssue && req.body.filterIssue != '' && req.body.filterIssue != 'Identified Issues' && req.body.filterIssue != 'Issues Not Identified'&&req.body.filterIssue != 'All Issues' ) {
777
794
  query.push( {
778
795
  $match: {
779
796
  primaryIssue: req.body.filterIssue,
@@ -3,9 +3,9 @@
3
3
  import { aggregateTangoTicket, createTangoTicket, findOneTangoTicket, updateOneTangoTicket, updateManyTangoTicket, findTangoTicket } from '../services/tangoTicket.service.js';
4
4
  import { createinfraReason, findinfraReason } from '../services/infraReason.service.js';
5
5
  import { updateOneStore, findStore } from '../services/store.service.js';
6
- import { logger, fileUpload, signedUrl, sendEmailWithSES, getOpenSearchData, download, appConfig, getUTC } from 'tango-app-api-middleware';
6
+ import { logger, fileUpload, signedUrl, sendEmailWithSES, getOpenSearchData, insertOpenSearchData, download, appConfig, getUTC } from 'tango-app-api-middleware';
7
7
  import { aggregateUser, updateOneUser } from '../services/user.service.js';
8
- import { updateoneClient } from '../services/client.service.js';
8
+ import { findOneClient, updateoneClient } from '../services/client.service.js';
9
9
  import dayjs from 'dayjs';
10
10
  import { readFileSync } from 'fs';
11
11
  import { join } from 'path';
@@ -518,7 +518,7 @@ export async function emailUserList( req, res ) {
518
518
  export async function saveInfraEmailConfig( req, res ) {
519
519
  try {
520
520
  let inputData = req.body;
521
-
521
+ let client = await findOneClient( { clientId: inputData.clientId } );
522
522
  await updateoneClient( { clientId: inputData.clientId }, {
523
523
  'ticketConfigs.infraReport': {
524
524
  start: inputData.start,
@@ -535,6 +535,29 @@ export async function saveInfraEmailConfig( req, res ) {
535
535
  } );
536
536
  }
537
537
  }
538
+
539
+ const logObj = {
540
+ clientId: inputData.clientId,
541
+ userName: req.user?.userName,
542
+ email: req.user?.email,
543
+ date: new Date(),
544
+ logType: 'configuration',
545
+ logSubType: 'emailConfig',
546
+ eventType: 'update',
547
+ showTo: [ 'tango' ],
548
+ changes: [ `Email Config` ],
549
+ previous: client.ticketConfigs.infraReport,
550
+ current: {
551
+ infraReport: {
552
+ start: inputData.start,
553
+ end: inputData.end,
554
+ },
555
+ },
556
+ };
557
+
558
+ await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
559
+
560
+
538
561
  res.sendSuccess( 'Updated Successfully' );
539
562
  } catch ( error ) {
540
563
  logger.error( { error: error, function: 'emailUserList' } );