tango-app-api-infra 3.0.106-dev → 3.0.107-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 +1 -1
- package/src/controllers/clientInfra.controller.js +38 -1
- package/src/controllers/infra.controllers.js +10 -1
- package/src/controllers/internalInfra.controller.js +4 -4
- package/src/controllers/storeInfra.controlller.js +149 -188
- package/src/controllers/userInfra.controller.js +9 -16
- package/src/validations/infra.validation.js +7 -8
package/package.json
CHANGED
|
@@ -302,7 +302,7 @@ export async function installationCard( req, res ) {
|
|
|
302
302
|
onboardedStoresCount: onboardedCount,
|
|
303
303
|
inactiveStoresCount: deactiveCount,
|
|
304
304
|
installedStoresCount: installedCount-yettoInstallCount.length,
|
|
305
|
-
yettoInstallCount: yettoInstallCount.length,
|
|
305
|
+
yettoInstallCount: yettoInstallCount.length-installFailedCount.length,
|
|
306
306
|
installFailedCount: installFailedCount.length,
|
|
307
307
|
infraIssues: response,
|
|
308
308
|
} );
|
|
@@ -516,6 +516,43 @@ export async function infraIssuesTable( req, res ) {
|
|
|
516
516
|
{ $skip: ( req.body.offset - 1 ) * req.body.limit },
|
|
517
517
|
{ $limit: Number( req.body.limit ) },
|
|
518
518
|
);
|
|
519
|
+
storesQuery.push( {
|
|
520
|
+
$lookup: {
|
|
521
|
+
from: 'clients',
|
|
522
|
+
let: { clientId: '$clientId' },
|
|
523
|
+
pipeline: [
|
|
524
|
+
{
|
|
525
|
+
$match: {
|
|
526
|
+
$expr: {
|
|
527
|
+
$and: [
|
|
528
|
+
{ $eq: [ '$clientId', '$$clientId' ] },
|
|
529
|
+
],
|
|
530
|
+
},
|
|
531
|
+
},
|
|
532
|
+
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
$project: {
|
|
536
|
+
clientName: 1,
|
|
537
|
+
},
|
|
538
|
+
},
|
|
539
|
+
], as: 'client',
|
|
540
|
+
},
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
$unwind: { path: '$client', preserveNullAndEmptyArrays: true },
|
|
544
|
+
},
|
|
545
|
+
{
|
|
546
|
+
$project: {
|
|
547
|
+
clientName: '$client.clientName',
|
|
548
|
+
storeId: 1,
|
|
549
|
+
clientId: 1,
|
|
550
|
+
storeName: 1,
|
|
551
|
+
status: 1,
|
|
552
|
+
createdAt: 1,
|
|
553
|
+
},
|
|
554
|
+
},
|
|
555
|
+
);
|
|
519
556
|
}
|
|
520
557
|
let result;
|
|
521
558
|
if ( req.body.infrafilterIssue == 'Live Stores' || req.body.infrafilterIssue == 'Total Stores' ) {
|
|
@@ -19,7 +19,9 @@ export async function createTicket( req, res ) {
|
|
|
19
19
|
try {
|
|
20
20
|
req.body.issueDate = new Date( req.body.Date );
|
|
21
21
|
if ( req.body.issueType == 'infra' ) {
|
|
22
|
-
req.body.ticketId
|
|
22
|
+
if ( !req.body.ticketId ) {
|
|
23
|
+
req.body.ticketId = 'TE_INF_' + new Date().valueOf();
|
|
24
|
+
}
|
|
23
25
|
req.body.ticketActivity = [ {
|
|
24
26
|
actionType: 'defaultInfra',
|
|
25
27
|
timeStamp: new Date(),
|
|
@@ -238,6 +240,13 @@ export async function updateTicketIssue( req, res ) {
|
|
|
238
240
|
};
|
|
239
241
|
}
|
|
240
242
|
let updateTicket = await updateOneTangoTicket( { ticketId: req.body.ticketId }, query );
|
|
243
|
+
if ( req.body.issueType === 'infra' ) {
|
|
244
|
+
let client = await findOneClient( { clientId: req.body.basicDetails.clientId } );
|
|
245
|
+
let refreshdate = dayjs().add( client.ticketConfigs.refreshAlert, 'days' );
|
|
246
|
+
req.body.ticketDetails = {
|
|
247
|
+
ticketRefreshTime: new Date( dayjs( refreshdate ).format( 'YYYY-MM-DD' ) ),
|
|
248
|
+
};
|
|
249
|
+
}
|
|
241
250
|
if ( req.body.ticketDetails.ticketType === 'refreshticket' ) {
|
|
242
251
|
await updateOneTangoTicket( { ticketId: req.body.ticketId }, { 'ticketDetails.refreshTicketStatus': 'identified' } );
|
|
243
252
|
}
|
|
@@ -156,7 +156,7 @@ export async function updateRefreshTicket( req, res ) {
|
|
|
156
156
|
try {
|
|
157
157
|
for ( let ticket of req.body.TicketList ) {
|
|
158
158
|
let getTicket = await findOneTangoTicket( { ticketId: ticket.ticketId } );
|
|
159
|
-
await updateOneTangoTicket( { ticketId: ticket.ticketId }, { 'ticketDetails.ticketType': 'refreshticket' } );
|
|
159
|
+
await updateOneTangoTicket( { ticketId: ticket.ticketId }, { 'ticketDetails.ticketType': 'refreshticket', 'ticketDetails.refreshTicketStatus': 'notidentified' } );
|
|
160
160
|
await updateOneTangoTicketunset( { ticketId: ticket.ticketId }, { 'ticketDetails.addressingUser': 1 } );
|
|
161
161
|
let downTimeQuery = {
|
|
162
162
|
'size': 1,
|
|
@@ -901,7 +901,7 @@ export async function edgeApplogsCheck( req, res ) {
|
|
|
901
901
|
edgelog: findissue,
|
|
902
902
|
storeId: ticket.basicDetails.storeId,
|
|
903
903
|
primary: 'System Issues',
|
|
904
|
-
secondary: [ '
|
|
904
|
+
secondary: [ 'Antivirus blockages' ],
|
|
905
905
|
};
|
|
906
906
|
updateIssue( findissueEdgeApp );
|
|
907
907
|
finalresult.push( findissueEdgeApp );
|
|
@@ -920,7 +920,7 @@ export async function edgeApplogsCheck( req, res ) {
|
|
|
920
920
|
storeId: ticket.basicDetails.storeId,
|
|
921
921
|
edgelog: findissue.edgelog.data,
|
|
922
922
|
primary: 'Camera Issues',
|
|
923
|
-
secondary: [ 'Camera
|
|
923
|
+
secondary: [ 'Camera not working' ],
|
|
924
924
|
};
|
|
925
925
|
updateIssue( findissueEdgeApp );
|
|
926
926
|
finalresult.push( findissueEdgeApp );
|
|
@@ -951,7 +951,7 @@ export async function edgeApplogsCheck( req, res ) {
|
|
|
951
951
|
edgelog: findissue,
|
|
952
952
|
storeId: ticket.basicDetails.storeId,
|
|
953
953
|
primary: 'Internet Issues',
|
|
954
|
-
secondary: [ '
|
|
954
|
+
secondary: [ 'Internet slow' ],
|
|
955
955
|
};
|
|
956
956
|
updateIssue( findissueEdgeApp );
|
|
957
957
|
finalresult.push( findissueEdgeApp );
|
|
@@ -62,7 +62,12 @@ export async function storeTicketList( req, res ) {
|
|
|
62
62
|
$filter: {
|
|
63
63
|
input: '$ticketActivity',
|
|
64
64
|
as: 'item',
|
|
65
|
-
cond: {
|
|
65
|
+
cond: {
|
|
66
|
+
$and: [
|
|
67
|
+
{ $ne: [ '$$item.actionType', 'statusChange' ] },
|
|
68
|
+
{ $ne: [ '$$item.actionType', 'statusCheck' ] },
|
|
69
|
+
],
|
|
70
|
+
},
|
|
66
71
|
},
|
|
67
72
|
},
|
|
68
73
|
primaryIssue: {
|
|
@@ -284,173 +289,136 @@ export async function edgeAppLogTable( req, res ) {
|
|
|
284
289
|
try {
|
|
285
290
|
const store = await findOneStore( { storeId: req.body.storeId } );
|
|
286
291
|
if ( !store ) {
|
|
287
|
-
return res.sendError( '
|
|
292
|
+
return res.sendError( 'Store Not found', 204 );
|
|
288
293
|
}
|
|
289
|
-
|
|
290
|
-
let
|
|
294
|
+
|
|
295
|
+
let startHour = parseInt( store.storeProfile.open.split( ':' )[0], 10 );
|
|
296
|
+
let endHour = parseInt( store.storeProfile.close.split( ':' )[0], 10 );
|
|
291
297
|
const interval = 60; // 1 hour in minutes
|
|
292
298
|
const timeSlots = generateTimeSlots( startHour, endHour, interval, req );
|
|
299
|
+
|
|
300
|
+
const date = dayjs( timeSlots[0].from ).format( 'DD-MM-YYYY' );
|
|
301
|
+
const storeId = req.body.storeId;
|
|
302
|
+
|
|
303
|
+
const internetSpeedQuery = {
|
|
304
|
+
size: 100,
|
|
305
|
+
query: {
|
|
306
|
+
bool: {
|
|
307
|
+
must: [
|
|
308
|
+
{ term: { 'log_type.keyword': 'Application' } },
|
|
309
|
+
{ term: { 'store_date.keyword': date } },
|
|
310
|
+
{ term: { 'storeId.keyword': storeId } },
|
|
311
|
+
{ term: { 'log_subtype.keyword': 'Speed_Test' } },
|
|
312
|
+
],
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
sort: [ { timestamp: { order: 'desc' } } ],
|
|
316
|
+
_source: [ 'data.upload_Speed', 'data.occuringTime' ],
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
const fileCountQuery = {
|
|
320
|
+
size: 100,
|
|
321
|
+
query: {
|
|
322
|
+
bool: {
|
|
323
|
+
must: [
|
|
324
|
+
{ term: { 'log_type.keyword': 'Application' } },
|
|
325
|
+
{ term: { 'store_date.keyword': date } },
|
|
326
|
+
{ term: { 'storeId.keyword': storeId } },
|
|
327
|
+
{ term: { 'log_subtype.keyword': 'Zip_File_Count' } },
|
|
328
|
+
],
|
|
329
|
+
},
|
|
330
|
+
},
|
|
331
|
+
sort: [ { timestamp: { order: 'desc' } } ],
|
|
332
|
+
_source: [ 'data.files_pushed', 'data.files_generated', 'data.occuringTime' ],
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
const downTimeQuery = {
|
|
336
|
+
size: 100,
|
|
337
|
+
query: {
|
|
338
|
+
bool: {
|
|
339
|
+
must: [
|
|
340
|
+
{ term: { 'doc.date.keyword': date } },
|
|
341
|
+
{ term: { 'doc.store_id.keyword': storeId } },
|
|
342
|
+
],
|
|
343
|
+
},
|
|
344
|
+
},
|
|
345
|
+
_source: [ 'doc.streamwise_downtime', 'doc.hour' ],
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
// Execute all queries in parallel
|
|
349
|
+
const [ speedTestResult, fileCountResult, downtimeResult ] = await Promise.all( [
|
|
350
|
+
getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, internetSpeedQuery ),
|
|
351
|
+
getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, fileCountQuery ),
|
|
352
|
+
getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).downTimeHourly, downTimeQuery ),
|
|
353
|
+
] );
|
|
354
|
+
// Process results
|
|
355
|
+
const speedTestData = speedTestResult?.body?.hits?.hits ?? [];
|
|
356
|
+
const fileCountData = fileCountResult?.body?.hits?.hits ?? [];
|
|
357
|
+
const downtimeData = downtimeResult?.body?.hits?.hits ?? [];
|
|
358
|
+
|
|
293
359
|
for ( const obj of timeSlots ) {
|
|
360
|
+
const hour = obj.hour;
|
|
294
361
|
obj.startTime = dayjs( obj.from ).format( 'hh:mm A' );
|
|
295
362
|
obj.endTime = dayjs( obj.to ).format( 'hh:mm A' );
|
|
296
|
-
let internetSpeedQuery = {
|
|
297
|
-
'query': {
|
|
298
|
-
'bool': {
|
|
299
|
-
'must': [
|
|
300
|
-
{
|
|
301
|
-
'term': {
|
|
302
|
-
'log_type.keyword': 'Application',
|
|
303
|
-
},
|
|
304
|
-
},
|
|
305
|
-
{
|
|
306
|
-
'term': {
|
|
307
|
-
'store_date.keyword': dayjs( obj.from ).format( 'DD-MM-YYYY' ),
|
|
308
|
-
},
|
|
309
|
-
},
|
|
310
|
-
{
|
|
311
|
-
'term': {
|
|
312
|
-
'storeId.keyword': req.body.storeId,
|
|
313
|
-
},
|
|
314
|
-
},
|
|
315
|
-
{
|
|
316
|
-
'term': {
|
|
317
|
-
'log_subtype.keyword': 'Speed_Test',
|
|
318
|
-
},
|
|
319
|
-
},
|
|
320
|
-
],
|
|
321
|
-
},
|
|
322
|
-
},
|
|
323
|
-
'sort': [
|
|
324
|
-
{ 'timestamp': { 'order': 'desc' } },
|
|
325
|
-
],
|
|
326
|
-
};
|
|
327
|
-
let speedTest = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, internetSpeedQuery );
|
|
328
|
-
if ( speedTest&& speedTest.body.hits && speedTest.body.hits.hits.length > 0 ) {
|
|
329
|
-
for ( const sourcedata of speedTest.body.hits.hits ) {
|
|
330
|
-
if ( sourcedata._source ) {
|
|
331
|
-
if ( Number( sourcedata._source.data.occuringTime.split( ':' )[0] )==obj.hour ) {
|
|
332
|
-
const megabytes = bytesToMB( sourcedata._source.data.upload_Speed.split( '.' )[0] ).toFixed( 2 );
|
|
333
|
-
obj.Internetspeed = megabytes+ ' MB/sec';
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
} else {
|
|
338
|
-
obj.Internetspeed = '';
|
|
339
|
-
}
|
|
340
|
-
let FileCountQuery = {
|
|
341
|
-
'size': 1000,
|
|
342
|
-
'query': {
|
|
343
|
-
'bool': {
|
|
344
|
-
'must': [
|
|
345
|
-
{
|
|
346
|
-
'term': {
|
|
347
|
-
'log_type.keyword': 'Application',
|
|
348
|
-
},
|
|
349
|
-
},
|
|
350
|
-
{
|
|
351
|
-
'term': {
|
|
352
|
-
'store_date.keyword': dayjs( obj.from ).format( 'DD-MM-YYYY' ),
|
|
353
|
-
},
|
|
354
|
-
},
|
|
355
|
-
{
|
|
356
|
-
'term': {
|
|
357
|
-
'storeId.keyword': req.body.storeId,
|
|
358
|
-
},
|
|
359
|
-
},
|
|
360
|
-
{
|
|
361
|
-
'term': {
|
|
362
|
-
'log_subtype.keyword': 'Zip_File_Count',
|
|
363
|
-
},
|
|
364
|
-
},
|
|
365
|
-
],
|
|
366
363
|
|
|
367
|
-
|
|
368
|
-
},
|
|
364
|
+
// Internet speed
|
|
369
365
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
};
|
|
374
|
-
let newFilesCount = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, FileCountQuery );
|
|
375
|
-
if ( newFilesCount&& newFilesCount.body.hits && newFilesCount.body.hits.hits.length > 0 ) {
|
|
376
|
-
obj.files_pushed = 0;
|
|
377
|
-
obj.files_generated = 0;
|
|
378
|
-
for ( let sourcedata of newFilesCount.body.hits.hits ) {
|
|
379
|
-
if ( sourcedata._source ) {
|
|
380
|
-
if ( Number( sourcedata._source.data.occuringTime.split( ':' )[0] )==obj.hour ) {
|
|
381
|
-
obj.files_pushed = obj.files_pushed+Number( sourcedata._source.data.files_pushed );
|
|
382
|
-
obj.files_generated = obj.files_generated+Number( sourcedata._source.data.files_generated );
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
} else {
|
|
387
|
-
obj.files_pushed = '';
|
|
388
|
-
obj.files_generated = '';
|
|
389
|
-
}
|
|
390
|
-
let downTimeQuery = {
|
|
391
|
-
'size': 1,
|
|
392
|
-
'query': {
|
|
393
|
-
'bool': {
|
|
394
|
-
'must': [
|
|
395
|
-
{
|
|
396
|
-
'term': {
|
|
397
|
-
'doc.date.keyword': dayjs( obj.from ).format( 'DD-MM-YYYY' ),
|
|
398
|
-
},
|
|
399
|
-
},
|
|
400
|
-
{
|
|
401
|
-
'term': {
|
|
402
|
-
'doc.store_id.keyword': req.body.storeId,
|
|
403
|
-
},
|
|
404
|
-
},
|
|
405
|
-
{
|
|
406
|
-
'terms': {
|
|
407
|
-
'doc.hour.keyword': [ obj.hour ],
|
|
408
|
-
},
|
|
409
|
-
},
|
|
410
|
-
],
|
|
366
|
+
const speedTest = speedTestData.find(
|
|
367
|
+
( item ) => Number( item._source.data.occuringTime.split( ':' )[0] ) === hour,
|
|
368
|
+
);
|
|
369
|
+
obj.Internetspeed = speedTest ? `${bytesToMB( speedTest._source.data.upload_Speed.split( '.' )[0] ).toFixed( 2 )} MB/sec` : '';
|
|
411
370
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
371
|
+
// File counts
|
|
372
|
+
const fileCounts = fileCountData.filter(
|
|
373
|
+
( item ) => Number( item._source.data.occuringTime.split( ':' )[0] ) === hour,
|
|
374
|
+
);
|
|
375
|
+
obj.files_pushed = fileCounts.reduce( ( sum, item ) => sum + Number( item._source.data.files_pushed ), 0 ) || '';
|
|
376
|
+
obj.files_generated = fileCounts.reduce( ( sum, item ) => sum + Number( item._source.data.files_generated ), 0 ) || '';
|
|
377
|
+
|
|
378
|
+
// Downtime
|
|
379
|
+
|
|
380
|
+
const downtime = downtimeData.find( ( item ) => Number( item._source.doc.hour ) === hour );
|
|
381
|
+
|
|
382
|
+
if ( downtime ) {
|
|
383
|
+
const streamwiseDowntime = downtime._source.doc.streamwise_downtime || [];
|
|
384
|
+
if ( streamwiseDowntime.length > 0 ) {
|
|
385
|
+
const sum = streamwiseDowntime.reduce( ( acc, cur ) => acc + cur.down_time, 0 );
|
|
386
|
+
const average = sum / streamwiseDowntime.length;
|
|
387
|
+
obj.downtime = Math.round( average );
|
|
388
|
+
} else {
|
|
389
|
+
obj.downtime = '';
|
|
390
|
+
}
|
|
423
391
|
} else {
|
|
424
392
|
obj.downtime = '';
|
|
425
393
|
}
|
|
426
394
|
}
|
|
395
|
+
|
|
427
396
|
if ( req.body.export ) {
|
|
428
|
-
const
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
} );
|
|
437
|
-
} );
|
|
438
|
-
await download( exportdata, res );
|
|
397
|
+
const exportData = timeSlots.map( ( element ) => ( {
|
|
398
|
+
'Time Stamp': `${element.startTime}-${element.endTime}`,
|
|
399
|
+
'Downtime': element.downtime,
|
|
400
|
+
'Avg Internet Speed': element.Internetspeed,
|
|
401
|
+
'Files Generated': element.files_generated,
|
|
402
|
+
'Files Pushed': element.files_pushed,
|
|
403
|
+
} ) );
|
|
404
|
+
await download( exportData, res );
|
|
439
405
|
return;
|
|
440
406
|
}
|
|
407
|
+
|
|
441
408
|
res.sendSuccess( timeSlots );
|
|
442
409
|
} catch ( error ) {
|
|
443
|
-
logger.error( { error
|
|
410
|
+
logger.error( { error, function: 'edgeAppLog' } );
|
|
444
411
|
return res.sendError( error, 500 );
|
|
445
412
|
}
|
|
446
413
|
}
|
|
414
|
+
|
|
447
415
|
function bytesToMB( bytes ) {
|
|
448
416
|
return bytes / ( 1024 * 1024 );
|
|
449
417
|
}
|
|
450
418
|
function generateTimeSlots( startHour, endHour, interval, req ) {
|
|
451
419
|
try {
|
|
452
420
|
const timeSlots = [];
|
|
453
|
-
for ( let hour = startHour; hour
|
|
421
|
+
for ( let hour = startHour; hour < endHour; hour++ ) {
|
|
454
422
|
for ( let minute = 0; minute < 60; minute += interval ) {
|
|
455
423
|
let isoDate = new Date();
|
|
456
424
|
|
|
@@ -496,7 +464,7 @@ export async function viewedgeAppLog( req, res ) {
|
|
|
496
464
|
|
|
497
465
|
|
|
498
466
|
let appStartTimeQuery = {
|
|
499
|
-
'size':
|
|
467
|
+
'size': 100,
|
|
500
468
|
'query': {
|
|
501
469
|
'bool': {
|
|
502
470
|
'must': [
|
|
@@ -530,7 +498,7 @@ export async function viewedgeAppLog( req, res ) {
|
|
|
530
498
|
response.appStartTime = appStartTime.body.hits.hits.length > 0 ? appStartTime.body.hits.hits[0]._source.data.occuringTime : '';
|
|
531
499
|
|
|
532
500
|
let appQuitTimeQuery = {
|
|
533
|
-
'size':
|
|
501
|
+
'size': 100,
|
|
534
502
|
'query': {
|
|
535
503
|
'bool': {
|
|
536
504
|
'must': [
|
|
@@ -571,7 +539,7 @@ export async function viewedgeAppLog( req, res ) {
|
|
|
571
539
|
}
|
|
572
540
|
}
|
|
573
541
|
let appCrashTimeQuery = {
|
|
574
|
-
'size':
|
|
542
|
+
'size': 100,
|
|
575
543
|
'query': {
|
|
576
544
|
'bool': {
|
|
577
545
|
'must': [
|
|
@@ -613,7 +581,7 @@ export async function viewedgeAppLog( req, res ) {
|
|
|
613
581
|
}
|
|
614
582
|
}
|
|
615
583
|
const screenStatus = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, {
|
|
616
|
-
'size':
|
|
584
|
+
'size': 100,
|
|
617
585
|
'query': {
|
|
618
586
|
'bool': {
|
|
619
587
|
'must': [
|
|
@@ -674,7 +642,7 @@ export async function viewedgeAppLog( req, res ) {
|
|
|
674
642
|
response.screenStatus = differences.length>0?`${differences[0].minutes}Mins ${differences[0].seconds}Sec`:'';
|
|
675
643
|
}
|
|
676
644
|
const FileCountQuery = {
|
|
677
|
-
'size':
|
|
645
|
+
'size': 100,
|
|
678
646
|
'query': {
|
|
679
647
|
'bool': {
|
|
680
648
|
'must': [
|
|
@@ -726,7 +694,7 @@ export async function viewedgeAppLog( req, res ) {
|
|
|
726
694
|
|
|
727
695
|
|
|
728
696
|
const antiVirus = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, {
|
|
729
|
-
'size':
|
|
697
|
+
'size': 100,
|
|
730
698
|
'query': {
|
|
731
699
|
'bool': {
|
|
732
700
|
'must': [
|
|
@@ -880,55 +848,47 @@ export async function streamwiseDowntime( req, res ) {
|
|
|
880
848
|
try {
|
|
881
849
|
const store = await findOneStore( { storeId: req.body.storeId } );
|
|
882
850
|
if ( !store ) {
|
|
883
|
-
return res.sendError( '
|
|
851
|
+
return res.sendError( 'Store not found', 204 );
|
|
884
852
|
}
|
|
885
|
-
|
|
886
|
-
|
|
853
|
+
|
|
854
|
+
const startHour = store.storeProfile.open.split( ':' )[0];
|
|
855
|
+
const endHour = store.storeProfile.close.split( ':' )[0];
|
|
887
856
|
const interval = 60; // 1 hour in minutes
|
|
888
857
|
const TimeSlots = generateTimeSlots( startHour, endHour, interval, req );
|
|
889
|
-
let timewise = [];
|
|
890
|
-
for ( const obj of TimeSlots ) {
|
|
891
|
-
obj.startTime = dayjs( obj.from ).format( 'hh:mm A' );
|
|
892
|
-
obj.endTime = dayjs( obj.to ).format( 'hh:mm A' );
|
|
893
|
-
let downTimeQuery = {
|
|
894
|
-
'size': 1,
|
|
895
|
-
'query': {
|
|
896
|
-
'bool': {
|
|
897
|
-
'must': [
|
|
898
|
-
{
|
|
899
|
-
'term': {
|
|
900
|
-
'doc.date.keyword': dayjs( obj.from ).format( 'DD-MM-YYYY' ),
|
|
901
|
-
},
|
|
902
|
-
},
|
|
903
|
-
{
|
|
904
|
-
'term': {
|
|
905
|
-
'doc.store_id.keyword': req.body.storeId,
|
|
906
|
-
},
|
|
907
|
-
},
|
|
908
|
-
{
|
|
909
|
-
'term': {
|
|
910
|
-
'doc.hour.keyword': obj.hour,
|
|
911
|
-
},
|
|
912
|
-
},
|
|
913
|
-
],
|
|
914
858
|
|
|
859
|
+
const parsedOpenSearch = JSON.parse( process.env.OPENSEARCH );
|
|
860
|
+
const downTimeIndex = parsedOpenSearch.downTimeHourly;
|
|
861
|
+
|
|
862
|
+
const batchRequests = TimeSlots.map( async ( obj ) => {
|
|
863
|
+
const formattedDate = dayjs( obj.from ).format( 'DD-MM-YYYY' );
|
|
864
|
+
const downTimeQuery = {
|
|
865
|
+
size: 1,
|
|
866
|
+
query: {
|
|
867
|
+
bool: {
|
|
868
|
+
must: [
|
|
869
|
+
{ term: { 'doc.date.keyword': formattedDate } },
|
|
870
|
+
{ term: { 'doc.store_id.keyword': req.body.storeId } },
|
|
871
|
+
{ term: { 'doc.hour.keyword': obj.hour } },
|
|
872
|
+
],
|
|
915
873
|
},
|
|
916
874
|
},
|
|
917
875
|
};
|
|
918
|
-
const downtime = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).downTimeHourly, downTimeQuery );
|
|
919
876
|
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
877
|
+
const downtime = await getOpenSearchData( downTimeIndex, downTimeQuery );
|
|
878
|
+
const streamwiseDowntime = downtime.body.hits.hits.length > 0 ?
|
|
879
|
+
downtime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
|
|
880
|
+
|
|
881
|
+
const foundStream = streamwiseDowntime.find( ( stream ) => stream.stream === req.body.stream );
|
|
882
|
+
return {
|
|
883
|
+
startTime: dayjs( obj.from ).format( 'hh:mm A' ),
|
|
884
|
+
endTime: dayjs( obj.to ).format( 'hh:mm A' ),
|
|
885
|
+
downTime: foundStream ? foundStream.down_time : '',
|
|
886
|
+
hour: obj.hour,
|
|
887
|
+
|
|
888
|
+
};
|
|
889
|
+
} );
|
|
890
|
+
|
|
891
|
+
const timewise = await Promise.all( batchRequests );
|
|
932
892
|
res.sendSuccess( timewise );
|
|
933
893
|
} catch ( error ) {
|
|
934
894
|
logger.error( { error: error, function: 'streamwiseDowntime' } );
|
|
@@ -936,6 +896,7 @@ export async function streamwiseDowntime( req, res ) {
|
|
|
936
896
|
}
|
|
937
897
|
}
|
|
938
898
|
|
|
899
|
+
|
|
939
900
|
export async function livecountCheck( inputData, req ) {
|
|
940
901
|
return new Promise( async ( Resolve, Reject ) => {
|
|
941
902
|
try {
|
|
@@ -130,22 +130,15 @@ export async function userTicketList( req, res ) {
|
|
|
130
130
|
},
|
|
131
131
|
} );
|
|
132
132
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
} else {
|
|
143
|
-
query.push( {
|
|
144
|
-
$match: {
|
|
145
|
-
updatedAt: { $gte: new Date( dayjs().format( 'YYYY-MM-DD' ) ) },
|
|
146
|
-
},
|
|
147
|
-
} );
|
|
148
|
-
}
|
|
133
|
+
|
|
134
|
+
query.push( {
|
|
135
|
+
$match: {
|
|
136
|
+
$and: [
|
|
137
|
+
{ updatedAt: { $gte: date.start } },
|
|
138
|
+
{ updatedAt: { $lte: date.end } },
|
|
139
|
+
],
|
|
140
|
+
},
|
|
141
|
+
} );
|
|
149
142
|
if ( req.body.status && req.body.status != '' ) {
|
|
150
143
|
query.push( {
|
|
151
144
|
$match: {
|
|
@@ -29,19 +29,18 @@ export async function validateDetails( req, res, next ) {
|
|
|
29
29
|
clientName: client.clientName,
|
|
30
30
|
};
|
|
31
31
|
req.body.emailAlert = client.ticketConfigs.emailAlert;
|
|
32
|
-
if ( req.body.issueType == 'infra' ) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
32
|
+
// if ( req.body.issueType == 'infra' ) {
|
|
33
|
+
// let refreshdate = dayjs().add( client.ticketConfigs.refreshAlert, 'days' );
|
|
34
|
+
// req.body.ticketDetails = {
|
|
35
|
+
// ticketRefreshTime: new Date( dayjs( refreshdate ).format( 'YYYY-MM-DD' ) ),
|
|
36
|
+
// };
|
|
37
|
+
// }
|
|
38
|
+
if ( req.body.issueType == 'installation' ) {
|
|
38
39
|
let refreshdate = dayjs().add( client.ticketConfigs.installationReAssign, 'days' );
|
|
39
40
|
req.body.ticketDetails = {
|
|
40
41
|
ticketRefreshTime: new Date( dayjs( refreshdate ).format( 'YYYY-MM-DD' ) ),
|
|
41
42
|
};
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
44
|
next();
|
|
46
45
|
} catch ( error ) {
|
|
47
46
|
logger.error( { error: error, function: 'validateDetails' } );
|