tango-app-api-infra 3.0.49-dev → 3.0.51-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
|
@@ -75,9 +75,9 @@ 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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
if ( req.body.spocEmail&&req.body.issueType == 'infra' ) {
|
|
79
|
+
await sendEmailWithSES( req.body.spocEmail, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
|
|
80
|
+
}
|
|
81
81
|
if ( create ) {
|
|
82
82
|
res.sendSuccess( 'Ticket Created Successfully' );
|
|
83
83
|
}
|
|
@@ -86,7 +86,7 @@ export async function clientList( req, res ) {
|
|
|
86
86
|
export async function basicList( req, res ) {
|
|
87
87
|
try {
|
|
88
88
|
let storeList = await findStore( { status: 'active' },
|
|
89
|
-
{ 'storeName': 1, 'storeId': 1, 'clientId': 1, 'storeProfile.open': 1, 'storeProfile.close': 1, 'storeProfile.timeZone': 1 } );
|
|
89
|
+
{ 'storeName': 1, 'storeId': 1, 'ticketConfigs': 1, 'clientId': 1, 'storeProfile.open': 1, 'storeProfile.close': 1, 'storeProfile.timeZone': 1 } );
|
|
90
90
|
res.sendSuccess( storeList );
|
|
91
91
|
} catch ( error ) {
|
|
92
92
|
logger.error( { error: error, function: 'basicList' } );
|
|
@@ -201,7 +201,9 @@ export async function updateRefreshTicket( req, res ) {
|
|
|
201
201
|
}
|
|
202
202
|
let Uidomain = `${appConfig.url.domain}/manage/stores/infra-ticket?storeId=${getTicket.basicDetails.storeId}`;
|
|
203
203
|
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
|
-
|
|
204
|
+
if ( spocEmail ) {
|
|
205
|
+
await sendEmailWithSES( spocEmail, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
|
|
206
|
+
}
|
|
205
207
|
}
|
|
206
208
|
}
|
|
207
209
|
|
|
@@ -215,71 +217,75 @@ export async function closeTicket( req, res ) {
|
|
|
215
217
|
try {
|
|
216
218
|
for ( let ticket of req.body.TicketList ) {
|
|
217
219
|
let getTicket = await findOneTangoTicket( { ticketId: ticket.ticketId } );
|
|
218
|
-
if (
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
'
|
|
235
|
-
'
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
'
|
|
220
|
+
if ( getTicket ) {
|
|
221
|
+
if ( ticket.status == 'closed' ) {
|
|
222
|
+
getTicket.ticketActivity.push( {
|
|
223
|
+
actionType: 'dataRecived',
|
|
224
|
+
actionBy: 'Tango',
|
|
225
|
+
} );
|
|
226
|
+
}
|
|
227
|
+
await updateOneTangoTicket( { ticketId: ticket.ticketId },
|
|
228
|
+
{
|
|
229
|
+
status: ticket.status,
|
|
230
|
+
ticketActivity: getTicket.ticketActivity,
|
|
231
|
+
issueClosedDate: new Date(),
|
|
232
|
+
},
|
|
233
|
+
);
|
|
234
|
+
let downTimeQuery = {
|
|
235
|
+
'size': 1,
|
|
236
|
+
'query': {
|
|
237
|
+
'bool': {
|
|
238
|
+
'must': [
|
|
239
|
+
{
|
|
240
|
+
'term': {
|
|
241
|
+
'doc.date.keyword': dayjs( getTicket.issueDate ).format( 'DD-MM-YYYY' ),
|
|
242
|
+
},
|
|
239
243
|
},
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
+
{
|
|
245
|
+
'term': {
|
|
246
|
+
'doc.store_id.keyword': getTicket.basicDetails.storeId,
|
|
247
|
+
},
|
|
244
248
|
},
|
|
245
|
-
},
|
|
246
249
|
|
|
247
|
-
|
|
250
|
+
],
|
|
248
251
|
|
|
252
|
+
},
|
|
249
253
|
},
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
254
|
+
};
|
|
255
|
+
let downtimetotal;
|
|
256
|
+
const downtime = await getOpenSearchData( 'live_downtime_hourly', downTimeQuery );
|
|
257
|
+
let streamwiseDowntime = downtime.body.hits.hits.length > 0 ? downtime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
|
|
258
|
+
if ( streamwiseDowntime.length > 0 ) {
|
|
259
|
+
const sum = streamwiseDowntime.reduce( ( accumulator, currentValue ) => {
|
|
260
|
+
return accumulator + currentValue.down_time;
|
|
261
|
+
}, 0 );
|
|
262
|
+
const average = sum / streamwiseDowntime.length;
|
|
263
|
+
downtimetotal = Math.round( average );
|
|
264
|
+
} else {
|
|
265
|
+
downtimetotal = 0;
|
|
266
|
+
}
|
|
264
267
|
|
|
265
|
-
|
|
266
|
-
|
|
268
|
+
let Issue = getTicket.ticketActivity.filter( ( a ) => a.actionType == 'issueUpdate' );
|
|
269
|
+
let primaryIssue = '';
|
|
267
270
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
271
|
+
if ( Issue.length > 0 && Issue[0].reasons.length > 0 ) {
|
|
272
|
+
primaryIssue = Issue[0].reasons[0].primaryIssue;
|
|
273
|
+
}
|
|
274
|
+
let Timestamp = dayjs().format( 'YYYY-MM-DD HH:mm' );
|
|
275
|
+
const attachments = null;
|
|
276
|
+
const subject = `Tango Eye - Infra Ticket Closed for ${getTicket.basicDetails.storeName} `;
|
|
277
|
+
const fileContent = readFileSync( join() + '/src/hbs/closeTicekt.hbs', 'utf8' );
|
|
278
|
+
const htmlContent = handlebars.compile( fileContent );
|
|
279
|
+
let store = await findOneStore( { storeId: getTicket.basicDetails.storeId } );
|
|
280
|
+
if ( store.spocDetails && store.spocDetails.length > 0 ) {
|
|
281
|
+
let spocEmail = store.spocDetails[0].email;
|
|
282
|
+
let spocName = store.spocDetails[0].name;
|
|
283
|
+
let Uidomain = `${appConfig.url.domain}/manage/stores/infra-ticket?storeId=${getTicket.basicDetails.storeId}`;
|
|
284
|
+
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 } );
|
|
285
|
+
if ( spocEmail && spocEmail != '' &&spocEmail!='none'&& spocEmail != undefined ) {
|
|
286
|
+
await sendEmailWithSES( spocEmail, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
|
|
287
|
+
}
|
|
288
|
+
}
|
|
283
289
|
}
|
|
284
290
|
}
|
|
285
291
|
|
|
@@ -523,7 +529,7 @@ export async function infraReportSent( req, res ) {
|
|
|
523
529
|
'Status ': element.status,
|
|
524
530
|
'Responded By': clientuser && clientuser.userName ? clientuser.userName : '-',
|
|
525
531
|
'Resolved By': tangouser && tangouser.userName ? tangouser.userName : '-',
|
|
526
|
-
'Closed Date & Time': element.issueClosedDate?dayjs( element.issueClosedDate ).format( 'YYYY-MM-DD HH:mm A' ):'-',
|
|
532
|
+
'Closed Date & Time': element.issueClosedDate ? dayjs( element.issueClosedDate ).format( 'YYYY-MM-DD HH:mm A' ) : '-',
|
|
527
533
|
'Latest Comment': '',
|
|
528
534
|
'Activity Log': '',
|
|
529
535
|
} );
|
|
@@ -537,7 +543,7 @@ export async function infraReportSent( req, res ) {
|
|
|
537
543
|
],
|
|
538
544
|
} );
|
|
539
545
|
let client = await findOneClient( { clientId: req.body.clientId } );
|
|
540
|
-
let avgDownTime = client.ticketConfigs.infraDownTime*60;
|
|
546
|
+
let avgDownTime = client.ticketConfigs.infraDownTime * 60;
|
|
541
547
|
let issueList = await findinfraReason( { parentId: { '$exists': false } } );
|
|
542
548
|
const categoryCounts = {};
|
|
543
549
|
let response;
|
|
@@ -561,8 +567,8 @@ export async function infraReportSent( req, res ) {
|
|
|
561
567
|
} ) );
|
|
562
568
|
}
|
|
563
569
|
let reportdate = dayjs().format( 'YYYY-MM-DD' );
|
|
564
|
-
let attachments= null;
|
|
565
|
-
if ( exportdata.length>0 ) {
|
|
570
|
+
let attachments = null;
|
|
571
|
+
if ( exportdata.length > 0 ) {
|
|
566
572
|
const wb = new xl.Workbook();
|
|
567
573
|
const ws = wb.addWorksheet( 'Daily report' );
|
|
568
574
|
const headers = Object.keys( exportdata[0] );
|
|
@@ -601,3 +607,16 @@ export async function infraReportSent( req, res ) {
|
|
|
601
607
|
res.sendError( error, 500 );
|
|
602
608
|
}
|
|
603
609
|
}
|
|
610
|
+
export async function spocmailchange() {
|
|
611
|
+
let storelist = await findStore( {} );
|
|
612
|
+
for ( let store of storelist ) {
|
|
613
|
+
if ( store && store.spocDetails ) {
|
|
614
|
+
let spoclist = [];
|
|
615
|
+
for ( let spoc of store.spocDetails ) {
|
|
616
|
+
spoc.email = spoc.email.replace( '@', '1@' ),
|
|
617
|
+
spoclist.push( spoc );
|
|
618
|
+
}
|
|
619
|
+
await updateOneStore( { storeId: store.storeId }, { spocDetails: spoclist } );
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import express from 'express';
|
|
3
3
|
import {
|
|
4
4
|
migrateClient, migrateStores, basicList, clientList, setTicketTime, downStoresList,
|
|
5
|
-
openTicketList, assigntoUser, updateRefreshTicket, closeTicket, emailUserList, infraReportSent,
|
|
5
|
+
openTicketList, assigntoUser, updateRefreshTicket, closeTicket, spocmailchange, emailUserList, infraReportSent,
|
|
6
6
|
} from '../controllers/internalInfra.controller.js';
|
|
7
7
|
|
|
8
8
|
export const internalInfraRouter = express.Router();
|
|
@@ -19,5 +19,6 @@ internalInfraRouter.post( '/updateRefreshTicket', updateRefreshTicket );
|
|
|
19
19
|
internalInfraRouter.post( '/closeTicket', closeTicket );
|
|
20
20
|
internalInfraRouter.get( '/emailUserList', emailUserList );
|
|
21
21
|
internalInfraRouter.post( '/infraReportSent', infraReportSent );
|
|
22
|
+
internalInfraRouter.post( '/spocmailchange', spocmailchange );
|
|
22
23
|
|
|
23
24
|
|
|
@@ -30,15 +30,18 @@ export async function validateDetails( req, res, next ) {
|
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
if ( req.body.issueType == 'infra' ) {
|
|
33
|
+
let refreshdate = dayjs().add( client.ticketConfigs.refreshAlert, 'days' );
|
|
33
34
|
req.body.ticketDetails = {
|
|
34
|
-
ticketRefreshTime: dayjs().
|
|
35
|
+
ticketRefreshTime: new Date( dayjs( refreshdate ).format( 'YYYY-MM-DD' ) ),
|
|
35
36
|
};
|
|
36
37
|
} else if ( req.body.issueType == 'installation' ) {
|
|
38
|
+
let refreshdate = dayjs().add( client.ticketConfigs.installationReAssign, 'days' );
|
|
37
39
|
req.body.ticketDetails = {
|
|
38
|
-
ticketRefreshTime: dayjs().
|
|
40
|
+
ticketRefreshTime: new Date( dayjs( refreshdate ).format( 'YYYY-MM-DD' ) ),
|
|
39
41
|
};
|
|
40
42
|
}
|
|
41
43
|
|
|
44
|
+
|
|
42
45
|
next();
|
|
43
46
|
} catch ( error ) {
|
|
44
47
|
logger.error( { error: error, function: 'validateDetails' } );
|
|
@@ -64,6 +67,7 @@ export async function validateTicket( req, res, next ) {
|
|
|
64
67
|
'basicDetails.storeId': req.body.basicDetails.storeId,
|
|
65
68
|
'issueType': 'infra',
|
|
66
69
|
'status': { $ne: 'closed' },
|
|
70
|
+
'ticketDetails.ticketRefreshTime': { $lte: new Date() },
|
|
67
71
|
'ticketDetails.ticketType': 'refreshticket',
|
|
68
72
|
},
|
|
69
73
|
);
|