tango-app-api-infra 3.9.2 → 3.9.4
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,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-infra",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.4",
|
|
4
4
|
"description": "infra",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"start": "nodemon --exec \"eslint --fix . && node
|
|
8
|
+
"start": "nodemon --exec \"eslint --fix . && node index.js\""
|
|
9
9
|
},
|
|
10
10
|
"engines": {
|
|
11
11
|
"node": ">=18.10.0"
|
|
@@ -15,9 +15,9 @@ import { countDocumentsClusters } from '../services/cluster.service.js';
|
|
|
15
15
|
export async function infraCard( req, res ) {
|
|
16
16
|
try {
|
|
17
17
|
let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
|
|
18
|
-
let storecountQuery ={ 'clientId': { $in: req.body.clientId }, 'createdAt': { $lte: date.end }, 'status': 'active' };
|
|
18
|
+
let storecountQuery = { 'clientId': { $in: req.body.clientId }, 'createdAt': { $lte: date.end }, 'status': 'active' };
|
|
19
19
|
|
|
20
|
-
if ( req.user&&req.user.userType ==='client'&&req.user.role!='superadmin' ) {
|
|
20
|
+
if ( req.user && req.user.userType === 'client' && req.user.role != 'superadmin' ) {
|
|
21
21
|
storecountQuery = { ...storecountQuery, ...{ storeId: { $in: req.body.assignedStores } } };
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -39,7 +39,7 @@ export async function infraCard( req, res ) {
|
|
|
39
39
|
},
|
|
40
40
|
];
|
|
41
41
|
|
|
42
|
-
if ( req.user&&req.user.userType ==='client'&&req.user.role!='superadmin' ) {
|
|
42
|
+
if ( req.user && req.user.userType === 'client' && req.user.role != 'superadmin' ) {
|
|
43
43
|
yetToInstallQuery.push(
|
|
44
44
|
{
|
|
45
45
|
$match: {
|
|
@@ -49,8 +49,8 @@ export async function infraCard( req, res ) {
|
|
|
49
49
|
);
|
|
50
50
|
}
|
|
51
51
|
let yettoInstallCount = await aggregateTangoTicket( yetToInstallQuery );
|
|
52
|
-
storeCount = storeCount-yettoInstallCount.length;
|
|
53
|
-
let totalStoreQuery =[ {
|
|
52
|
+
storeCount = storeCount - yettoInstallCount.length;
|
|
53
|
+
let totalStoreQuery = [ {
|
|
54
54
|
$match: {
|
|
55
55
|
'$and': [
|
|
56
56
|
{ 'clientId': { $in: req.body.clientId } },
|
|
@@ -59,7 +59,7 @@ export async function infraCard( req, res ) {
|
|
|
59
59
|
],
|
|
60
60
|
},
|
|
61
61
|
} ];
|
|
62
|
-
if ( req.user&&req.user.userType ==='client'&&req.user.role!='superadmin' ) {
|
|
62
|
+
if ( req.user && req.user.userType === 'client' && req.user.role != 'superadmin' ) {
|
|
63
63
|
totalStoreQuery.push(
|
|
64
64
|
{
|
|
65
65
|
$match: {
|
|
@@ -210,18 +210,18 @@ export async function infraCard( req, res ) {
|
|
|
210
210
|
} );
|
|
211
211
|
response.unshift( {
|
|
212
212
|
name: 'All Issues',
|
|
213
|
-
count: infraStoreCount.length > 0 ? req.body.filter && req.body.filter.length > 0?ticketList.length:( infraStoreCount[0].notidentifiedcount+ticketList.length ): 0,
|
|
213
|
+
count: infraStoreCount.length > 0 ? req.body.filter && req.body.filter.length > 0 ? ticketList.length : ( infraStoreCount[0].notidentifiedcount + ticketList.length ) : 0,
|
|
214
214
|
} );
|
|
215
215
|
response.push( {
|
|
216
216
|
name: 'Issues Not Identified',
|
|
217
|
-
count: infraStoreCount.length > 0 ?( req.body.filter && req.body.filter.length > 0 )?0: infraStoreCount[0].notidentifiedcount : 0,
|
|
217
|
+
count: infraStoreCount.length > 0 ? ( req.body.filter && req.body.filter.length > 0 ) ? 0 : infraStoreCount[0].notidentifiedcount : 0,
|
|
218
218
|
} );
|
|
219
219
|
res.sendSuccess( {
|
|
220
220
|
total: storeCount,
|
|
221
221
|
liveStoreCount: infraStoreCount.length > 0 ? storeCount - infraStoreCount[0].infraCount : storeCount,
|
|
222
|
-
infraStoreCount: infraStoreCount.length > 0 ? infraStoreCount[0].notidentifiedcount+ticketList.length : 0,
|
|
222
|
+
infraStoreCount: infraStoreCount.length > 0 ? infraStoreCount[0].notidentifiedcount + ticketList.length : 0,
|
|
223
223
|
identifiedcount: infraStoreCount.length > 0 ? ticketList.length : 0,
|
|
224
|
-
notidentifiedcount: infraStoreCount.length > 0 ?( req.body.filter && req.body.filter.length > 0 )?0: infraStoreCount[0].notidentifiedcount : 0,
|
|
224
|
+
notidentifiedcount: infraStoreCount.length > 0 ? ( req.body.filter && req.body.filter.length > 0 ) ? 0 : infraStoreCount[0].notidentifiedcount : 0,
|
|
225
225
|
infraIssues: response,
|
|
226
226
|
} );
|
|
227
227
|
} catch ( error ) {
|
|
@@ -238,7 +238,7 @@ export async function installationCard( req, res ) {
|
|
|
238
238
|
};
|
|
239
239
|
|
|
240
240
|
|
|
241
|
-
if ( req.user&&req.user.userType ==='client'&&req.user.role!='superadmin' ) {
|
|
241
|
+
if ( req.user && req.user.userType === 'client' && req.user.role != 'superadmin' ) {
|
|
242
242
|
baseQuery = { ...baseQuery, ...{ storeId: { $in: req.body.assignedStores } } };
|
|
243
243
|
}
|
|
244
244
|
let onboardQuery = { ...baseQuery };
|
|
@@ -264,7 +264,7 @@ export async function installationCard( req, res ) {
|
|
|
264
264
|
},
|
|
265
265
|
},
|
|
266
266
|
];
|
|
267
|
-
if ( req.user&&req.user.userType ==='client'&&req.user.role!='superadmin' ) {
|
|
267
|
+
if ( req.user && req.user.userType === 'client' && req.user.role != 'superadmin' ) {
|
|
268
268
|
ticketbaseQuery.push(
|
|
269
269
|
{
|
|
270
270
|
$match: {
|
|
@@ -350,8 +350,8 @@ export async function installationCard( req, res ) {
|
|
|
350
350
|
res.sendSuccess( {
|
|
351
351
|
onboardedStoresCount: onboardedCount,
|
|
352
352
|
inactiveStoresCount: deactiveCount,
|
|
353
|
-
installedStoresCount: installedCount-yettoInstallCount.length,
|
|
354
|
-
yettoInstallCount: yettoInstallCount.length-installFailedCount.length,
|
|
353
|
+
installedStoresCount: installedCount - yettoInstallCount.length,
|
|
354
|
+
yettoInstallCount: yettoInstallCount.length - installFailedCount.length,
|
|
355
355
|
installFailedCount: installFailedCount.length,
|
|
356
356
|
infraIssues: response,
|
|
357
357
|
} );
|
|
@@ -381,7 +381,7 @@ export async function infraIssuesTable( req, res ) {
|
|
|
381
381
|
],
|
|
382
382
|
},
|
|
383
383
|
} ];
|
|
384
|
-
if ( req.user&&req.user.userType ==='client'&&req.user.role!='superadmin' ) {
|
|
384
|
+
if ( req.user && req.user.userType === 'client' && req.user.role != 'superadmin' ) {
|
|
385
385
|
totalStoreQuery.push(
|
|
386
386
|
{
|
|
387
387
|
$match: {
|
|
@@ -406,7 +406,7 @@ export async function infraIssuesTable( req, res ) {
|
|
|
406
406
|
],
|
|
407
407
|
},
|
|
408
408
|
} );
|
|
409
|
-
if ( req.user&&req.user.userType ==='client'&&req.user.role!='superadmin' ) {
|
|
409
|
+
if ( req.user && req.user.userType === 'client' && req.user.role != 'superadmin' ) {
|
|
410
410
|
pendingquery.push(
|
|
411
411
|
{
|
|
412
412
|
$match: {
|
|
@@ -443,6 +443,13 @@ export async function infraIssuesTable( req, res ) {
|
|
|
443
443
|
createdAt: 1,
|
|
444
444
|
issueIdentifiedDate: '$ticketDetails.issueIdentifiedDate',
|
|
445
445
|
issueClosedDate: '$issueClosedDate',
|
|
446
|
+
otherscomment: {
|
|
447
|
+
$filter: {
|
|
448
|
+
input: '$ticketActivity',
|
|
449
|
+
as: 'item',
|
|
450
|
+
cond: { $eq: [ '$$item.actionType', 'comment' ] },
|
|
451
|
+
},
|
|
452
|
+
},
|
|
446
453
|
primaryIssue: {
|
|
447
454
|
$filter: {
|
|
448
455
|
input: '$ticketActivity',
|
|
@@ -452,6 +459,11 @@ export async function infraIssuesTable( req, res ) {
|
|
|
452
459
|
},
|
|
453
460
|
},
|
|
454
461
|
},
|
|
462
|
+
{
|
|
463
|
+
$unwind: {
|
|
464
|
+
path: '$otherscomment', preserveNullAndEmptyArrays: true,
|
|
465
|
+
},
|
|
466
|
+
},
|
|
455
467
|
{
|
|
456
468
|
$unwind: {
|
|
457
469
|
path: '$primaryIssue',
|
|
@@ -478,6 +490,8 @@ export async function infraIssuesTable( req, res ) {
|
|
|
478
490
|
createdAt: 1,
|
|
479
491
|
ticketId: 1,
|
|
480
492
|
clientName: 1,
|
|
493
|
+
commentText: { $ifNull: [ '$primaryIssue.comment', '-' ] },
|
|
494
|
+
otherscomment: { $ifNull: [ '$otherscomment.comment', '-' ] },
|
|
481
495
|
issueIdentifiedBy: { $ifNull: [ '$primaryIssue.actionBy', '' ] },
|
|
482
496
|
issueIdentifiedDate: { $ifNull: [ '$issueIdentifiedDate', '' ] },
|
|
483
497
|
issueClosedDate: { $ifNull: [ '$issueClosedDate', '' ] },
|
|
@@ -501,6 +515,7 @@ export async function infraIssuesTable( req, res ) {
|
|
|
501
515
|
status: { $last: '$status' },
|
|
502
516
|
primaryIssue: { $last: '$primaryIssue' },
|
|
503
517
|
secondaryIssue: { $last: '$secondaryIssue' },
|
|
518
|
+
commentText: { $last: '$commentText' },
|
|
504
519
|
},
|
|
505
520
|
},
|
|
506
521
|
];
|
|
@@ -539,7 +554,7 @@ export async function infraIssuesTable( req, res ) {
|
|
|
539
554
|
},
|
|
540
555
|
);
|
|
541
556
|
|
|
542
|
-
if ( infraissueStore&&infraissueStore.length==0 ) {
|
|
557
|
+
if ( infraissueStore && infraissueStore.length == 0 ) {
|
|
543
558
|
storesQuery = [ {
|
|
544
559
|
$match: {
|
|
545
560
|
'$and': [
|
|
@@ -552,7 +567,7 @@ export async function infraIssuesTable( req, res ) {
|
|
|
552
567
|
} ];
|
|
553
568
|
}
|
|
554
569
|
}
|
|
555
|
-
if ( req.user&&req.user.userType ==='client'&&req.user.role!='superadmin' ) {
|
|
570
|
+
if ( req.user && req.user.userType === 'client' && req.user.role != 'superadmin' ) {
|
|
556
571
|
storesQuery.push(
|
|
557
572
|
{
|
|
558
573
|
$match: {
|
|
@@ -682,10 +697,12 @@ export async function infraIssuesTable( req, res ) {
|
|
|
682
697
|
'Created On': dayjs( element.createdAt ).format( 'DD MMM, YYYY' ),
|
|
683
698
|
'StoreID': element.storeId,
|
|
684
699
|
'StoreName': element.storeName,
|
|
700
|
+
'clientName': element.clientName,
|
|
685
701
|
'Primary Issue': element.primaryIssue,
|
|
686
702
|
'Sub Issue': element.secondaryIssue,
|
|
687
703
|
'Issue Identified on': element.issueIdentifiedDate ? dayjs( element.issueIdentifiedDate ).format( 'DD MMM, YYYY' ) : '',
|
|
688
704
|
'Status': element.status,
|
|
705
|
+
'Comment': element.otherscomment ? element.otherscomment : element.commentText,
|
|
689
706
|
};
|
|
690
707
|
}
|
|
691
708
|
} );
|
|
@@ -720,7 +737,7 @@ export async function InstallationIssuesTable( req, res ) {
|
|
|
720
737
|
],
|
|
721
738
|
},
|
|
722
739
|
} );
|
|
723
|
-
if ( req.user&&req.user.userType ==='client'&&req.user.role!='superadmin' ) {
|
|
740
|
+
if ( req.user && req.user.userType === 'client' && req.user.role != 'superadmin' ) {
|
|
724
741
|
query.push(
|
|
725
742
|
{
|
|
726
743
|
$match: {
|
|
@@ -792,7 +809,7 @@ export async function InstallationIssuesTable( req, res ) {
|
|
|
792
809
|
},
|
|
793
810
|
);
|
|
794
811
|
let storesQuery = [];
|
|
795
|
-
if ( req.user&&req.user.userType ==='client'&&req.user.role!='superadmin' ) {
|
|
812
|
+
if ( req.user && req.user.userType === 'client' && req.user.role != 'superadmin' ) {
|
|
796
813
|
storesQuery.push(
|
|
797
814
|
{
|
|
798
815
|
$match: {
|
|
@@ -1154,7 +1171,7 @@ export async function hourWiseDownstores( req, res ) {
|
|
|
1154
1171
|
],
|
|
1155
1172
|
},
|
|
1156
1173
|
} ];
|
|
1157
|
-
if ( req.user&&req.user.userType ==='client' &&req.user.role!='superadmin' ) {
|
|
1174
|
+
if ( req.user && req.user.userType === 'client' && req.user.role != 'superadmin' ) {
|
|
1158
1175
|
totalStoreQuery.push(
|
|
1159
1176
|
{
|
|
1160
1177
|
$match: {
|
|
@@ -1179,7 +1196,7 @@ export async function hourWiseDownstores( req, res ) {
|
|
|
1179
1196
|
],
|
|
1180
1197
|
},
|
|
1181
1198
|
} );
|
|
1182
|
-
if ( req.user&&req.user.userType ==='client' &&req.user.role!='superadmin' ) {
|
|
1199
|
+
if ( req.user && req.user.userType === 'client' && req.user.role != 'superadmin' ) {
|
|
1183
1200
|
pendingquery.push(
|
|
1184
1201
|
{
|
|
1185
1202
|
$match: {
|
|
@@ -1311,7 +1328,7 @@ export async function hourWiseDownstores( req, res ) {
|
|
|
1311
1328
|
},
|
|
1312
1329
|
},
|
|
1313
1330
|
);
|
|
1314
|
-
if ( infraissueStore&&infraissueStore.length==0 ) {
|
|
1331
|
+
if ( infraissueStore && infraissueStore.length == 0 ) {
|
|
1315
1332
|
storesQuery = [ {
|
|
1316
1333
|
$match: {
|
|
1317
1334
|
'$and': [
|
|
@@ -1324,7 +1341,7 @@ export async function hourWiseDownstores( req, res ) {
|
|
|
1324
1341
|
} ];
|
|
1325
1342
|
}
|
|
1326
1343
|
}
|
|
1327
|
-
if ( req.user&&req.user.userType ==='client' ) {
|
|
1344
|
+
if ( req.user && req.user.userType === 'client' ) {
|
|
1328
1345
|
storesQuery.push(
|
|
1329
1346
|
{
|
|
1330
1347
|
$match: {
|
|
@@ -1475,7 +1492,7 @@ async function downStoresCheck( data, inputData ) {
|
|
|
1475
1492
|
startTime: dayjs( slot.from ).format( 'hh:mm A' ),
|
|
1476
1493
|
endTime: dayjs( slot.to ).format( 'hh:mm A' ),
|
|
1477
1494
|
} ) );
|
|
1478
|
-
let Totaldowntime=0;
|
|
1495
|
+
let Totaldowntime = 0;
|
|
1479
1496
|
|
|
1480
1497
|
const downTimePromises = formattedTimeSlots.map( async ( obj ) => {
|
|
1481
1498
|
const downTime = await getOpenSearchData(
|
|
@@ -1500,7 +1517,7 @@ async function downStoresCheck( data, inputData ) {
|
|
|
1500
1517
|
const average = streamwiseDowntime.length ?
|
|
1501
1518
|
Math.round( streamwiseDowntime.reduce( ( acc, curr ) => acc + curr.down_time, 0 ) / streamwiseDowntime.length ) :
|
|
1502
1519
|
'';
|
|
1503
|
-
Totaldowntime= Number( Totaldowntime ) + Number( average );
|
|
1520
|
+
Totaldowntime = Number( Totaldowntime ) + Number( average );
|
|
1504
1521
|
return { ...obj, [`${obj.startTime}-${obj.endTime}`]: average };
|
|
1505
1522
|
} );
|
|
1506
1523
|
|
|
@@ -1538,7 +1555,7 @@ export async function ticketCountSplit( req, res ) {
|
|
|
1538
1555
|
{ issueType: { $in: [ 'highcount', 'lowcount' ] } },
|
|
1539
1556
|
|
|
1540
1557
|
];
|
|
1541
|
-
if ( req.user&&req.user.userType ==='client'&&req.user.role!='superadmin' ) {
|
|
1558
|
+
if ( req.user && req.user.userType === 'client' && req.user.role != 'superadmin' ) {
|
|
1542
1559
|
filter.push( { 'basicDetails.storeId': { $in: req.body.assignedStores } } );
|
|
1543
1560
|
}
|
|
1544
1561
|
if ( req.user.userType === 'client' ) {
|
|
@@ -1619,7 +1636,7 @@ export async function overViewTable( req, res ) {
|
|
|
1619
1636
|
'basicDetails.clientId': { $in: inputData.clientId },
|
|
1620
1637
|
},
|
|
1621
1638
|
];
|
|
1622
|
-
if ( req.user&&req.user.userType ==='client' ) {
|
|
1639
|
+
if ( req.user && req.user.userType === 'client' ) {
|
|
1623
1640
|
filter.push( { 'basicDetails.storeId': { $in: req.body.assignedStores } } );
|
|
1624
1641
|
}
|
|
1625
1642
|
if ( req.user.userType === 'client' ) {
|
|
@@ -1630,7 +1647,7 @@ export async function overViewTable( req, res ) {
|
|
|
1630
1647
|
issueType: { $in: inputData.issueType },
|
|
1631
1648
|
} );
|
|
1632
1649
|
}
|
|
1633
|
-
if ( inputData?.status && inputData?.status!='' ) {
|
|
1650
|
+
if ( inputData?.status && inputData?.status != '' ) {
|
|
1634
1651
|
filter.push( {
|
|
1635
1652
|
status: inputData?.status,
|
|
1636
1653
|
} );
|
|
@@ -1670,7 +1687,8 @@ export async function overViewTable( req, res ) {
|
|
|
1670
1687
|
if ( inputData.sortColumnName ) {
|
|
1671
1688
|
const sortBy = inputData.sortBy || -1;
|
|
1672
1689
|
query.push( {
|
|
1673
|
-
$sort: {
|
|
1690
|
+
$sort: {
|
|
1691
|
+
[inputData.sortColumnName]: sortBy,
|
|
1674
1692
|
},
|
|
1675
1693
|
} );
|
|
1676
1694
|
}
|
|
@@ -1717,7 +1735,7 @@ export async function ticketCount( req, res ) {
|
|
|
1717
1735
|
},
|
|
1718
1736
|
|
|
1719
1737
|
];
|
|
1720
|
-
if ( req.user&&req.user.userType ==='client' &&req.user.role!='superadmin' ) {
|
|
1738
|
+
if ( req.user && req.user.userType === 'client' && req.user.role != 'superadmin' ) {
|
|
1721
1739
|
filter.push( { 'basicDetails.storeId': { $in: req.body.assignedStores } } );
|
|
1722
1740
|
}
|
|
1723
1741
|
if ( req.user.userType === 'client' ) {
|
|
@@ -1783,7 +1801,7 @@ export async function ticketCount( req, res ) {
|
|
|
1783
1801
|
};
|
|
1784
1802
|
export async function checkPermission( req, res, next ) {
|
|
1785
1803
|
try {
|
|
1786
|
-
let result =[];
|
|
1804
|
+
let result = [];
|
|
1787
1805
|
if ( req.user.role !== 'superadmin' && req.user.userType == 'client' ) {
|
|
1788
1806
|
const assignedUser = await findUserAssignedStore( { userEmail: req.user.email } );
|
|
1789
1807
|
if ( assignedUser.length == 0 ) {
|
|
@@ -1875,9 +1893,9 @@ export async function checkPermission( req, res, next ) {
|
|
|
1875
1893
|
result = await aggregateUserAssignedStore( assignedQuery );
|
|
1876
1894
|
break;
|
|
1877
1895
|
}
|
|
1878
|
-
if ( result&&result.length>0 ) {
|
|
1896
|
+
if ( result && result.length > 0 ) {
|
|
1879
1897
|
const uniqueArray = [ ...new Set( result[0].storeList ) ];
|
|
1880
|
-
req.body.assignedStores =uniqueArray;
|
|
1898
|
+
req.body.assignedStores = uniqueArray;
|
|
1881
1899
|
}
|
|
1882
1900
|
}
|
|
1883
1901
|
next();
|
|
@@ -1889,9 +1907,9 @@ export async function checkPermission( req, res, next ) {
|
|
|
1889
1907
|
|
|
1890
1908
|
export async function getcount( req, res ) {
|
|
1891
1909
|
try {
|
|
1892
|
-
let storecountQuery ={ 'clientId': { $in: req.body.clientId }, 'status': 'active' };
|
|
1910
|
+
let storecountQuery = { 'clientId': { $in: req.body.clientId }, 'status': 'active' };
|
|
1893
1911
|
|
|
1894
|
-
if ( req.user&&req.user.userType ==='client'&&req.user.role!='superadmin' ) {
|
|
1912
|
+
if ( req.user && req.user.userType === 'client' && req.user.role != 'superadmin' ) {
|
|
1895
1913
|
storecountQuery = { ...storecountQuery, ...{ storeId: { $in: req.body.assignedStores } } };
|
|
1896
1914
|
}
|
|
1897
1915
|
|
|
@@ -826,7 +826,7 @@ export async function checkStoreTimezoneMatchesInterval( times, storeTimezone )
|
|
|
826
826
|
const currentStoreTime = dayjs().tz( storeTimezone );
|
|
827
827
|
const intervalTime = dayjs.tz( `${currentStoreTime.format( 'YYYY-MM-DD' )} ${interval}`, 'YYYY-MM-DD HH:mm', storeTimezone );
|
|
828
828
|
const diffInMinutes = intervalTime.diff( currentStoreTime, 'minute' );
|
|
829
|
-
|
|
829
|
+
console.log( diffInMinutes );
|
|
830
830
|
return diffInMinutes >= 0 && diffInMinutes <= 15;
|
|
831
831
|
} );
|
|
832
832
|
};
|
|
@@ -917,7 +917,7 @@ export async function infraReportSent( req, res ) {
|
|
|
917
917
|
status: 1,
|
|
918
918
|
ticketDetails: 1,
|
|
919
919
|
issueClosedDate: 1,
|
|
920
|
-
|
|
920
|
+
commentText: { $ifNull: [ '$primaryIssue.comment', '-' ] },
|
|
921
921
|
otherscomment: { $ifNull: [ '$otherscomment.comment', '-' ] },
|
|
922
922
|
primaryIssue: { $ifNull: [ '$primaryIssue.reasons.primaryIssue', '-' ] },
|
|
923
923
|
secondaryIssue: { $ifNull: [ '$primaryIssue.reasons.secondaryIssue.name', '-' ] },
|
|
@@ -1436,7 +1436,7 @@ export async function edgeApplogsCheck( req, res ) {
|
|
|
1436
1436
|
item.ticketId === ticket.ticketId,
|
|
1437
1437
|
);
|
|
1438
1438
|
if ( !existsInArray ) {
|
|
1439
|
-
if ( diffInMinutes>60 ) {
|
|
1439
|
+
if ( diffInMinutes>60 &&diffInMinutes<=180 ) {
|
|
1440
1440
|
findissueEdgeApp = {
|
|
1441
1441
|
ticketId: ticket.ticketId,
|
|
1442
1442
|
edgelog: findissue,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { logger, getOpenSearchData, download, getUTC } from 'tango-app-api-middleware';
|
|
3
3
|
import { aggregateTangoTicket } from '../services/tangoTicket.service.js';
|
|
4
4
|
import { findOneStore } from '../services/store.service.js';
|
|
5
|
+
import { findOneCamera, findCamera } from '../services/camera.service.js';
|
|
5
6
|
import dayjs from 'dayjs';
|
|
6
7
|
import { findinfraReason } from '../services/infraReason.service.js';
|
|
7
8
|
import { signedUrl } from 'tango-app-api-middleware';
|
|
@@ -160,7 +161,7 @@ export async function storeTicketList( req, res ) {
|
|
|
160
161
|
primaryIssue: { $last: '$primaryIssue' },
|
|
161
162
|
secondaryIssue: { $last: '$secondaryIssue' },
|
|
162
163
|
otherscomment: { $last: '$otherscomment' },
|
|
163
|
-
|
|
164
|
+
otherscomment: { $last: '$otherscomment' },
|
|
164
165
|
},
|
|
165
166
|
},
|
|
166
167
|
{
|
|
@@ -170,7 +171,7 @@ export async function storeTicketList( req, res ) {
|
|
|
170
171
|
},
|
|
171
172
|
);
|
|
172
173
|
|
|
173
|
-
if ( req.body.filter &&req.body.filter.length>0 ) {
|
|
174
|
+
if ( req.body.filter && req.body.filter.length > 0 ) {
|
|
174
175
|
query.push( {
|
|
175
176
|
$match: {
|
|
176
177
|
primaryIssue: { $in: req.body.filter },
|
|
@@ -185,7 +186,7 @@ export async function storeTicketList( req, res ) {
|
|
|
185
186
|
'STORE ID': element.storeId,
|
|
186
187
|
'TICKET ID': element.ticketId,
|
|
187
188
|
'DATE': dayjs( element.createdAt ).format( 'DD MMM, YYYY' ),
|
|
188
|
-
'ISSUE CLOSED DATE': element.issueClosedDate?dayjs( element.issueClosedDate ).format( 'DD MMM, YYYY' ):'',
|
|
189
|
+
'ISSUE CLOSED DATE': element.issueClosedDate ? dayjs( element.issueClosedDate ).format( 'DD MMM, YYYY' ) : '',
|
|
189
190
|
'PRIMARY ISSUE': element.primaryIssue,
|
|
190
191
|
'SECONDARY ISSUE': element.secondaryIssue,
|
|
191
192
|
'STATUS': element.status,
|
|
@@ -326,8 +327,14 @@ export async function edgeAppLogTable( req, res ) {
|
|
|
326
327
|
const timeSlots = generateTimeSlots( startHour, endHour, interval, req );
|
|
327
328
|
|
|
328
329
|
const date = dayjs( timeSlots[0].from ).format( 'DD-MM-YYYY' );
|
|
329
|
-
|
|
330
|
-
|
|
330
|
+
let storeId = req.body.storeId;
|
|
331
|
+
let camera = await findCamera( { storeId: req.body.storeId, isActivated: true, isUp: true } );
|
|
332
|
+
let findMasterServer = camera.find( ( data ) => data.masterServer != null );
|
|
333
|
+
if ( findMasterServer && findMasterServer.masterServer && findMasterServer.masterServer != null ) {
|
|
334
|
+
storeId = findMasterServer.masterServer;
|
|
335
|
+
}
|
|
336
|
+
let allstreams = camera.map( ( data ) => data.streamName );
|
|
337
|
+
console.log( allstreams, storeId );
|
|
331
338
|
const internetSpeedQuery = {
|
|
332
339
|
size: 100,
|
|
333
340
|
query: {
|
|
@@ -351,7 +358,7 @@ export async function edgeAppLogTable( req, res ) {
|
|
|
351
358
|
must: [
|
|
352
359
|
{ term: { 'log_type.keyword': 'Application' } },
|
|
353
360
|
{ term: { 'store_date.keyword': date } },
|
|
354
|
-
{ term: { '
|
|
361
|
+
{ term: { 'data.store_id.keyword': req.body.storeId } },
|
|
355
362
|
{ term: { 'log_subtype.keyword': 'Zip_File_Count' } },
|
|
356
363
|
],
|
|
357
364
|
},
|
|
@@ -359,6 +366,21 @@ export async function edgeAppLogTable( req, res ) {
|
|
|
359
366
|
sort: [ { timestamp: { order: 'desc' } } ],
|
|
360
367
|
_source: [ 'data.files_pushed', 'data.files_generated', 'data.occuringTime' ],
|
|
361
368
|
};
|
|
369
|
+
const videoCountQuery = {
|
|
370
|
+
size: 100,
|
|
371
|
+
query: {
|
|
372
|
+
bool: {
|
|
373
|
+
must: [
|
|
374
|
+
{ term: { 'log_type.keyword': 'Application' } },
|
|
375
|
+
{ term: { 'store_date.keyword': date } },
|
|
376
|
+
{ term: { 'storeId.keyword': req.body.storeId } },
|
|
377
|
+
{ term: { 'log_subtype.keyword': 'VideoFileUpload_Status' } },
|
|
378
|
+
],
|
|
379
|
+
},
|
|
380
|
+
},
|
|
381
|
+
sort: [ { timestamp: { order: 'desc' } } ],
|
|
382
|
+
_source: [ 'data.files_pushed', 'data.files_generated', 'data.occuringTime' ],
|
|
383
|
+
};
|
|
362
384
|
|
|
363
385
|
const downTimeQuery = {
|
|
364
386
|
size: 100,
|
|
@@ -366,7 +388,7 @@ export async function edgeAppLogTable( req, res ) {
|
|
|
366
388
|
bool: {
|
|
367
389
|
must: [
|
|
368
390
|
{ term: { 'doc.date.keyword': date } },
|
|
369
|
-
{ term: { 'doc.store_id.keyword': storeId } },
|
|
391
|
+
{ term: { 'doc.store_id.keyword': req.body.storeId } },
|
|
370
392
|
],
|
|
371
393
|
},
|
|
372
394
|
},
|
|
@@ -374,15 +396,18 @@ export async function edgeAppLogTable( req, res ) {
|
|
|
374
396
|
};
|
|
375
397
|
|
|
376
398
|
// Execute all queries in parallel
|
|
377
|
-
const [ speedTestResult, fileCountResult, downtimeResult ] = await Promise.all( [
|
|
399
|
+
const [ speedTestResult, fileCountResult, videoCountResult, downtimeResult ] = await Promise.all( [
|
|
378
400
|
getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, internetSpeedQuery ),
|
|
379
401
|
getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, fileCountQuery ),
|
|
402
|
+
getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, videoCountQuery ),
|
|
380
403
|
getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).downTimeHourly, downTimeQuery ),
|
|
381
404
|
] );
|
|
382
405
|
// Process results
|
|
406
|
+
console.log( fileCountResult );
|
|
383
407
|
const speedTestData = speedTestResult?.body?.hits?.hits ?? [];
|
|
384
408
|
const fileCountData = fileCountResult?.body?.hits?.hits ?? [];
|
|
385
409
|
const downtimeData = downtimeResult?.body?.hits?.hits ?? [];
|
|
410
|
+
const videofileCountData = videoCountResult?.body?.hits?.hits ?? [];
|
|
386
411
|
|
|
387
412
|
for ( const obj of timeSlots ) {
|
|
388
413
|
if ( ( obj.hour ).toString().length === 1 ) {
|
|
@@ -397,7 +422,7 @@ export async function edgeAppLogTable( req, res ) {
|
|
|
397
422
|
const speedTest = speedTestData.find(
|
|
398
423
|
( item ) => Number( item._source.data.occuringTime.split( ':' )[0] ) === Number( hour ),
|
|
399
424
|
);
|
|
400
|
-
if ( speedTest&&speedTest._source.data.upload_Speed =='0 bytes' ) {
|
|
425
|
+
if ( speedTest && speedTest._source.data.upload_Speed == '0 bytes' ) {
|
|
401
426
|
obj.Internetspeed = '0 MB/sec';
|
|
402
427
|
} else {
|
|
403
428
|
obj.Internetspeed = speedTest ? `${bytesToMB( speedTest._source.data.upload_Speed.split( '.' )[0] ).toFixed( 2 )} MB/sec` : '';
|
|
@@ -411,6 +436,13 @@ export async function edgeAppLogTable( req, res ) {
|
|
|
411
436
|
|
|
412
437
|
obj.files_pushed = fileCounts.reduce( ( sum, item ) => sum + Number( item._source.data.files_pushed ), 0 ) || '';
|
|
413
438
|
obj.files_generated = fileCounts.reduce( ( sum, item ) => sum + Number( item._source.data.files_generated ), 0 ) || '';
|
|
439
|
+
// video File counts
|
|
440
|
+
const videofileCounts = videofileCountData.filter(
|
|
441
|
+
( item ) => Number( item._source.data.occuringTime.split( ':' )[0] ) === Number( hour ),
|
|
442
|
+
);
|
|
443
|
+
|
|
444
|
+
obj.videofiles_pushed = videofileCounts.reduce( ( sum, item ) => sum + Number( item._source.data.files_pushed ), 0 ) || '';
|
|
445
|
+
obj.videofiles_generated = videofileCounts.reduce( ( sum, item ) => sum + Number( item._source.data.files_generated ), 0 ) || '';
|
|
414
446
|
|
|
415
447
|
// Downtime
|
|
416
448
|
const downtime = downtimeData.find( ( item ) => Number( item._source.doc.hour ) === Number( hour ) );
|
|
@@ -431,10 +463,12 @@ export async function edgeAppLogTable( req, res ) {
|
|
|
431
463
|
if ( req.body.export ) {
|
|
432
464
|
const exportData = timeSlots.map( ( element ) => ( {
|
|
433
465
|
'Time Stamp': `${element.startTime}-${element.endTime}`,
|
|
434
|
-
'Downtime': element.downtime?element.downtime +' Mins':'--',
|
|
466
|
+
'Downtime': element.downtime ? element.downtime + ' Mins' : '--',
|
|
435
467
|
'Avg Internet Speed': element.Internetspeed,
|
|
436
|
-
'Files Generated': element.
|
|
437
|
-
'Files Pushed': element.
|
|
468
|
+
'Tracking Files Generated': element.videofiles_generated,
|
|
469
|
+
'Tracking Files Pushed': element.videofiles_pushed,
|
|
470
|
+
'Traffic Files Generated': element.files_generated,
|
|
471
|
+
'Traffic Files Pushed': element.files_pushed,
|
|
438
472
|
} ) );
|
|
439
473
|
await download( exportData, res );
|
|
440
474
|
return;
|
|
@@ -815,7 +849,7 @@ export async function streamwiseDowntime( req, res ) {
|
|
|
815
849
|
const downTimeIndex = parsedOpenSearch.downTimeHourly;
|
|
816
850
|
|
|
817
851
|
const batchRequests = TimeSlots.map( async ( obj ) => {
|
|
818
|
-
if ( ( obj.hour ).toString().length ===1 ) {
|
|
852
|
+
if ( ( obj.hour ).toString().length === 1 ) {
|
|
819
853
|
obj.hour = obj.hour.toString().padStart( 2, '0' );
|
|
820
854
|
}
|
|
821
855
|
|
|
@@ -854,6 +888,220 @@ export async function streamwiseDowntime( req, res ) {
|
|
|
854
888
|
return res.sendError( error, 500 );
|
|
855
889
|
}
|
|
856
890
|
}
|
|
891
|
+
export async function edgeAppCameralogs( req, res ) {
|
|
892
|
+
try {
|
|
893
|
+
const store = await findOneStore( { storeId: req.body.storeId } );
|
|
894
|
+
if ( !store ) {
|
|
895
|
+
return res.sendError( 'Store Not found', 204 );
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
let startHour = parseInt( store.storeProfile.open.split( ':' )[0], 10 );
|
|
899
|
+
let endHour = parseInt( store.storeProfile.close.split( ':' )[0], 10 );
|
|
900
|
+
const interval = 60; // 1 hour in minutes
|
|
901
|
+
const timeSlots = generateTimeSlots( startHour, endHour, interval, req );
|
|
902
|
+
|
|
903
|
+
const date = dayjs( timeSlots[0].from ).format( 'DD-MM-YYYY' );
|
|
904
|
+
const storeId = req.body.storeId;
|
|
905
|
+
const streamName = req.body.stream;
|
|
906
|
+
const streamData = await findOneCamera( { streamName: streamName } );
|
|
907
|
+
if ( !streamData ) {
|
|
908
|
+
return res.sendError( 'camera Not found', 204 );
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
const internetSpeedQuery = {
|
|
912
|
+
size: 100,
|
|
913
|
+
query: {
|
|
914
|
+
bool: {
|
|
915
|
+
must: [
|
|
916
|
+
{ term: { 'log_type.keyword': 'Application' } },
|
|
917
|
+
{ term: { 'store_date.keyword': date } },
|
|
918
|
+
{ term: { 'storeId.keyword': streamData.masterServer != null ? streamData.masterServer : storeId } },
|
|
919
|
+
{ term: { 'log_subtype.keyword': 'Speed_Test' } },
|
|
920
|
+
],
|
|
921
|
+
},
|
|
922
|
+
},
|
|
923
|
+
sort: [ { timestamp: { order: 'desc' } } ],
|
|
924
|
+
_source: [ 'data.upload_Speed', 'data.occuringTime' ],
|
|
925
|
+
};
|
|
926
|
+
|
|
927
|
+
const fileCountQuery = {
|
|
928
|
+
size: 100,
|
|
929
|
+
query: {
|
|
930
|
+
bool: {
|
|
931
|
+
must: [
|
|
932
|
+
{ term: { 'log_type.keyword': 'Application' } },
|
|
933
|
+
{ term: { 'store_date.keyword': date } },
|
|
934
|
+
// { term: { 'storeId.keyword': storeId } },
|
|
935
|
+
{ term: { 'data.stream_name.keyword': streamName } },
|
|
936
|
+
{ term: { 'log_subtype.keyword': 'Zip_File_Count' } },
|
|
937
|
+
],
|
|
938
|
+
},
|
|
939
|
+
},
|
|
940
|
+
sort: [ { timestamp: { order: 'desc' } } ],
|
|
941
|
+
_source: [ 'data.files_pushed', 'data.files_generated', 'data.occuringTime' ],
|
|
942
|
+
};
|
|
943
|
+
const videoCountQuery = {
|
|
944
|
+
size: 100,
|
|
945
|
+
query: {
|
|
946
|
+
bool: {
|
|
947
|
+
must: [
|
|
948
|
+
{ term: { 'log_type.keyword': 'Application' } },
|
|
949
|
+
{ term: { 'store_date.keyword': date } },
|
|
950
|
+
// { term: { 'storeId.keyword': storeId } },
|
|
951
|
+
{ term: { 'data.stream_name.keyword': streamName } },
|
|
952
|
+
|
|
953
|
+
{ term: { 'log_subtype.keyword': 'VideoFileUpload_Status' } },
|
|
954
|
+
],
|
|
955
|
+
},
|
|
956
|
+
},
|
|
957
|
+
sort: [ { timestamp: { order: 'desc' } } ],
|
|
958
|
+
_source: [ 'data.files_pushed', 'data.files_generated', 'data.occuringTime' ],
|
|
959
|
+
};
|
|
960
|
+
|
|
961
|
+
const downTimeQuery = {
|
|
962
|
+
size: 100,
|
|
963
|
+
query: {
|
|
964
|
+
bool: {
|
|
965
|
+
must: [
|
|
966
|
+
{ term: { 'doc.date.keyword': date } },
|
|
967
|
+
{ term: { 'doc.store_id.keyword': storeId } },
|
|
968
|
+
],
|
|
969
|
+
},
|
|
970
|
+
},
|
|
971
|
+
_source: [ 'doc.streamwise_downtime', 'doc.hour' ],
|
|
972
|
+
};
|
|
973
|
+
|
|
974
|
+
// Execute all queries in parallel
|
|
975
|
+
const [ speedTestResult, fileCountResult, videoCountResult, downtimeResult ] = await Promise.all( [
|
|
976
|
+
getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, internetSpeedQuery ),
|
|
977
|
+
getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, fileCountQuery ),
|
|
978
|
+
getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, videoCountQuery ),
|
|
979
|
+
getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).downTimeHourly, downTimeQuery ),
|
|
980
|
+
] );
|
|
981
|
+
// Process results
|
|
982
|
+
const speedTestData = speedTestResult?.body?.hits?.hits ?? [];
|
|
983
|
+
const fileCountData = fileCountResult?.body?.hits?.hits ?? [];
|
|
984
|
+
const downtimeData = downtimeResult?.body?.hits?.hits ?? [];
|
|
985
|
+
const videofileCountData = videoCountResult?.body?.hits?.hits ?? [];
|
|
986
|
+
|
|
987
|
+
for ( const obj of timeSlots ) {
|
|
988
|
+
if ( ( obj.hour ).toString().length === 1 ) {
|
|
989
|
+
obj.hour = obj.hour.toString().padStart( 2, '0' );
|
|
990
|
+
}
|
|
991
|
+
const hour = obj.hour;
|
|
992
|
+
obj.startTime = dayjs( obj.from ).format( 'hh:mm A' );
|
|
993
|
+
obj.endTime = dayjs( obj.to ).format( 'hh:mm A' );
|
|
994
|
+
|
|
995
|
+
// Internet speed
|
|
996
|
+
|
|
997
|
+
const speedTest = speedTestData.find(
|
|
998
|
+
( item ) => Number( item._source.data.occuringTime.split( ':' )[0] ) === Number( hour ),
|
|
999
|
+
);
|
|
1000
|
+
if ( speedTest && speedTest._source.data.upload_Speed == '0 bytes' ) {
|
|
1001
|
+
obj.Internetspeed = '0 MB/sec';
|
|
1002
|
+
} else {
|
|
1003
|
+
obj.Internetspeed = speedTest ? `${bytesToMB( speedTest._source.data.upload_Speed.split( '.' )[0] ).toFixed( 2 )} MB/sec` : '';
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
|
|
1007
|
+
// File counts
|
|
1008
|
+
const fileCounts = fileCountData.filter(
|
|
1009
|
+
( item ) => Number( item._source.data.occuringTime.split( ':' )[0] ) === Number( hour ),
|
|
1010
|
+
);
|
|
1011
|
+
|
|
1012
|
+
obj.files_pushed = fileCounts.reduce( ( sum, item ) => sum + Number( item._source.data.files_pushed ), 0 ) || '';
|
|
1013
|
+
obj.files_generated = fileCounts.reduce( ( sum, item ) => sum + Number( item._source.data.files_generated ), 0 ) || '';
|
|
1014
|
+
// video File counts
|
|
1015
|
+
const videofileCounts = videofileCountData.filter(
|
|
1016
|
+
( item ) => Number( item._source.data.occuringTime.split( ':' )[0] ) === Number( hour ),
|
|
1017
|
+
);
|
|
1018
|
+
|
|
1019
|
+
obj.videofiles_pushed = videofileCounts.reduce( ( sum, item ) => sum + Number( item._source.data.files_pushed ), 0 ) || '';
|
|
1020
|
+
obj.videofiles_generated = videofileCounts.reduce( ( sum, item ) => sum + Number( item._source.data.files_generated ), 0 ) || '';
|
|
1021
|
+
|
|
1022
|
+
// Downtime
|
|
1023
|
+
const downtime = downtimeData.find( ( item ) => Number( item._source.doc.hour ) === Number( hour ) );
|
|
1024
|
+
|
|
1025
|
+
if ( downtime ) {
|
|
1026
|
+
const streamwiseDowntime = downtime._source.doc.streamwise_downtime || [];
|
|
1027
|
+
|
|
1028
|
+
const downtimeData = streamwiseDowntime.find( ( item ) => item.stream === streamName );
|
|
1029
|
+
if ( downtimeData ) {
|
|
1030
|
+
obj.downtime = downtimeData?.down_time;
|
|
1031
|
+
} else {
|
|
1032
|
+
obj.downtime = '';
|
|
1033
|
+
}
|
|
1034
|
+
} else {
|
|
1035
|
+
obj.downtime = '';
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
if ( req.body.export ) {
|
|
1040
|
+
const exportData = timeSlots.map( ( element ) => ( {
|
|
1041
|
+
'Time Stamp': `${element.startTime}-${element.endTime}`,
|
|
1042
|
+
'Downtime': element.downtime ? element.downtime + ' Mins' : '--',
|
|
1043
|
+
'Avg Internet Speed': element.Internetspeed,
|
|
1044
|
+
'Tracking Files Generated': element.videofiles_generated,
|
|
1045
|
+
'Tracking Files Pushed': element.videofiles_pushed,
|
|
1046
|
+
'Traffic Files Generated': element.files_generated,
|
|
1047
|
+
'Traffic Files Pushed': element.files_pushed,
|
|
1048
|
+
} ) );
|
|
1049
|
+
await download( exportData, res );
|
|
1050
|
+
return;
|
|
1051
|
+
}
|
|
1052
|
+
let totalCount = 0;
|
|
1053
|
+
const query = {
|
|
1054
|
+
'size': 10000,
|
|
1055
|
+
'query': {
|
|
1056
|
+
bool: {
|
|
1057
|
+
must: [
|
|
1058
|
+
{
|
|
1059
|
+
term: {
|
|
1060
|
+
'store_date.keyword': dayjs( req.body.Date ).format( 'DD-MM-YYYY' ),
|
|
1061
|
+
},
|
|
1062
|
+
},
|
|
1063
|
+
{
|
|
1064
|
+
term: {
|
|
1065
|
+
'store_id.keyword': storeId,
|
|
1066
|
+
},
|
|
1067
|
+
},
|
|
1068
|
+
{
|
|
1069
|
+
term: {
|
|
1070
|
+
'stream_id.keyword': streamName,
|
|
1071
|
+
},
|
|
1072
|
+
},
|
|
1073
|
+
],
|
|
1074
|
+
},
|
|
1075
|
+
},
|
|
1076
|
+
'sort': [ { timestamp: { order: 'desc' } } ],
|
|
1077
|
+
'_source': [ 'fileSize', 'store_id', 'stream_id' ],
|
|
1078
|
+
|
|
1079
|
+
};
|
|
1080
|
+
|
|
1081
|
+
const storeSizeData = await getOpenSearchData(
|
|
1082
|
+
JSON.parse( process.env.OPENSEARCH ).edgeAppFilelogs,
|
|
1083
|
+
query,
|
|
1084
|
+
);
|
|
1085
|
+
if ( storeSizeData?.body?.hits?.hits == undefined || storeSizeData?.body?.hits?.hits == null ) {
|
|
1086
|
+
return res.sendError( { message: 'Data not found' }, 204 );
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
for ( const count of storeSizeData.body?.hits?.hits ) {
|
|
1090
|
+
totalCount += Number( count._source.fileSize );
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
|
|
1094
|
+
res.sendSuccess( {
|
|
1095
|
+
result: timeSlots,
|
|
1096
|
+
totalData: {
|
|
1097
|
+
totalCount: totalCount,
|
|
1098
|
+
},
|
|
1099
|
+
} );
|
|
1100
|
+
} catch ( error ) {
|
|
1101
|
+
logger.error( { error: error, function: 'streamwiseDowntime' } );
|
|
1102
|
+
return res.sendError( error, 500 );
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
857
1105
|
|
|
858
1106
|
|
|
859
1107
|
export async function livecountCheck( inputData, singleDate, req ) {
|
|
@@ -916,7 +1164,7 @@ export async function livecountCheck( inputData, singleDate, req ) {
|
|
|
916
1164
|
|
|
917
1165
|
export async function edgeappFileSize( req, res ) {
|
|
918
1166
|
try {
|
|
919
|
-
let totalCount=0;
|
|
1167
|
+
let totalCount = 0;
|
|
920
1168
|
const query = {
|
|
921
1169
|
'size': 10000,
|
|
922
1170
|
'query': {
|
|
@@ -944,12 +1192,12 @@ export async function edgeappFileSize( req, res ) {
|
|
|
944
1192
|
JSON.parse( process.env.OPENSEARCH ).edgeAppFilelogs,
|
|
945
1193
|
query,
|
|
946
1194
|
);
|
|
947
|
-
if ( storeSizeData?.body?.hits?.hits ==undefined|| storeSizeData?.body?.hits?.hits ==null ) {
|
|
1195
|
+
if ( storeSizeData?.body?.hits?.hits == undefined || storeSizeData?.body?.hits?.hits == null ) {
|
|
948
1196
|
return res.sendError( { message: 'Data not found' }, 204 );
|
|
949
1197
|
}
|
|
950
1198
|
|
|
951
1199
|
for ( const count of storeSizeData.body?.hits?.hits ) {
|
|
952
|
-
totalCount+=Number( count._source.fileSize );
|
|
1200
|
+
totalCount += Number( count._source.fileSize );
|
|
953
1201
|
}
|
|
954
1202
|
|
|
955
1203
|
const queryAvg = {
|
|
@@ -989,7 +1237,7 @@ export async function edgeappFileSize( req, res ) {
|
|
|
989
1237
|
|
|
990
1238
|
res.sendSuccess( {
|
|
991
1239
|
totalCount: totalCount,
|
|
992
|
-
avgCount: totalCount/( storeAvgSizeData.body.aggregations.grouped_by_store_id.buckets.length ),
|
|
1240
|
+
avgCount: totalCount / ( storeAvgSizeData.body.aggregations.grouped_by_store_id.buckets.length ),
|
|
993
1241
|
totalCam: storeAvgSizeData.body.aggregations.grouped_by_store_id.buckets.length,
|
|
994
1242
|
} );
|
|
995
1243
|
} catch ( error ) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import express from 'express';
|
|
3
3
|
import { isAllowedSessionHandler } from 'tango-app-api-middleware';
|
|
4
|
-
import { storeTicketList, storeTicketcard, edgeAppLogTable, viewedgeAppLog, isAllowedStore, cameraAngleChange, datewiseDowntime, streamwiseDowntime, edgeappFileSize } from '../controllers/storeInfra.controlller.js';
|
|
4
|
+
import { storeTicketList, storeTicketcard, edgeAppLogTable, viewedgeAppLog, isAllowedStore, cameraAngleChange, edgeAppCameralogs, datewiseDowntime, streamwiseDowntime, edgeappFileSize } from '../controllers/storeInfra.controlller.js';
|
|
5
5
|
export const storeInfraRouter = express.Router();
|
|
6
6
|
|
|
7
7
|
storeInfraRouter.post( '/storeTicketList', isAllowedSessionHandler, isAllowedStore, storeTicketList );
|
|
@@ -11,5 +11,6 @@ storeInfraRouter.post( '/viewedgeAppLog', isAllowedSessionHandler, isAllowedStor
|
|
|
11
11
|
storeInfraRouter.post( '/cameraAngleChange', isAllowedSessionHandler, isAllowedStore, cameraAngleChange );
|
|
12
12
|
storeInfraRouter.post( '/datewiseDowntime', isAllowedSessionHandler, isAllowedStore, datewiseDowntime );
|
|
13
13
|
storeInfraRouter.post( '/streamwiseDowntime', isAllowedSessionHandler, isAllowedStore, streamwiseDowntime );
|
|
14
|
+
storeInfraRouter.post( '/edgeAppCameralogs', isAllowedSessionHandler, isAllowedStore, edgeAppCameralogs );
|
|
14
15
|
|
|
15
16
|
storeInfraRouter.post( '/edgeappFileSize', isAllowedSessionHandler, isAllowedStore, edgeappFileSize );
|
|
@@ -3,6 +3,12 @@ import cameraModel from 'tango-api-schema/schema/camera.model.js';
|
|
|
3
3
|
export async function aggregateCamera( query ) {
|
|
4
4
|
return await cameraModel.aggregate( query );
|
|
5
5
|
}
|
|
6
|
+
export async function findOneCamera( query ) {
|
|
7
|
+
return await cameraModel.findOne( query );
|
|
8
|
+
}
|
|
9
|
+
export async function findCamera( query ) {
|
|
10
|
+
return await cameraModel.find( query );
|
|
11
|
+
}
|
|
6
12
|
export async function updateOneCamera( query, record ) {
|
|
7
13
|
return await cameraModel.updateOne( query, { $set: record } );
|
|
8
14
|
}
|