tango-app-api-infra 3.0.49-dev → 3.0.50-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.49-dev",
3
+ "version": "3.0.50-dev",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -215,71 +215,75 @@ export async function closeTicket( req, res ) {
215
215
  try {
216
216
  for ( let ticket of req.body.TicketList ) {
217
217
  let getTicket = await findOneTangoTicket( { ticketId: ticket.ticketId } );
218
- if ( ticket.status == 'closed' ) {
219
- getTicket.ticketActivity.push( {
220
- actionType: 'dataRecived',
221
- actionBy: 'Tango',
222
- } );
223
- }
224
- await updateOneTangoTicket( { ticketId: ticket.ticketId },
225
- {
226
- status: ticket.status,
227
- ticketActivity: getTicket.ticketActivity,
228
- issueClosedDate: new Date(),
229
- },
230
- );
231
- let downTimeQuery = {
232
- 'size': 1,
233
- 'query': {
234
- 'bool': {
235
- 'must': [
236
- {
237
- 'term': {
238
- 'doc.date.keyword': dayjs( getTicket.issueDate ).format( 'DD-MM-YYYY' ),
218
+ if ( getTicket ) {
219
+ if ( ticket.status == 'closed' ) {
220
+ getTicket.ticketActivity.push( {
221
+ actionType: 'dataRecived',
222
+ actionBy: 'Tango',
223
+ } );
224
+ }
225
+ await updateOneTangoTicket( { ticketId: ticket.ticketId },
226
+ {
227
+ status: ticket.status,
228
+ ticketActivity: getTicket.ticketActivity,
229
+ issueClosedDate: new Date(),
230
+ },
231
+ );
232
+ let downTimeQuery = {
233
+ 'size': 1,
234
+ 'query': {
235
+ 'bool': {
236
+ 'must': [
237
+ {
238
+ 'term': {
239
+ 'doc.date.keyword': dayjs( getTicket.issueDate ).format( 'DD-MM-YYYY' ),
240
+ },
239
241
  },
240
- },
241
- {
242
- 'term': {
243
- 'doc.store_id.keyword': getTicket.basicDetails.storeId,
242
+ {
243
+ 'term': {
244
+ 'doc.store_id.keyword': getTicket.basicDetails.storeId,
245
+ },
244
246
  },
245
- },
246
247
 
247
- ],
248
+ ],
248
249
 
250
+ },
249
251
  },
250
- },
251
- };
252
- let downtimetotal;
253
- const downtime = await getOpenSearchData( 'live_downtime_hourly', downTimeQuery );
254
- let streamwiseDowntime = downtime.body.hits.hits.length > 0 ? downtime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
255
- if ( streamwiseDowntime.length > 0 ) {
256
- const sum = streamwiseDowntime.reduce( ( accumulator, currentValue ) => {
257
- return accumulator + currentValue.down_time;
258
- }, 0 );
259
- const average = sum / streamwiseDowntime.length;
260
- downtimetotal = Math.round( average );
261
- } else {
262
- downtimetotal = 0;
263
- }
252
+ };
253
+ let downtimetotal;
254
+ const downtime = await getOpenSearchData( 'live_downtime_hourly', downTimeQuery );
255
+ let streamwiseDowntime = downtime.body.hits.hits.length > 0 ? downtime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
256
+ if ( streamwiseDowntime.length > 0 ) {
257
+ const sum = streamwiseDowntime.reduce( ( accumulator, currentValue ) => {
258
+ return accumulator + currentValue.down_time;
259
+ }, 0 );
260
+ const average = sum / streamwiseDowntime.length;
261
+ downtimetotal = Math.round( average );
262
+ } else {
263
+ downtimetotal = 0;
264
+ }
264
265
 
265
- let Issue = getTicket.ticketActivity.filter( ( a ) => a.actionType == 'issueUpdate' );
266
- let primaryIssue = '';
266
+ let Issue = getTicket.ticketActivity.filter( ( a ) => a.actionType == 'issueUpdate' );
267
+ let primaryIssue = '';
267
268
 
268
- if ( Issue.length > 0 && Issue[0].reasons.length > 0 ) {
269
- primaryIssue = Issue[0].reasons[0].primaryIssue;
270
- }
271
- let Timestamp = dayjs().format( 'YYYY-MM-DD HH:mm' );
272
- const attachments = null;
273
- const subject = `Tango Eye - Infra Ticket Closed for ${getTicket.basicDetails.storeName} `;
274
- const fileContent = readFileSync( join() + '/src/hbs/closeTicekt.hbs', 'utf8' );
275
- const htmlContent = handlebars.compile( fileContent );
276
- let store = await findOneStore( { storeId: getTicket.basicDetails.storeId } );
277
- if ( store.spocDetails && store.spocDetails.length > 0 ) {
278
- let spocEmail = store.spocDetails[0].email;
279
- let spocName = store.spocDetails[0].name;
280
- let Uidomain = `${appConfig.url.domain}/manage/stores/infra-ticket?storeId=${getTicket.basicDetails.storeId}`;
281
- 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 } );
282
- await sendEmailWithSES( spocEmail, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
269
+ if ( Issue.length > 0 && Issue[0].reasons.length > 0 ) {
270
+ primaryIssue = Issue[0].reasons[0].primaryIssue;
271
+ }
272
+ let Timestamp = dayjs().format( 'YYYY-MM-DD HH:mm' );
273
+ const attachments = null;
274
+ const subject = `Tango Eye - Infra Ticket Closed for ${getTicket.basicDetails.storeName} `;
275
+ const fileContent = readFileSync( join() + '/src/hbs/closeTicekt.hbs', 'utf8' );
276
+ const htmlContent = handlebars.compile( fileContent );
277
+ let store = await findOneStore( { storeId: getTicket.basicDetails.storeId } );
278
+ if ( store.spocDetails && store.spocDetails.length > 0 ) {
279
+ let spocEmail = store.spocDetails[0].email;
280
+ let spocName = store.spocDetails[0].name;
281
+ let Uidomain = `${appConfig.url.domain}/manage/stores/infra-ticket?storeId=${getTicket.basicDetails.storeId}`;
282
+ 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 } );
283
+ if ( spocEmail ) {
284
+ await sendEmailWithSES( spocEmail, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
285
+ }
286
+ }
283
287
  }
284
288
  }
285
289