tango-app-api-infra 3.1.34-beta.43 → 3.1.34-beta.45
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
|
@@ -1023,7 +1023,7 @@ export async function infraReportSent( req, res ) {
|
|
|
1023
1023
|
contentType: 'application/xlsx', // e.g., 'application/pdf'
|
|
1024
1024
|
};
|
|
1025
1025
|
|
|
1026
|
-
const subject =
|
|
1026
|
+
const subject = `${client.clientName} Daily Digest - Infra Downtime Report - ${date}`;
|
|
1027
1027
|
const fileContent = readFileSync( join() + '/src/hbs/dailyInfraReport.hbs', 'utf8' );
|
|
1028
1028
|
const htmlContent = handlebars.compile( fileContent );
|
|
1029
1029
|
let Uidomain = `${JSON.parse( process.env.URL ).domain}`;
|
|
@@ -885,3 +885,89 @@ export async function livecountCheck( inputData, singleDate, req ) {
|
|
|
885
885
|
throw err;
|
|
886
886
|
}
|
|
887
887
|
}
|
|
888
|
+
|
|
889
|
+
export async function edgeappFileSize( req, res ) {
|
|
890
|
+
try {
|
|
891
|
+
let totalCount=0;
|
|
892
|
+
const query = {
|
|
893
|
+
'size': 10000,
|
|
894
|
+
'query': {
|
|
895
|
+
bool: {
|
|
896
|
+
must: [
|
|
897
|
+
{
|
|
898
|
+
term: {
|
|
899
|
+
'store_date.keyword': dayjs( req.body.Date ).format( 'DD-MM-YYYY' ),
|
|
900
|
+
},
|
|
901
|
+
},
|
|
902
|
+
{
|
|
903
|
+
term: {
|
|
904
|
+
'store_id.keyword': req.body.storeId,
|
|
905
|
+
},
|
|
906
|
+
},
|
|
907
|
+
],
|
|
908
|
+
},
|
|
909
|
+
},
|
|
910
|
+
'sort': [ { timestamp: { order: 'desc' } } ],
|
|
911
|
+
'_source': [ 'fileSize', 'store_id', 'stream_id' ],
|
|
912
|
+
|
|
913
|
+
};
|
|
914
|
+
|
|
915
|
+
const storeSizeData = await getOpenSearchData(
|
|
916
|
+
JSON.parse( process.env.OPENSEARCH ).edgeAppFilelogs,
|
|
917
|
+
query,
|
|
918
|
+
);
|
|
919
|
+
if ( storeSizeData.body?.hits?.hits ==undefined|| storeSizeData.body?.hits?.hits ==null ) {
|
|
920
|
+
return res.sendError( { message: 'Data not found' }, 204 );
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
for ( const count of storeSizeData.body?.hits?.hits ) {
|
|
924
|
+
totalCount+=Number( count._source.fileSize );
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
const queryAvg = {
|
|
928
|
+
query: {
|
|
929
|
+
bool: {
|
|
930
|
+
must: [
|
|
931
|
+
{
|
|
932
|
+
term: {
|
|
933
|
+
'store_date.keyword': dayjs( req.body.Date ).format( 'DD-MM-YYYY' ),
|
|
934
|
+
},
|
|
935
|
+
},
|
|
936
|
+
{
|
|
937
|
+
term: {
|
|
938
|
+
'store_id.keyword': req.body.storeId,
|
|
939
|
+
},
|
|
940
|
+
},
|
|
941
|
+
],
|
|
942
|
+
},
|
|
943
|
+
},
|
|
944
|
+
sort: [ { timestamp: { order: 'desc' } } ],
|
|
945
|
+
_source: [ 'fileSize', 'store_id', 'stream_id' ],
|
|
946
|
+
aggs: {
|
|
947
|
+
// Grouping by store_id
|
|
948
|
+
grouped_by_store_id: {
|
|
949
|
+
terms: {
|
|
950
|
+
field: 'stream_id.keyword', // Group by store_id
|
|
951
|
+
size: 1000, // Limit the number of groups (adjust based on needs)
|
|
952
|
+
},
|
|
953
|
+
},
|
|
954
|
+
},
|
|
955
|
+
};
|
|
956
|
+
|
|
957
|
+
const storeAvgSizeData = await getOpenSearchData(
|
|
958
|
+
JSON.parse( process.env.OPENSEARCH ).edgeAppFilelogs,
|
|
959
|
+
queryAvg,
|
|
960
|
+
);
|
|
961
|
+
|
|
962
|
+
res.sendSuccess( {
|
|
963
|
+
totalCount: totalCount,
|
|
964
|
+
avgCount: totalCount/( storeAvgSizeData.body.aggregations.grouped_by_store_id.buckets.length ),
|
|
965
|
+
totalCam: storeAvgSizeData.body.aggregations.grouped_by_store_id.buckets.length,
|
|
966
|
+
} );
|
|
967
|
+
} catch ( error ) {
|
|
968
|
+
console.error( error );
|
|
969
|
+
|
|
970
|
+
logger.error( { error: error, function: 'edgeappFileSize' } );
|
|
971
|
+
return res.sendError( error, 500 );
|
|
972
|
+
}
|
|
973
|
+
}
|
|
@@ -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, cameraAngleChange, datewiseDowntime, streamwiseDowntime } from '../controllers/storeInfra.controlller.js';
|
|
4
|
+
import { storeTicketList, storeTicketcard, edgeAppLogTable, viewedgeAppLog, cameraAngleChange, datewiseDowntime, streamwiseDowntime, edgeappFileSize } from '../controllers/storeInfra.controlller.js';
|
|
5
5
|
export const storeInfraRouter = express.Router();
|
|
6
6
|
|
|
7
7
|
storeInfraRouter.post( '/storeTicketList', isAllowedSessionHandler, storeTicketList );
|
|
@@ -11,3 +11,5 @@ storeInfraRouter.post( '/viewedgeAppLog', isAllowedSessionHandler, viewedgeAppLo
|
|
|
11
11
|
storeInfraRouter.post( '/cameraAngleChange', isAllowedSessionHandler, cameraAngleChange );
|
|
12
12
|
storeInfraRouter.post( '/datewiseDowntime', isAllowedSessionHandler, datewiseDowntime );
|
|
13
13
|
storeInfraRouter.post( '/streamwiseDowntime', isAllowedSessionHandler, streamwiseDowntime );
|
|
14
|
+
|
|
15
|
+
storeInfraRouter.post( '/edgeappFileSize', isAllowedSessionHandler, edgeappFileSize );
|