tango-app-api-infra 3.0.53-dev → 3.1.1

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.53-dev",
3
+ "version": "3.1.1",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -24,8 +24,8 @@
24
24
  "html-pdf-node": "^1.0.8",
25
25
  "mongodb": "^6.4.0",
26
26
  "nodemon": "^3.1.0",
27
- "tango-api-schema": "^2.0.77",
28
- "tango-app-api-middleware": "^1.0.54-dev",
27
+ "tango-api-schema": "^2.0.90",
28
+ "tango-app-api-middleware": "^3.1.3",
29
29
  "winston": "^3.12.0",
30
30
  "winston-daily-rotate-file": "^5.0.0"
31
31
  },
@@ -207,9 +207,19 @@ export async function installationCard( req, res ) {
207
207
  issueIdentifiedBy: 1,
208
208
  primaryIssue: '$primaryIssue.reasons.primaryIssue',
209
209
  },
210
+ }, {
211
+ $group: {
212
+ _id: '$ticketId',
213
+ ticketId: { $first: '$ticketId' },
214
+ issueStatus: { $first: '$issueStatus' },
215
+ ticketType: { $first: '$ticketType' },
216
+ issueIdentifiedBy: { $first: '$issueIdentifiedBy' },
217
+ primaryIssue: { $first: '$primaryIssue' },
218
+ },
210
219
  },
211
220
  ];
212
221
  let installFailedCount = await aggregateTangoTicket( query );
222
+
213
223
  let issueList = await findinfraReason( { parentId: { '$exists': false } } );
214
224
  const categoryCounts = {};
215
225
  let response;
@@ -443,6 +453,18 @@ export async function InstallationIssuesTable( req, res ) {
443
453
  primaryIssue: { $ifNull: [ '$primaryIssue.reasons.primaryIssue', '-' ] },
444
454
  },
445
455
  },
456
+ {
457
+ $group: {
458
+ _id: '$storeId',
459
+ createdAt: { $first: '$createdAt' },
460
+ clientName: { $first: '$clientName' },
461
+ storeId: { $first: '$storeId' },
462
+ clientId: { $first: '$clientId' },
463
+ storeName: { $first: '$storeName' },
464
+ status: { $first: '$status' },
465
+ primaryIssue: { $first: '$primaryIssue' },
466
+ },
467
+ },
446
468
  ];
