tango-app-api-infra 3.0.87-dev → 3.0.89-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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-infra",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.89-dev",
|
|
4
4
|
"description": "infra",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"nodemon": "^3.1.0",
|
|
28
28
|
"swagger-ui-express": "^5.0.0",
|
|
29
29
|
"tango-api-schema": "^2.0.103",
|
|
30
|
-
"tango-app-api-middleware": "^1.0.
|
|
30
|
+
"tango-app-api-middleware": "^1.0.72-test",
|
|
31
31
|
"winston": "^3.12.0",
|
|
32
32
|
"winston-daily-rotate-file": "^5.0.0"
|
|
33
33
|
},
|
|
@@ -876,9 +876,21 @@ export async function cameraAngleChange( req, res ) {
|
|
|
876
876
|
file_path: changeDetected[0].path,
|
|
877
877
|
};
|
|
878
878
|
let Image = await signedUrl( params );
|
|
879
|
+
let expectedparams = {
|
|
880
|
+
Bucket: appConfig.cloud.aws.bucket.cameraAngle,
|
|
881
|
+
file_path: changeDetected[0].expected,
|
|
882
|
+
};
|
|
883
|
+
let expectedImage = await signedUrl( expectedparams );
|
|
884
|
+
let actualparams = {
|
|
885
|
+
Bucket: appConfig.cloud.aws.bucket.cameraAngle,
|
|
886
|
+
file_path: changeDetected[0].actual,
|
|
887
|
+
};
|
|
888
|
+
let actualImage = await signedUrl( actualparams );
|
|
879
889
|
res.sendSuccess( {
|
|
880
890
|
StreamName: req.body.StreamName,
|
|
881
891
|
angleChangeImage: Image,
|
|
892
|
+
expected: expectedImage,
|
|
893
|
+
actual: actualImage,
|
|
882
894
|
anglechange: true,
|
|
883
895
|
resolution: changeDetected[0].resolution,
|
|
884
896
|
} );
|
|
@@ -907,7 +919,7 @@ function getDatesArray( fromDate, toDate ) {
|
|
|
907
919
|
}
|
|
908
920
|
|
|
909
921
|
function paginateArray( array, offset, limit ) {
|
|
910
|
-
return array.slice( ( offset - 1 ) * limit, offset*limit );
|
|
922
|
+
return array.slice( ( offset - 1 ) * limit, offset * limit );
|
|
911
923
|
}
|
|
912
924
|
export async function datewiseDowntime( req, res ) {
|
|
913
925
|
try {
|
|
@@ -927,7 +939,7 @@ export async function datewiseDowntime( req, res ) {
|
|
|
927
939
|
end: endHour,
|
|
928
940
|
interval: 60,
|
|
929
941
|
};
|
|
930
|
-
req.body.Date= singleDate;
|
|
942
|
+
req.body.Date = singleDate;
|
|
931
943
|
let storedata = await livecountCheck( inputData, req );
|
|
932
944
|
result.push( storedata[0] );
|
|
933
945
|
}
|
|
@@ -936,11 +948,71 @@ export async function datewiseDowntime( req, res ) {
|
|
|
936
948
|
data: result,
|
|
937
949
|
} );
|
|
938
950
|
} catch ( error ) {
|
|
939
|
-
logger.error( { error: error, function: '
|
|
951
|
+
logger.error( { error: error, function: 'datewiseDowntime' } );
|
|
940
952
|
return res.sendError( error, 500 );
|
|
941
953
|
}
|
|
942
954
|
}
|
|
955
|
+
export async function streamwiseDowntime( req, res ) {
|
|
956
|
+
try {
|
|
957
|
+
const store = await findOneStore( { storeId: req.body.storeId } );
|
|
958
|
+
if ( !store ) {
|
|
959
|
+
return res.sendError( 'Stores Not fond', 204 );
|
|
960
|
+
}
|
|
961
|
+
let startHour = store.storeProfile.open.split( ':' )[0];
|
|
962
|
+
let endHour = store.storeProfile.close.split( ':' )[0];
|
|
963
|
+
const interval = 60; // 1 hour in minutes
|
|
964
|
+
const TimeSlots = generateTimeSlots( startHour, endHour, interval, req );
|
|
965
|
+
let timewise = [];
|
|
966
|
+
for ( const obj of TimeSlots ) {
|
|
967
|
+
obj.startTime = dayjs( obj.from ).format( 'hh:mm A' );
|
|
968
|
+
obj.endTime = dayjs( obj.to ).format( 'hh:mm A' );
|
|
969
|
+
let downTimeQuery = {
|
|
970
|
+
'size': 1,
|
|
971
|
+
'query': {
|
|
972
|
+
'bool': {
|
|
973
|
+
'must': [
|
|
974
|
+
{
|
|
975
|
+
'term': {
|
|
976
|
+
'doc.date.keyword': dayjs( obj.from ).format( 'DD-MM-YYYY' ),
|
|
977
|
+
},
|
|
978
|
+
},
|
|
979
|
+
{
|
|
980
|
+
'term': {
|
|
981
|
+
'doc.store_id.keyword': req.body.storeId,
|
|
982
|
+
},
|
|
983
|
+
},
|
|
984
|
+
{
|
|
985
|
+
'terms': {
|
|
986
|
+
'doc.hour.keyword': [ obj.hour ],
|
|
987
|
+
},
|
|
988
|
+
},
|
|
989
|
+
],
|
|
990
|
+
|
|
991
|
+
},
|
|
992
|
+
},
|
|
993
|
+
};
|
|
994
|
+
const downtime = await getOpenSearchData( 'live_downtime_hourly', downTimeQuery );
|
|
943
995
|
|
|
996
|
+
let streamwiseDowntime = downtime.body.hits.hits.length > 0 ? downtime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
|
|
997
|
+
if ( streamwiseDowntime.length > 0 ) {
|
|
998
|
+
console.log( streamwiseDowntime );
|
|
999
|
+
for ( let stream of streamwiseDowntime ) {
|
|
1000
|
+
if ( stream.stream === req.body.stream ) {
|
|
1001
|
+
obj.downTime= stream.down_time;
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
} else {
|
|
1005
|
+
obj.downTime= '';
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
timewise.push( obj );
|
|
1009
|
+
}
|
|
1010
|
+
res.sendSuccess( timewise );
|
|
1011
|
+
} catch ( error ) {
|
|
1012
|
+
logger.error( { error: error, function: 'streamwiseDowntime' } );
|
|
1013
|
+
return res.sendError( error, 500 );
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
944
1016
|
|
|
945
1017
|
export async function livecountCheck( inputData, req ) {
|
|
946
1018
|
return new Promise( async ( Resolve, Reject ) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import express from 'express';
|
|
3
3
|
import { isAllowedSessionHandler, authorize } from 'tango-app-api-middleware';
|
|
4
|
-
import { storeTicketList, storeTicketcard, edgeAppLogTable, viewedgeAppLog, cameraAngleChange, datewiseDowntime } from '../controllers/storeInfra.controlller.js';
|
|
4
|
+
import { storeTicketList, storeTicketcard, edgeAppLogTable, viewedgeAppLog, cameraAngleChange, datewiseDowntime, streamwiseDowntime } from '../controllers/storeInfra.controlller.js';
|
|
5
5
|
export const storeInfraRouter = express.Router();
|
|
6
6
|
|
|
7
7
|
storeInfraRouter.post( '/storeTicketList', isAllowedSessionHandler, authorize( {
|
|
@@ -29,3 +29,7 @@ storeInfraRouter.post( '/datewiseDowntime', isAllowedSessionHandler, authorize(
|
|
|
29
29
|
userType: [ 'client', 'tango' ], access: [
|
|
30
30
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
31
31
|
} ), datewiseDowntime );
|
|
32
|
+
storeInfraRouter.post( '/streamwiseDowntime', isAllowedSessionHandler, authorize( {
|
|
33
|
+
userType: [ 'client', 'tango' ], access: [
|
|
34
|
+
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
35
|
+
} ), streamwiseDowntime );
|