tango-app-api-infra 3.1.0 → 3.1.2

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.1.0",
3
+ "version": "3.1.2",
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": "^3.1.1",
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
  },
@@ -149,7 +149,7 @@ export async function infraCard( req, res ) {
149
149
  export async function installationCard( req, res ) {
150
150
  try {
151
151
  let onboardedCount = await countDocumentsStore( { clientId: { $in: req.body.clientId } } );
152
- let installedCount = await countDocumentsStore( { 'clientId': { $in: req.body.clientId }, 'edge.deployed': true } );
152
+ let installedCount = await countDocumentsStore( { 'clientId': { $in: req.body.clientId }, 'edge.firstFile': true } );
153
153
 
154
154
  let yettoInstallCount = await aggregateTangoTicket( [
155
155
  {
@@ -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 ) {
@@ -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
  }
@@ -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: appConfig.cloud.aws.bucket.ticket,
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
  }
@@ -307,16 +306,26 @@ export async function InfrastepstoResolve( req, res, next ) {
307
306
  export async function InfraAlert( req, res, next ) {
308
307
  try {
309
308
  if ( req.body.hibernationDays ) {
310
- req.body.hibernationDays = dayjs().add( req.body.hibernationDays, 'days' ).format( 'YYYY-MM-DD' );
311
- await updateOneStore( { storeId: req.body.basicDetails.storeId }, { 'ticketConfigs.hibernation': new Date( req.body.hibernationDays ) } );
309
+ let actionBy = '';
310
+ if ( req.user.userType == 'tango' ) {
311
+ actionBy = 'Tango';
312
+ } else if ( req.user.userType == 'client' ) {
313
+ actionBy = 'User';
314
+ }
315
+
312
316
  req.body.ticketActivity.push( {
313
317
  actionType: 'statusCheckReply',
314
- actionBy: 'User',
318
+ actionBy: actionBy,
315
319
  timeStamp: new Date(),
320
+ statusCheckReply: 'No',
316
321
  IdentifiedBy: req.user.userName,
317
322
  hibernationDays: req.body.hibernationDays,
318
323
  } );
324
+ req.body.hibernationDays = dayjs().add( req.body.hibernationDays, 'days' ).format( 'YYYY-MM-DD' );
325
+ await updateOneStore( { storeId: req.body.basicDetails.storeId }, { 'ticketConfigs.hibernation': new Date( req.body.hibernationDays ) } );
326
+
319
327
  await updateOneTangoTicket( { ticketId: req.body.ticketId }, { 'hibernation': new Date( req.body.hibernationDays ) } );
328
+ console.log( req.body.ticketActivity );
320
329
  } else {
321
330
  if ( req.body.issueType == 'infra' ) {
322
331
  let client = await findOneClient( { clientId: req.body.basicDetails.clientId }, { ticketConfigs: 1 } );