447
469
  if ( req.body.searchValue && req.body.searchValue !== '' ) {
448
470
  query.push( {
@@ -75,7 +75,7 @@ export async function createTicket( req, res ) {
75
75
  let Uidomain = `${appConfig.url.domain}/manage/stores/infra-ticket?storeId=${req.body.basicDetails.storeId}`;
76
76
 
77
77
  const html = htmlContent( { ...req.body, Uidomain: Uidomain, domain: appConfig.url.apiDomain, date: dayjs( req.body.issueDate ).format( 'YYYY-MM-DD' ), downtimetotal: downtimetotal, Timestamp: Timestamp } );
78
- if ( req.body.spocEmail&&req.body.issueType == 'infra'&&isValidEmail( req.body.spocEmail ) ) {
78
+ if ( req.body.emailAlert&&req.body.spocEmail&&req.body.issueType == 'infra'&&isValidEmail( req.body.spocEmail ) ) {
79
79
  await sendEmailWithSES( req.body.spocEmail, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
80
80
  }
81
81
  if ( create ) {
@@ -288,7 +288,7 @@ export async function viewTicket( req, res ) {
288
288
  if ( ticket.attachments.hasOwnProperty( index ) ) {
289
289
  let file = ticket.attachments[index];
290
290
  let params = {
291
- Bucket: 'tango-client-sandbox',
291
+ Bucket: appConfig.cloud.aws.bucket.ticket,
292
292
  file_path: file.filePath,
293
293
  };
294
294
  let attachments = await signedUrl( params );
@@ -340,7 +340,7 @@ export async function uploadAttachments( req, res ) {
340
340
  for ( let singleImg in req.files.img ) {
341
341
  if ( req.files.img.hasOwnProperty( singleImg ) ) {
342
342
  let params = {
343
- Bucket: 'tango-client-sandbox',
343
+ Bucket: appConfig.cloud.aws.bucket.ticket,
344
344
  Key: req.params.ticketId + '/',
345
345
  ContentType: 'multipart/form-data',
346
346
  body: req.files.img[singleImg].data,
@@ -364,7 +364,7 @@ export async function uploadAttachments( req, res ) {
364
364
  let oldticket = await findOneTangoTicket( { ticketId: req.params.ticketId } );
365
365
  let attachments = oldticket.attachments;
366
366
  let params = {
367
- Bucket: 'tango-client-sandbox',
367
+ Bucket: appConfig.cloud.aws.bucket.ticket,
368
368
  Key: req.params.ticketId + '/',
369
369
  ContentType: 'multipart/form-data',
370
370
  body: req.files.img.data,
@@ -200,8 +200,9 @@ export async function updateRefreshTicket( req, res ) {
200
200
  primaryIssue = Issue[0].reasons[0].primaryIssue;
201
201
  }
202
202
  let Uidomain = `${appConfig.url.domain}/manage/stores/infra-ticket?storeId=${getTicket.basicDetails.storeId}`;
203
+ let getclient = await findOneClient( { clientId: getTicket.basicDetails.clientId } );
203
204
  const html = htmlContent( { ...getTicket, Uidomain: Uidomain, primary: primaryIssue, storeName: getTicket.basicDetails.storeName, hibernation: '', spocName: spocName, date: dayjs( getTicket.issueDate ).format( 'YYYY-MM-DD' ), downtimetotal: downtimetotal, Timestamp: Timestamp, domain: appConfig.url.apiDomain } );
204
- if ( spocEmail && isValidEmail( spocEmail ) ) {
205
+ if ( getclient.ticketConfigs.emailAlert&&spocEmail && isValidEmail( spocEmail ) ) {
205
206
  await sendEmailWithSES( spocEmail, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
206
207
  }
207
208
  }
@@ -282,8 +283,9 @@ export async function closeTicket( req, res ) {
282
283
  let spocEmail = store.spocDetails[0].email;
283
284
  let spocName = store.spocDetails[0].name;
284
285
  let Uidomain = `${appConfig.url.domain}/manage/stores/infra-ticket?storeId=${getTicket.basicDetails.storeId}`;
286
+ let getclient = await findOneClient( { clientId: getTicket.basicDetails.clientId } );
285
287
  const html = htmlContent( { ...getTicket, Uidomain: Uidomain, primaryIssue: primaryIssue, storeName: getTicket.basicDetails.storeName, spocName: spocName, date: dayjs( getTicket.issueDate ).format( 'YYYY-MM-DD HH:mm' ), downtimetotal: downtimetotal, Timestamp: Timestamp, domain: appConfig.url.apiDomain } );
286
- if ( spocEmail && isValidEmail( spocEmail ) ) {
288
+ if ( getclient.ticketConfigs.emailAlert&& spocEmail && isValidEmail( spocEmail ) ) {
287
289
  await sendEmailWithSES( spocEmail, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
288
290
  }
289
291
  }
@@ -4,7 +4,7 @@ import { aggregateTangoTicket } from '../services/tangoTicket.service.js';
4
4
  import { findOneStore } from '../services/store.service.js';
5
5
  import dayjs from 'dayjs';
6
6
  import { findinfraReason } from '../services/infraReason.service.js';
7
- import { signedUrl } from 'tango-app-api-middleware';
7
+ import { signedUrl, appConfig } from 'tango-app-api-middleware';
8
8
  export async function storeTicketList( req, res ) {
9
9
  try {
10
10
  let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
@@ -337,7 +337,7 @@ export async function edgeAppLogTable( req, res ) {
337
337
  const average = sum / streamwiseDowntime.length;
338
338
  obj.downtime = Math.round( average );
339
339
  } else {
340
- obj.downtime = '';
340
+ obj.downtime = 0;
341
341
  }
342
342
  let appStatusQuery = {
343
343
  'size': 1,
@@ -803,7 +803,7 @@ export async function cameraAngleChange( req, res ) {
803
803
  let changeDetected = result.camera_info.filter( ( cam ) => cam.stream == req.body.StreamName );
804
804
  if ( changeDetected.length == 1 ) {
805
805
  let params = {
806
- Bucket: 'tango-client-sandbox',
806
+ Bucket: appConfig.cloud.aws.bucket.cameraAngle,
807
807
  file_path: changeDetected[0].path,
808
808
  };
809
809
  let Image = await signedUrl( params );
@@ -28,7 +28,7 @@ export async function validateDetails( req, res, next ) {
28
28
  clientId: store.clientId,
29
29
  clientName: client.clientName,
30
30
  };
31
-
31
+ req.body.emailAlert = client.ticketConfigs.emailAlert;
32
32
  if ( req.body.issueType == 'infra' ) {
33
33
  let refreshdate = dayjs().add( client.ticketConfigs.refreshAlert, 'days' );
34
34
  req.body.ticketDetails = {
@@ -62,7 +62,7 @@ export async function validateTicket( req, res, next ) {
62
62
  if ( Ticket ) {
63
63
  return res.sendSuccess( 'Infra Ticket Already Exists for the day' );
64
64
  }
65
- console.log( req.body );
65
+
66
66
  let refreshTicket = await findOneTangoTicket(
67
67
  {
68
68
  'basicDetails.storeId': req.body.basicDetails.storeId,
@@ -71,7 +71,6 @@ export async function validateTicket( req, res, next ) {
71
71
  'ticketDetails.ticketRefreshTime': { $lte: new Date() },
72
72
  },
73
73
  );
74
- console.log( refreshTicket );
75
74
  if ( refreshTicket ) {
76
75
  return res.sendSuccess( 'refreshTicket Ticket Already Exists for the Store' );
77
76
  }