tango-app-api-infra 3.9.3 → 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
|
@@ -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';
|
|
@@ -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
|
},
|
|
@@ -366,7 +373,7 @@ export async function edgeAppLogTable( req, res ) {
|
|
|
366
373
|
must: [
|
|
367
374
|
{ term: { 'log_type.keyword': 'Application' } },
|
|
368
375
|
{ term: { 'store_date.keyword': date } },
|
|
369
|
-
{ term: { 'storeId.keyword': storeId } },
|
|
376
|
+
{ term: { 'storeId.keyword': req.body.storeId } },
|
|
370
377
|
{ term: { 'log_subtype.keyword': 'VideoFileUpload_Status' } },
|
|
371
378
|
],
|
|
372
379
|
},
|
|
@@ -381,7 +388,7 @@ export async function edgeAppLogTable( req, res ) {
|
|
|
381
388
|
bool: {
|
|
382
389
|
must: [
|
|
383
390
|
{ term: { 'doc.date.keyword': date } },
|
|
384
|
-
{ term: { 'doc.store_id.keyword': storeId } },
|
|
391
|
+
{ term: { 'doc.store_id.keyword': req.body.storeId } },
|
|
385
392
|
],
|
|
386
393
|
},
|
|
387
394
|
},
|
|
@@ -396,6 +403,7 @@ export async function edgeAppLogTable( req, res ) {
|
|
|
396
403
|
getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).downTimeHourly, downTimeQuery ),
|
|
397
404
|
] );
|
|
398
405
|
// Process results
|
|
406
|
+
console.log( fileCountResult );
|
|
399
407
|
const speedTestData = speedTestResult?.body?.hits?.hits ?? [];
|
|
400
408
|
const fileCountData = fileCountResult?.body?.hits?.hits ?? [];
|
|
401
409
|
const downtimeData = downtimeResult?.body?.hits?.hits ?? [];
|
|
@@ -895,6 +903,10 @@ export async function edgeAppCameralogs( req, res ) {
|
|
|
895
903
|
const date = dayjs( timeSlots[0].from ).format( 'DD-MM-YYYY' );
|
|
896
904
|
const storeId = req.body.storeId;
|
|
897
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
|
+
}
|
|
898
910
|
|
|
899
911
|
const internetSpeedQuery = {
|
|
900
912
|
size: 100,
|
|
@@ -903,7 +915,7 @@ export async function edgeAppCameralogs( req, res ) {
|
|
|
903
915
|
must: [
|
|
904
916
|
{ term: { 'log_type.keyword': 'Application' } },
|
|
905
917
|
{ term: { 'store_date.keyword': date } },
|
|
906
|
-
{ term: { 'storeId.keyword': storeId } },
|
|
918
|
+
{ term: { 'storeId.keyword': streamData.masterServer != null ? streamData.masterServer : storeId } },
|
|
907
919
|
{ term: { 'log_subtype.keyword': 'Speed_Test' } },
|
|
908
920
|
],
|
|
909
921
|
},
|
|
@@ -919,7 +931,7 @@ export async function edgeAppCameralogs( req, res ) {
|
|
|
919
931
|
must: [
|
|
920
932
|
{ term: { 'log_type.keyword': 'Application' } },
|
|
921
933
|
{ term: { 'store_date.keyword': date } },
|
|
922
|
-
{ term: { 'storeId.keyword': storeId } },
|
|
934
|
+
// { term: { 'storeId.keyword': storeId } },
|
|
923
935
|
{ term: { 'data.stream_name.keyword': streamName } },
|
|
924
936
|
{ term: { 'log_subtype.keyword': 'Zip_File_Count' } },
|
|
925
937
|
],
|
|
@@ -935,7 +947,7 @@ export async function edgeAppCameralogs( req, res ) {
|
|
|
935
947
|
must: [
|
|
936
948
|
{ term: { 'log_type.keyword': 'Application' } },
|
|
937
949
|
{ term: { 'store_date.keyword': date } },
|
|
938
|
-
{ term: { 'storeId.keyword': storeId } },
|
|
950
|
+
// { term: { 'storeId.keyword': storeId } },
|
|
939
951
|
{ term: { 'data.stream_name.keyword': streamName } },
|
|
940
952
|
|
|
941
953
|
{ term: { 'log_subtype.keyword': 'VideoFileUpload_Status' } },
|
|
@@ -1050,7 +1062,12 @@ export async function edgeAppCameralogs( req, res ) {
|
|
|
1050
1062
|
},
|
|
1051
1063
|
{
|
|
1052
1064
|
term: {
|
|
1053
|
-
'store_id.keyword':
|
|
1065
|
+
'store_id.keyword': storeId,
|
|
1066
|
+
},
|
|
1067
|
+
},
|
|
1068
|
+
{
|
|
1069
|
+
term: {
|
|
1070
|
+
'stream_id.keyword': streamName,
|
|
1054
1071
|
},
|
|
1055
1072
|
},
|
|
1056
1073
|
],
|
|
@@ -1073,49 +1090,11 @@ export async function edgeAppCameralogs( req, res ) {
|
|
|
1073
1090
|
totalCount += Number( count._source.fileSize );
|
|
1074
1091
|
}
|
|
1075
1092
|
|
|
1076
|
-
const queryAvg = {
|
|
1077
|
-
query: {
|
|
1078
|
-
bool: {
|
|
1079
|
-
must: [
|
|
1080
|
-
{
|
|
1081
|
-
term: {
|
|
1082
|
-
'store_date.keyword': dayjs( req.body.Date ).format( 'DD-MM-YYYY' ),
|
|
1083
|
-
},
|
|
1084
|
-
},
|
|
1085
|
-
{
|
|
1086
|
-
term: {
|
|
1087
|
-
'store_id.keyword': req.body.storeId,
|
|
1088
|
-
},
|
|
1089
|
-
},
|
|
1090
|
-
],
|
|
1091
|
-
},
|
|
1092
|
-
},
|
|
1093
|
-
sort: [ { timestamp: { order: 'desc' } } ],
|
|
1094
|
-
_source: [ 'fileSize', 'store_id', 'stream_id' ],
|
|
1095
|
-
aggs: {
|
|
1096
|
-
// Grouping by store_id
|
|
1097
|
-
grouped_by_store_id: {
|
|
1098
|
-
terms: {
|
|
1099
|
-
field: 'stream_id.keyword', // Group by store_id
|
|
1100
|
-
size: 1000, // Limit the number of groups (adjust based on needs)
|
|
1101
|
-
},
|
|
1102
|
-
},
|
|
1103
|
-
},
|
|
1104
|
-
};
|
|
1105
|
-
|
|
1106
|
-
const storeAvgSizeData = await getOpenSearchData(
|
|
1107
|
-
JSON.parse( process.env.OPENSEARCH ).edgeAppFilelogs,
|
|
1108
|
-
queryAvg,
|
|
1109
|
-
);
|
|
1110
|
-
|
|
1111
1093
|
|
|
1112
1094
|
res.sendSuccess( {
|
|
1113
1095
|
result: timeSlots,
|
|
1114
1096
|
totalData: {
|
|
1115
1097
|
totalCount: totalCount,
|
|
1116
|
-
avgCount: totalCount / ( storeAvgSizeData.body.aggregations.grouped_by_store_id.buckets.length ),
|
|
1117
|
-
totalCam: storeAvgSizeData.body.aggregations.grouped_by_store_id.buckets.length,
|
|
1118
|
-
|
|
1119
1098
|
},
|
|
1120
1099
|
} );
|
|
1121
1100
|
} catch ( error ) {
|
|
@@ -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
|
}
|