tango-app-api-infra 3.0.107-dev → 3.0.109-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
|
@@ -314,21 +314,20 @@ export async function installationCard( req, res ) {
|
|
|
314
314
|
export async function infraIssuesTable( req, res ) {
|
|
315
315
|
try {
|
|
316
316
|
let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
|
|
317
|
-
let issueStatus = [ 'identified' ];
|
|
317
|
+
let issueStatus = [ 'notidentified', 'identified' ];
|
|
318
|
+
|
|
318
319
|
if ( req.body.infrafilterIssue == 'Issues Not Identified' ) {
|
|
319
320
|
issueStatus = [ 'notidentified' ];
|
|
320
321
|
};
|
|
321
|
-
if ( req.body.infrafilterIssue == '
|
|
322
|
-
issueStatus = [ '
|
|
323
|
-
};
|
|
324
|
-
if ( req.body.infrafilterIssue == 'Live Stores' ) {
|
|
325
|
-
issueStatus = [ 'notidentified', 'identified' ];
|
|
322
|
+
if ( req.body.infrafilterIssue == 'Identified Issues' ) {
|
|
323
|
+
issueStatus = [ 'identified' ];
|
|
326
324
|
};
|
|
325
|
+
|
|
326
|
+
|
|
327
327
|
let totalstores = await aggregateStore( [ {
|
|
328
328
|
$match: {
|
|
329
329
|
'$and': [
|
|
330
330
|
{ 'clientId': { $in: req.body.clientId } },
|
|
331
|
-
{ 'edge.firstFile': true },
|
|
332
331
|
{ 'status': 'active' },
|
|
333
332
|
{ 'createdAt': { $lte: date.end } },
|
|
334
333
|
],
|
|
@@ -338,6 +337,23 @@ export async function infraIssuesTable( req, res ) {
|
|
|
338
337
|
for ( let store of totalstores ) {
|
|
339
338
|
totalnumberstores.push( store.storeId );
|
|
340
339
|
}
|
|
340
|
+
let pendingquery = [];
|
|
341
|
+
pendingquery.push( {
|
|
342
|
+
$match: {
|
|
343
|
+
$and: [
|
|
344
|
+
{ issueType: 'installation' },
|
|
345
|
+
{ 'status': { $ne: 'closed' } },
|
|
346
|
+
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
347
|
+
{ createdAt: { $lte: date.end } },
|
|
348
|
+
],
|
|
349
|
+
},
|
|
350
|
+
} );
|
|
351
|
+
let pendingstorecount = await aggregateTangoTicket( pendingquery );
|
|
352
|
+
let installpendingticket = [];
|
|
353
|
+
for ( let store of pendingstorecount ) {
|
|
354
|
+
installpendingticket.push( store.basicDetails.storeId );
|
|
355
|
+
}
|
|
356
|
+
|
|
341
357
|
let query = [ {
|
|
342
358
|
$match: {
|
|
343
359
|
$and: [
|
|
@@ -346,7 +362,6 @@ export async function infraIssuesTable( req, res ) {
|
|
|
346
362
|
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
347
363
|
{ 'basicDetails.storeId': { $in: totalnumberstores } },
|
|
348
364
|
{ 'ticketDetails.issueStatus': { $in: issueStatus } },
|
|
349
|
-
// { createdAt: { $gte: date.start } },
|
|
350
365
|
{ createdAt: { $lte: date.end } },
|
|
351
366
|
],
|
|
352
367
|
},
|
|
@@ -426,8 +441,8 @@ export async function infraIssuesTable( req, res ) {
|
|
|
426
441
|
$match: {
|
|
427
442
|
'$and': [
|
|
428
443
|
{ 'clientId': { $in: req.body.clientId } },
|
|
429
|
-
{ 'edge.firstFile': true },
|
|
430
444
|
{ 'status': 'active' },
|
|
445
|
+
{ 'storeId': { $nin: installpendingticket } },
|
|
431
446
|
{ 'createdAt': { $lte: date.end } },
|
|
432
447
|
],
|
|
433
448
|
},
|
|
@@ -442,7 +457,7 @@ export async function infraIssuesTable( req, res ) {
|
|
|
442
457
|
}
|
|
443
458
|
let result = [];
|
|
444
459
|
for ( let data of totalnumberstores ) {
|
|
445
|
-
if ( infraissueStore.length > 0 && !infraissueStore.includes( data ) ) {
|
|
460
|
+
if ( infraissueStore.length > 0 && !infraissueStore.includes( data )&&!installpendingticket.includes( data ) ) {
|
|
446
461
|
result.push( data );
|
|
447
462
|
}
|
|
448
463
|
}
|
|
@@ -563,15 +578,24 @@ export async function infraIssuesTable( req, res ) {
|
|
|
563
578
|
if ( req.body.export && result.length > 0 ) {
|
|
564
579
|
const exportdata = [];
|
|
565
580
|
result.forEach( ( element ) => {
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
581
|
+
if ( req.body.infrafilterIssue == 'Live Stores' || req.body.infrafilterIssue == 'Total Stores' ) {
|
|
582
|
+
exportdata.push( {
|
|
583
|
+
'Created On': element.createdAt,
|
|
584
|
+
'StoreID': element.storeId,
|
|
585
|
+
'StoreName': element.storeName,
|
|
586
|
+
'Status': element.status,
|
|
587
|
+
} );
|
|
588
|
+
} else {
|
|
589
|
+
exportdata.push( {
|
|
590
|
+
'Created On': element.createdAt,
|
|
591
|
+
'StoreID': element.storeId,
|
|
592
|
+
'StoreName': element.storeName,
|
|
593
|
+
'Primary Issue': element.primaryIssue,
|
|
594
|
+
'Sub Issue': element.secondaryIssue,
|
|
595
|
+
'Issue Identified on': element.issueIdentifiedDate? dayjs( element.issueIdentifiedDate ).tz( 'Asia/Kolkata' ).format( 'YYYY-MM-DD HH:mm A' ):'',
|
|
596
|
+
'Status': element.status,
|
|
597
|
+
} );
|
|
598
|
+
}
|
|
575
599
|
} );
|
|
576
600
|
await download( exportdata, res );
|
|
577
601
|
return;
|
|
@@ -30,7 +30,7 @@ export async function createTicket( req, res ) {
|
|
|
30
30
|
} ];
|
|
31
31
|
let ticketExists= await findOneTangoTicket( { ticketId: req.body.ticketId } );
|
|
32
32
|
if ( ticketExists ) {
|
|
33
|
-
res.status( 200 ).send( { storeId: req.body.storeId } );
|
|
33
|
+
return res.status( 200 ).send( { message: 'ticketId Exists', storeId: req.body.storeId } );
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
if ( req.body.issueType == 'installation' ) {
|
|
@@ -72,7 +72,7 @@ export async function createTicket( req, res ) {
|
|
|
72
72
|
downtimetotal = 0;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
console.log( req.body );
|
|
76
76
|
let create = await createTangoTicket( req.body );
|
|
77
77
|
let Timestamp = dayjs().format( 'YYYY-MM-DD HH:mm' );
|
|
78
78
|
const attachments = null;
|
|
@@ -239,14 +239,16 @@ export async function updateTicketIssue( req, res ) {
|
|
|
239
239
|
'status': 'inprogress',
|
|
240
240
|
};
|
|
241
241
|
}
|
|
242
|
-
let updateTicket = await updateOneTangoTicket( { ticketId: req.body.ticketId }, query );
|
|
243
242
|
if ( req.body.issueType === 'infra' ) {
|
|
244
243
|
let client = await findOneClient( { clientId: req.body.basicDetails.clientId } );
|
|
245
244
|
let refreshdate = dayjs().add( client.ticketConfigs.refreshAlert, 'days' );
|
|
246
|
-
|
|
247
|
-
|
|
245
|
+
console.log( new Date( dayjs( refreshdate ).format( 'YYYY-MM-DD' ) ) );
|
|
246
|
+
query = { ...query, 'ticketDetails.ticketRefreshTime': new Date( dayjs( refreshdate ).format( 'YYYY-MM-DD' ) ),
|
|
248
247
|
};
|
|
249
248
|
}
|
|
249
|
+
console.log( query );
|
|
250
|
+
let updateTicket = await updateOneTangoTicket( { ticketId: req.body.ticketId }, query );
|
|
251
|
+
|
|
250
252
|
if ( req.body.ticketDetails.ticketType === 'refreshticket' ) {
|
|
251
253
|
await updateOneTangoTicket( { ticketId: req.body.ticketId }, { 'ticketDetails.refreshTicketStatus': 'identified' } );
|
|
252
254
|
}
|
|
@@ -817,27 +817,30 @@ export async function datewiseDowntime( req, res ) {
|
|
|
817
817
|
try {
|
|
818
818
|
const store = await findOneStore( { storeId: req.body.storeId } );
|
|
819
819
|
if ( !store ) {
|
|
820
|
-
return res.sendError( '
|
|
820
|
+
return res.sendError( 'Store Not Found', 204 );
|
|
821
821
|
}
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
822
|
+
|
|
823
|
+
const startHour = parseInt( store.storeProfile.open.split( ':' )[0], 10 );
|
|
824
|
+
const endHour = parseInt( store.storeProfile.close.split( ':' )[0], 10 );
|
|
825
|
+
|
|
826
|
+
const datesArray = getDatesArray( req.body.fromDate, req.body.toDate );
|
|
827
|
+
const paginatedDates = paginateArray( datesArray, req.body.offset, req.body.limit );
|
|
828
|
+
|
|
829
|
+
const resultPromises = paginatedDates.map( ( singleDate ) => {
|
|
830
|
+
const inputData = {
|
|
830
831
|
start: startHour,
|
|
831
832
|
end: endHour,
|
|
832
833
|
interval: 60,
|
|
833
834
|
};
|
|
834
835
|
req.body.Date = singleDate;
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
836
|
+
return livecountCheck( inputData, singleDate, req );
|
|
837
|
+
} );
|
|
838
|
+
|
|
839
|
+
const result = await Promise.all( resultPromises );
|
|
840
|
+
|
|
838
841
|
res.sendSuccess( {
|
|
839
842
|
count: datesArray.length,
|
|
840
|
-
data: result,
|
|
843
|
+
data: result.flat(), // Flatten the array of arrays
|
|
841
844
|
} );
|
|
842
845
|
} catch ( error ) {
|
|
843
846
|
logger.error( { error: error, function: 'datewiseDowntime' } );
|
|
@@ -897,73 +900,60 @@ export async function streamwiseDowntime( req, res ) {
|
|
|
897
900
|
}
|
|
898
901
|
|
|
899
902
|
|
|
900
|
-
export async function livecountCheck( inputData, req ) {
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
let TimeSlots = generateTimeSlots( inputData.start, inputData.end, inputData.interval, req );
|
|
904
|
-
let timewise = [];
|
|
905
|
-
for ( const obj of TimeSlots ) {
|
|
906
|
-
obj.startTime = dayjs( obj.from ).format( 'hh:mm A' );
|
|
907
|
-
obj.endTime = dayjs( obj.to ).format( 'hh:mm A' );
|
|
908
|
-
let downTimeQuery = {
|
|
909
|
-
'size': 1,
|
|
910
|
-
'query': {
|
|
911
|
-
'bool': {
|
|
912
|
-
'must': [
|
|
913
|
-
{
|
|
914
|
-
'term': {
|
|
915
|
-
'doc.date.keyword': dayjs( obj.from ).format( 'DD-MM-YYYY' ),
|
|
916
|
-
},
|
|
917
|
-
},
|
|
918
|
-
{
|
|
919
|
-
'term': {
|
|
920
|
-
'doc.store_id.keyword': req.body.storeId,
|
|
921
|
-
},
|
|
922
|
-
},
|
|
923
|
-
{
|
|
924
|
-
'terms': {
|
|
925
|
-
'doc.hour.keyword': [ obj.hour ],
|
|
926
|
-
},
|
|
927
|
-
},
|
|
928
|
-
],
|
|
903
|
+
export async function livecountCheck( inputData, singleDate, req ) {
|
|
904
|
+
try {
|
|
905
|
+
const TimeSlots = generateTimeSlots( inputData.start, inputData.end, inputData.interval, req );
|
|
929
906
|
|
|
930
|
-
|
|
907
|
+
const queryPromises = TimeSlots.map( async ( obj ) => {
|
|
908
|
+
obj.startTime = dayjs( obj.from ).format( 'hh:mm A' );
|
|
909
|
+
obj.endTime = dayjs( obj.to ).format( 'hh:mm A' );
|
|
910
|
+
|
|
911
|
+
const downTimeQuery = {
|
|
912
|
+
size: 1,
|
|
913
|
+
query: {
|
|
914
|
+
bool: {
|
|
915
|
+
must: [
|
|
916
|
+
{ term: { 'doc.date.keyword': dayjs( obj.from ).format( 'DD-MM-YYYY' ) } },
|
|
917
|
+
{ term: { 'doc.store_id.keyword': req.body.storeId } },
|
|
918
|
+
{ terms: { 'doc.hour.keyword': [ obj.hour ] } },
|
|
919
|
+
],
|
|
931
920
|
},
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
let streamwiseDowntime = downtime.body.hits.hits.length > 0 ? downtime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
|
|
935
|
-
if ( streamwiseDowntime.length > 0 ) {
|
|
936
|
-
const sum = streamwiseDowntime.reduce( ( accumulator, currentValue ) => {
|
|
937
|
-
return accumulator + currentValue.down_time;
|
|
938
|
-
}, 0 );
|
|
939
|
-
const average = sum / streamwiseDowntime.length;
|
|
940
|
-
obj[obj.startTime + '-' + obj.endTime] = Math.round( average );
|
|
941
|
-
} else {
|
|
942
|
-
obj[obj.startTime + '-' + obj.endTime] = '';
|
|
943
|
-
}
|
|
921
|
+
},
|
|
922
|
+
};
|
|
944
923
|
|
|
945
|
-
|
|
924
|
+
const downtime = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).downTimeHourly, downTimeQuery );
|
|
925
|
+
const streamwiseDowntime = downtime.body.hits.hits.length > 0 ? downtime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
|
|
926
|
+
if ( streamwiseDowntime.length > 0 ) {
|
|
927
|
+
const sum = streamwiseDowntime.reduce( ( accumulator, currentValue ) => accumulator + currentValue.down_time, 0 );
|
|
928
|
+
const average = sum / streamwiseDowntime.length;
|
|
929
|
+
obj[obj.startTime + '-' + obj.endTime] = Math.round( average );
|
|
930
|
+
} else {
|
|
931
|
+
obj[obj.startTime + '-' + obj.endTime] = '';
|
|
946
932
|
}
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
933
|
+
return obj;
|
|
934
|
+
} );
|
|
935
|
+
|
|
936
|
+
const timewise = await Promise.all( queryPromises );
|
|
937
|
+
|
|
938
|
+
|
|
939
|
+
const mergedData = {
|
|
940
|
+
Date: dayjs( singleDate ).format( 'YYYY-MM-DD' ),
|
|
941
|
+
};
|
|
942
|
+
|
|
943
|
+
timewise.forEach( ( obj ) => {
|
|
944
|
+
for ( const key in obj ) {
|
|
945
|
+
if ( key !== 'hour' && key !== 'from' && key !== 'to' && key !== 'startTime' && key !== 'endTime' && key !== 'clientId' ) {
|
|
946
|
+
if ( mergedData[key] ) {
|
|
947
|
+
mergedData[key] += obj[key];
|
|
948
|
+
} else {
|
|
949
|
+
mergedData[key] = obj[key];
|
|
958
950
|
}
|
|
959
951
|
}
|
|
960
|
-
}
|
|
952
|
+
}
|
|
953
|
+
} );
|
|
961
954
|
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
Reject( err );
|
|
967
|
-
}
|
|
968
|
-
} );
|
|
955
|
+
return [ mergedData ];
|
|
956
|
+
} catch ( err ) {
|
|
957
|
+
throw err;
|
|
958
|
+
}
|
|
969
959
|
}
|
|
@@ -24,7 +24,8 @@ export async function userTakeTicket( req, res ) {
|
|
|
24
24
|
if ( req.body.issueType == 'infra' ) {
|
|
25
25
|
let query = {
|
|
26
26
|
'status': { $ne: 'closed' },
|
|
27
|
-
'issueType': 'infra',
|
|
27
|
+
'issueType': 'infra',
|
|
28
|
+
'ticketDetails.assigntoUser': true,
|
|
28
29
|
'ticketDetails.addressingUser': { $exists: false },
|
|
29
30
|
'ticketDetails.issueStatus': 'notidentified',
|
|
30
31
|
'ticketDetails.addressingClient': { $exists: false },
|
|
@@ -37,11 +38,12 @@ export async function userTakeTicket( req, res ) {
|
|
|
37
38
|
if ( !userTicket ) {
|
|
38
39
|
let query = {
|
|
39
40
|
'status': { $ne: 'closed' },
|
|
40
|
-
'basicDetails.clientId': { $in: assignedClients },
|
|
41
41
|
'issueType': 'infra',
|
|
42
|
-
'ticketType': 'refreshticket',
|
|
42
|
+
'ticketDetails.ticketType': 'refreshticket',
|
|
43
43
|
'ticketDetails.refreshTicketStatus': 'notidentified',
|
|
44
44
|
};
|
|
45
|
+
console.log( query, assignedClients );
|
|
46
|
+
|
|
45
47
|
if ( assignedClients.length > 0 ) {
|
|
46
48
|
query = ( { ...query, ...{ 'basicDetails.clientId': { $in: assignedClients } } } );
|
|
47
49
|
}
|
|
@@ -352,7 +354,6 @@ export async function workHistory( req, res ) {
|
|
|
352
354
|
$match: {
|
|
353
355
|
$and: [
|
|
354
356
|
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
355
|
-
{ 'status': 'closed' },
|
|
356
357
|
{ issueType: req.body.issueType },
|
|
357
358
|
{ 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ) },
|
|
358
359
|
],
|
|
@@ -363,7 +364,6 @@ export async function workHistory( req, res ) {
|
|
|
363
364
|
$match: {
|
|
364
365
|
$and: [
|
|
365
366
|
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
366
|
-
{ 'status': 'closed' },
|
|
367
367
|
{ issueType: { $in: [ 'highcount', 'lowcount' ] } },
|
|
368
368
|
{ 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ) },
|
|
369
369
|
],
|
|
@@ -420,6 +420,18 @@ export async function workHistory( req, res ) {
|
|
|
420
420
|
},
|
|
421
421
|
);
|
|
422
422
|
}
|
|
423
|
+
} else {
|
|
424
|
+
query.push(
|
|
425
|
+
{
|
|
426
|
+
$match: {
|
|
427
|
+
$and: [
|
|
428
|
+
{ createdAt: { $gte: date.start } },
|
|
429
|
+
{ createdAt: { $lte: date.end } },
|
|
430
|
+
],
|
|
431
|
+
|
|
432
|
+
},
|
|
433
|
+
},
|
|
434
|
+
);
|
|
423
435
|
}
|
|
424
436
|
|
|
425
437
|
if ( req.body.storeFilter && req.body.storeFilter.length > 0 ) {
|
|
@@ -537,6 +549,8 @@ export async function workHistory( req, res ) {
|
|
|
537
549
|
'Closed on': element.issueClosedDate,
|
|
538
550
|
'Issue Identified on': element.issueIdentifiedDate,
|
|
539
551
|
'Issue Type': element.infraIssue ? element.infraIssue : '-',
|
|
552
|
+
'Status': element.status,
|
|
553
|
+
|
|
540
554
|
};
|
|
541
555
|
}
|
|
542
556
|
if ( req.body.issueType === 'dataMismatch' ) {
|
|
@@ -550,6 +564,7 @@ export async function workHistory( req, res ) {
|
|
|
550
564
|
'Issue date': dayjs( element.issueDate ).format( 'DD MMM, YYYY' ),
|
|
551
565
|
'Closed on': element.issueClosedDate,
|
|
552
566
|
'Issue Type': element.issueType ? element.issueType : '-',
|
|
567
|
+
'Status': element.status,
|
|
553
568
|
};
|
|
554
569
|
}
|
|
555
570
|
exportdata.push( data );
|