tango-app-api-analysis-traffic 3.0.0-alpha.17 → 3.0.0-alpha.18

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-analysis-traffic",
3
- "version": "3.0.0-alpha.17",
3
+ "version": "3.0.0-alpha.18",
4
4
  "description": "Traffic Analysis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -444,7 +444,7 @@ export const storesMapV1 = async ( req, res ) => {
444
444
  'spocDetails': { $arrayElemAt: [ '$spocDetails', 0 ] },
445
445
  'businessType': 1,
446
446
  'storeType': 1,
447
- 'avgFootfall': '100',
447
+ 'avgFootfall': '',
448
448
  'avgWeekdayFootfall': '',
449
449
  'avgWeekendFootfall': '',
450
450
  'hourlyFootfall': '',
@@ -465,36 +465,6 @@ export const storesMapV1 = async ( req, res ) => {
465
465
  return res.sendError( 'No Content', 204 );
466
466
  } else {
467
467
  if ( getStores.length >0 ) {
468
- reqestData.fromDate = reqestData.storeDate;
469
- reqestData.toDate = reqestData.storeDate;
470
- let hourlyLamdaURL = 'https://ksxkjnhwwzvrgp7ngttw2ribsy0twqip.lambda-url.ap-south-1.on.aws/';
471
- let hourlyResultData = await LamdaServiceCall( hourlyLamdaURL, reqestData );
472
- if ( hourlyResultData && hourlyResultData.status_code == '200' && hourlyResultData.hourData.length>0 ) {
473
- for ( let i = 0; i < getStores.length; i++ ) {
474
- for ( let j = 0; j < hourlyResultData.hourData.length; j++ ) {
475
- if ( getStores[i].storeId == hourlyResultData.hourData[j].storeId ) {
476
- getStores[i].hourlyFootfall = hourlyResultData.hourData[j].hourlyFootfall;
477
- getStores[i].openTime = hourlyResultData.hourData[j].openTime;
478
- getStores[i].closeTime = hourlyResultData.hourData[j].closeTime;
479
- }
480
- }
481
- }
482
- }
483
- let fromDate = new Date( dayjs( reqestData.fromDate ).subtract( 30, 'days' ) );
484
- reqestData.fromDate = dayjs( fromDate ).format( 'YYYY-MM-DD' );
485
- let footfallLamdaURL = 'https://3ircml3r6dm7fbiif3ti2wwdee0zqhyb.lambda-url.ap-south-1.on.aws/';
486
- let footfallResultData = await LamdaServiceCall( footfallLamdaURL, reqestData );
487
- if ( footfallResultData && footfallResultData.status_code == '200' && footfallResultData.avgData.length>0 ) {
488
- for ( let k = 0; k < getStores.length; k++ ) {
489
- for ( let l = 0; l < footfallResultData.avgData.length; l++ ) {
490
- if ( getStores[k].storeId == footfallResultData.avgData[l].storeId ) {
491
- getStores[k].avgWeekendFootfall = footfallResultData.avgData[l].avgWeekendFootfall;
492
- getStores[k].avgWeekdayFootfall = footfallResultData.avgData[l].avgWeekdayFootfall;
493
- getStores[k].avgFootfall = footfallResultData.avgData[l].avgFootfall;
494
- }
495
- }
496
- }
497
- }
498
468
  return res.sendSuccess( { storeData: getStores } );
499
469
  } else {
500
470
  return res.sendError( 'No Content', 204 );
@@ -1319,10 +1289,11 @@ export const getMySubscription = async ( req, res ) => {
1319
1289
  }
1320
1290
  };
1321
1291
 
1322
- export const getStoreCameraImage = async ( req, res ) => {
1292
+ export const getStoreMapData = async ( req, res ) => {
1323
1293
  try {
1324
1294
  let reqestData = req.body;
1325
1295
  if ( reqestData.storeId && reqestData.storeId.length > 0 ) {
1296
+ let cameraBaseImage = '';
1326
1297
  const bucket= JSON.parse( process.env.BUCKET );
1327
1298
  if ( bucket && bucket.baseImage && bucket.baseImage != '' ) {
1328
1299
  const camera = await findCamera( { storeId: reqestData.storeId[0], isUp: true, isActivated: true }, { thumbnailImage: 1 } );
@@ -1331,16 +1302,38 @@ export const getStoreCameraImage = async ( req, res ) => {
1331
1302
  file_path: camera.thumbnailImage,
1332
1303
  Bucket: bucket.baseImage,
1333
1304
  };
1334
- let cameraBaseImage = await signedUrl( params );
1335
- let resultData = { cameraBaseImage: cameraBaseImage };
1336
-
1337
- return res.sendSuccess( resultData );
1338
- } else {
1339
- return res.sendError( 'No Camera', 400 );
1305
+ cameraBaseImage = await signedUrl( params );
1340
1306
  }
1341
- } else {
1342
- return res.sendError( 'Bucket Name Missing', 400 );
1343
1307
  }
1308
+ reqestData.fromDate = reqestData.storeDate;
1309
+ reqestData.toDate = reqestData.storeDate;
1310
+ let avgData = {
1311
+ 'avgFootfall': '',
1312
+ 'avgWeekdayFootfall': '',
1313
+ 'avgWeekendFootfall': '',
1314
+ };
1315
+ let hourlyData = {
1316
+ 'hourlyFootfall': '',
1317
+ 'openTime': '',
1318
+ 'closeTime': '',
1319
+ };
1320
+ let hourlyLamdaURL = 'https://ksxkjnhwwzvrgp7ngttw2ribsy0twqip.lambda-url.ap-south-1.on.aws/';
1321
+ let hourlyResultData = await LamdaServiceCall( hourlyLamdaURL, reqestData );
1322
+ if ( hourlyResultData && hourlyResultData.hourData.length>0 ) {
1323
+ hourlyData.hourlyFootfall = hourlyResultData.hourData[0].hourlyFootfall;
1324
+ hourlyData.openTime = hourlyResultData.hourData[0].openTime;
1325
+ hourlyData.closeTime = hourlyResultData.hourData[0].closeTime;
1326
+ }
1327
+ let fromDate = new Date( dayjs( reqestData.fromDate ).subtract( 30, 'days' ) );
1328
+ reqestData.fromDate = dayjs( fromDate ).format( 'YYYY-MM-DD' );
1329
+ let footfallLamdaURL = 'https://3ircml3r6dm7fbiif3ti2wwdee0zqhyb.lambda-url.ap-south-1.on.aws/';
1330
+ let footfallResultData = await LamdaServiceCall( footfallLamdaURL, reqestData );
1331
+ if ( footfallResultData && footfallResultData.avgData.length>0 ) {
1332
+ avgData.avgFootfall = footfallResultData.avgData[0].avgFootfall;
1333
+ avgData.avgWeekdayFootfall = footfallResultData.avgData[0].avgWeekdayFootfall;
1334
+ avgData.avgWeekendFootfall = footfallResultData.avgData[0].avgWeekendFootfall;
1335
+ }
1336
+ return res.sendSuccess( { cameraBaseImage: cameraBaseImage, hourlyData: hourlyData, avgData: avgData } );
1344
1337
  } else {
1345
1338
  return res.sendError( 'Store Id rewuired', 400 );
1346
1339
  }
@@ -211,6 +211,7 @@ export const getMyProductParams = {
211
211
  export const getStoreCameraImageSchema = joi.object( {
212
212
  clientId: joi.string().required(),
213
213
  storeId: joi.array().optional().empty(),
214
+ storeDate: joi.string().required(),
214
215
  } );
215
216
 
216
217
  export const getStoreCameraImageParams = {
@@ -53,7 +53,7 @@ import {
53
53
  headerGroupsV1,
54
54
  isAllowedClient,
55
55
  getMySubscription,
56
- getStoreCameraImage,
56
+ getStoreMapData,
57
57
  } from '../controllers/tangoTrafficV1.controllers.js';
58
58
 
59
59
 
@@ -186,6 +186,6 @@ analysisTrafficRouter
186
186
  ],
187
187
  } ), validate( validationDtos.validateHeaderParams ), headerStoresV1 )
188
188
  .post( '/getMySubscription', isAllowedSessionHandler, validate( validationDtos.getMyProductParams ), getMySubscription )
189
- .post( '/getStoreCameraImage', isAllowedSessionHandler, validate( validationDtos.getStoreCameraImageParams ), getStoreCameraImage );
189
+ .post( '/getStoreMapData', isAllowedSessionHandler, validate( validationDtos.getStoreCameraImageParams ), getStoreMapData );
190
190
 
191
191
  export default analysisTrafficRouter;