tango-app-api-analysis-traffic 3.8.7-vms.15 → 3.8.7-vms.17

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.8.7-vms.15",
3
+ "version": "3.8.7-vms.17",
4
4
  "description": "Traffic Analysis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -533,17 +533,12 @@ export async function footFallImages( req, res ) {
533
533
  actionTypes.forEach( ( type ) => {
534
534
  const mapping = getMappingForType( type );
535
535
  if ( type === 'tagging' ) {
536
- const revisedFootfall = mapping.revicedFootfall ?? 0;
537
- const revisedPerc =
538
- footfallValue > 0 ?
539
- `${Math.round( ( revisedFootfall / footfallValue ) * 100 )}` :
540
- '0';
541
536
  const countObj = mapping.count ? [ ...mapping.count ] : [];
542
537
  temp.push( {
543
538
  actionType: type,
544
539
  footfall: footfallValue,
545
- revicedFootfall: revisedFootfall,
546
- revicedPerc: revisedPerc,
540
+ revicedFootfall: mapping.revicedFootfall ?? 0,
541
+ revicedPerc: mapping.revisedPerc ?? '--',
547
542
  count: countObj,
548
543
  createdAt: mapping.createdAt ?? '',
549
544
  createdByEmail: mapping.createdByEmail ?? '',
@@ -551,18 +546,14 @@ export async function footFallImages( req, res ) {
551
546
  createdByRole: mapping.createdByRole ?? '',
552
547
  isUp: false,
553
548
  } );
554
- } else if ( type !== 'tagging' && mapping.status === 'Closed' ) {
555
- const revisedFootfall = mapping.revicedFootfall ?? 0;
556
- const revisedPerc =
557
- footfallValue > 0 ?
558
- `${Math.round( ( revisedFootfall / footfallValue ) * 100 )}` :
559
- '0';
549
+ }
550
+ if ( type !== 'tagging' && mapping.status === 'Closed' ) {
560
551
  const countObj = mapping.count ? [ ...mapping.count ] : [];
561
552
  temp.push( {
562
553
  actionType: type,
563
554
  footfall: footfallValue,
564
- revicedFootfall: revisedFootfall,
565
- revicedPerc: revisedPerc,
555
+ revicedFootfall: mapping.revicedFootfall ?? 0,
556
+ revicedPerc: mapping.revisedPerc ?? '--',
566
557
  count: countObj,
567
558
  createdAt: mapping.createdAt ?? '',
568
559
  createdByEmail: mapping.createdByEmail ?? '',
@@ -3129,29 +3129,30 @@ export const managerTrafficDensityExport = async ( req, res ) => {
3129
3129
  }
3130
3130
  };
3131
3131
 
3132
- // async function getGeocodedAddress( lat, lng ) {
3133
- // try {
3134
- // const apiKey = 'AIzaSyDlOezgwQO0JviD0aizrCuN1FY9tcWfR3o'; // Use this if you're using dotenv
3135
- // const url = `https://maps.googleapis.com/maps/api/geocode/json?latlng=${lat},${lng}&key=${apiKey}`;
3136
-
3137
- // const requestOptions = {
3138
- // method: 'GET',
3139
- // headers: {
3140
- // 'Content-Type': 'application/json',
3141
- // },
3142
- // };
3143
- // const response = await fetch( url, requestOptions );
3144
- // console.log( 'response =>', response );
3145
- // if ( !response.ok ) {
3146
- // throw new Error( `Response status: ${response.status}` );
3147
- // return false;
3148
- // }
3149
- // const json = await response.json();
3150
- // return json;
3151
- // } catch ( error ) {
3152
- // console.log( 'getGeocodedAddress error =>', error );
3153
- // logger.error( { error: error, message: data, function: 'getGeocodedAddress' } );
3154
- // }
3155
- // }
3156
- // let getGEO = await getGeocodedAddress( 12.900260100404893, 80.23384232089138 );
3157
- // console.log( 'getGEO =>', getGEO );
3132
+
3133
+ export const getStoreListv2 = async ( req, res ) => {
3134
+ try {
3135
+ let reqestData = req.body;
3136
+ let getClientData = await getClientConfig( reqestData.clientId );
3137
+ if ( !getClientData ) {
3138
+ return res.sendError( 'Invalid Client Id', 400 );
3139
+ }
3140
+ reqestData.featureConfigs = getClientData.featureConfigs;
3141
+ let LamdaURL = 'https://nmnnlq3ie65bljcvxauhxmsrpa0edhfa.lambda-url.ap-south-1.on.aws/';
3142
+ let resultData = await LamdaServiceCall( LamdaURL, reqestData );
3143
+ if ( resultData ) {
3144
+ if ( resultData.status_code == '200' ) {
3145
+ return res.sendSuccess( resultData );
3146
+ } else {
3147
+ return res.sendError( 'No Content', 204 );
3148
+ }
3149
+ } else {
3150
+ return res.sendError( 'No Content', 204 );
3151
+ }
3152
+ } catch ( error ) {
3153
+ const err = error.message || 'Internal Server Error';
3154
+ logger.error( { error: error, message: req.body, function: 'getStoreListv2' } );
3155
+ return res.sendError( err, 500 );
3156
+ }
3157
+ };
3158
+
@@ -239,6 +239,17 @@ export const validateCountryHeaderSchemav2 = joi.object( {
239
239
  export const validateCountryHeaderParamsv2 = {
240
240
  body: validateCountryHeaderSchemav2,
241
241
  };
242
+
243
+ export const validateGetStoreListSchemav2 = joi.object( {
244
+ clientId: joi.string().required(),
245
+ storeId: joi.array().items( joi.string().required() ).required(),
246
+ downtime: joi.array().items( joi.string().required() ).required(),
247
+ fromDate: joi.string().required(),
248
+ toDate: joi.string().required(),
249
+ } );
250
+ export const validateGetStoreList = {
251
+ body: validateGetStoreListSchemav2,
252
+ };
242
253
  export const getMyProductSchema = joi.object( {
243
254
  clientId: joi.string().required(),
244
255
  storeId: joi.array().optional().empty(),
@@ -92,6 +92,7 @@ import {
92
92
  funnelV3,
93
93
  getStoreMapDataV3,
94
94
  managerTrafficDensityExport,
95
+ getStoreListv2,
95
96
  } from '../controllers/tangoTrafficV3.controllers.js';
96
97
  analysisTrafficRouter
97
98
  .get( '/welcome', welcome )
@@ -175,5 +176,6 @@ analysisTrafficRouter
175
176
  .post( '/headerCountry_v2', isAllowedSessionHandler, isAllowedClient, validate( validationDtos.validateCountryHeaderParamsv2 ), getAssinedStore, headerCountryV2 )
176
177
  .post( '/checkTodayReportStatus', isAllowedSessionHandler, checkTodayReportStatus )
177
178
  .post( '/headerZoneV2', isAllowedSessionHandler, headerZoneV2 )
178
- .post( '/trafficDensityExport_v2', managerTrafficDensityExport );
179
+ .post( '/trafficDensityExport_v2', managerTrafficDensityExport )
180
+ .post( '/get-store-list-v2', isAllowedSessionHandler, isAllowedClient, validate( validationDtos.validateGetStoreList ), getStoreListv2 );
179
181
  export default analysisTrafficRouter;