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

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/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
 
2
2
 
3
3
  import { analysisTrafficRouter } from './src/routes/traffic.routes.js';
4
+ import { mobileTrafficAnalysisRouter } from './src/routes/mobileTraffic.routes.js';
4
5
 
5
- export { analysisTrafficRouter };
6
+ export { analysisTrafficRouter, mobileTrafficAnalysisRouter };
6
7
 
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.19",
4
4
  "description": "Traffic Analysis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -0,0 +1,470 @@
1
+ import { logger } from 'tango-app-api-middleware';
2
+ import * as clientService from '../services/clients.services.js';
3
+ import {
4
+ findOneStore,
5
+ } from '../services/stores.service.js';
6
+
7
+
8
+ async function LamdaServiceCall( url, data ) {
9
+ try {
10
+ const requestOptions = {
11
+ method: 'POST',
12
+ headers: {
13
+ 'Content-Type': 'application/json',
14
+ },
15
+ body: JSON.stringify( data ),
16
+ };
17
+ const response = await fetch( url, requestOptions );
18
+ if ( !response.ok ) {
19
+ throw new Error( `Response status: ${response.status}` );
20
+
21
+ return false;
22
+ }
23
+ const json = await response.json();
24
+ return json;
25
+ } catch ( error ) {
26
+ logger.error( { error: error, message: data, function: 'LamdaServiceCall' } );
27
+ return false;
28
+ }
29
+ }
30
+
31
+ // ///// V1 API's ///////
32
+ export const cardsFunnelV1 = async ( req, res ) => {
33
+ try {
34
+ let reqestData = req.body;
35
+ let getClientData = await clientService.findOne( { clientId: reqestData.clientId } );
36
+ if ( !getClientData ) {
37
+ return res.sendError( 'Invalid Client Id', 400 );
38
+ }
39
+ reqestData.currency = getClientData.paymentInvoice?.currencyType || 'INR';
40
+ reqestData.revenue = getClientData.averageTransactionValue || '0';
41
+ let LamdaURL = 'https://55mojecvuvtphucgsalx5jtyki0untzp.lambda-url.ap-south-1.on.aws/';
42
+ let resultData = await LamdaServiceCall( LamdaURL, reqestData );
43
+ if ( resultData ) {
44
+ if ( resultData.status_code == '200' ) {
45
+ return res.sendSuccess( resultData );
46
+ } else {
47
+ return res.sendError( 'No Content', 204 );
48
+ }
49
+ } else {
50
+ return res.sendError( 'No Content', 204 );
51
+ }
52
+ } catch ( error ) {
53
+ logger.error( { error: error, message: req.query, function: 'cardsFunnelV1' } );
54
+ return res.sendError( { error: error }, 500 );
55
+ }
56
+ };
57
+
58
+ export const cardsGraphsV1 = async ( req, res ) => {
59
+ try {
60
+ let reqestData = req.body;
61
+ let LamdaURL = 'https://xvsz4gd4erdlmvhv33hhyot3ui0xzitq.lambda-url.ap-south-1.on.aws/';
62
+ let resultData = await LamdaServiceCall( LamdaURL, reqestData );
63
+ if ( resultData ) {
64
+ if ( resultData.status_code == '200' ) {
65
+ return res.sendSuccess( resultData );
66
+ } else {
67
+ return res.sendError( 'No Content', 204 );
68
+ }
69
+ } else {
70
+ return res.sendError( 'No Content', 204 );
71
+ }
72
+ } catch ( error ) {
73
+ logger.error( { error: error, message: req.query, function: 'cardsFunnelV1' } );
74
+ return res.sendError( { error: error }, 500 );
75
+ }
76
+ };
77
+
78
+ export const recapVideoV1 = async ( req, res ) => {
79
+ try {
80
+ let reqestData = req.body;
81
+ let LamdaURL = 'https://u7xzph4jkl72sbefz2xx5rjw540rocck.lambda-url.ap-south-1.on.aws/';
82
+ let resultData = await LamdaServiceCall( LamdaURL, reqestData );
83
+ if ( resultData ) {
84
+ if ( resultData.status_code == '200' ) {
85
+ return res.sendSuccess( resultData );
86
+ } else {
87
+ return res.sendError( 'No Content', 204 );
88
+ }
89
+ } else {
90
+ return res.sendError( 'No Content', 204 );
91
+ }
92
+ } catch ( error ) {
93
+ logger.error( { error: error, message: req.query, function: 'cardsFunnelV1' } );
94
+ return res.sendError( { error: error }, 500 );
95
+ }
96
+ };
97
+
98
+ export const densityDwellV1 = async ( req, res ) => {
99
+ try {
100
+ let reqestData = req.body;
101
+ reqestData.hourFormat = 12;
102
+ let LamdaURL = 'https://wh2d4dkgsao5kbwpjxbmchcjja0cxjhv.lambda-url.ap-south-1.on.aws/';
103
+ let resultData = await LamdaServiceCall( LamdaURL, reqestData );
104
+ if ( resultData ) {
105
+ if ( resultData.status_code == '200' ) {
106
+ return res.sendSuccess( resultData );
107
+ } else {
108
+ return res.sendError( 'No Content', 204 );
109
+ }
110
+ } else {
111
+ return res.sendError( 'No Content', 204 );
112
+ }
113
+ } catch ( error ) {
114
+ logger.error( { error: error, message: req.query, function: 'cardsFunnelV1' } );
115
+ return res.sendError( { error: error }, 500 );
116
+ }
117
+ };
118
+
119
+ export const overallCardsV1 = async ( req, res ) => {
120
+ try {
121
+ let reqestData = req.body;
122
+ let LamdaURL = 'https://dugu3ghkgalnpaydf2wdjp37240pzcmy.lambda-url.ap-south-1.on.aws/';
123
+ let resultData = await LamdaServiceCall( LamdaURL, reqestData );
124
+ if ( resultData ) {
125
+ if ( resultData.status_code == '200' ) {
126
+ return res.sendSuccess( resultData );
127
+ } else {
128
+ return res.sendError( 'No Content', 204 );
129
+ }
130
+ } else {
131
+ return res.sendError( 'No Content', 204 );
132
+ }
133
+ } catch ( error ) {
134
+ logger.error( { error: error, message: req.query, function: 'cardsFunnelV1' } );
135
+ return res.sendError( { error: error }, 500 );
136
+ }
137
+ };
138
+
139
+ export const overallHourlyChartV1 = async ( req, res ) => {
140
+ try {
141
+ let reqestData = req.body;
142
+ reqestData.hourFormat = 12;
143
+ let LamdaURL = 'https://p3xcs56mkjj4sfugvsibhyto3i0gdbda.lambda-url.ap-south-1.on.aws/';
144
+ let resultData = await LamdaServiceCall( LamdaURL, reqestData );
145
+ if ( resultData ) {
146
+ if ( resultData.status_code == '200' ) {
147
+ return res.sendSuccess( resultData );
148
+ } else {
149
+ return res.sendError( 'No Content', 204 );
150
+ }
151
+ } else {
152
+ return res.sendError( 'No Content', 204 );
153
+ }
154
+ } catch ( error ) {
155
+ logger.error( { error: error, message: req.query, function: 'cardsFunnelV1' } );
156
+ return res.sendError( { error: error }, 500 );
157
+ }
158
+ };
159
+
160
+ export const overallChartV1 = async ( req, res ) => {
161
+ try {
162
+ let reqestData = req.body;
163
+ let LamdaURL = 'https://wtcllrsyec4iwkx6sg7xi2b7se0seawx.lambda-url.ap-south-1.on.aws/';
164
+ let resultData = await LamdaServiceCall( LamdaURL, reqestData );
165
+ if ( resultData ) {
166
+ if ( resultData.status_code == '200' ) {
167
+ return res.sendSuccess( resultData );
168
+ } else {
169
+ return res.sendError( 'No Content', 204 );
170
+ }
171
+ } else {
172
+ return res.sendError( 'No Content', 204 );
173
+ }
174
+ } catch ( error ) {
175
+ logger.error( { error: error, message: req.query, function: 'cardsFunnelV1' } );
176
+ return res.sendError( { error: error }, 500 );
177
+ }
178
+ };
179
+
180
+ export const singleStoreChartV1 = async ( req, res ) => {
181
+ try {
182
+ let reqestData = req.body;
183
+ let LamdaURL = 'https://j2mqa4qhmku3e7htuptsjvpumi0qkhkf.lambda-url.ap-south-1.on.aws/';
184
+ let resultData = await LamdaServiceCall( LamdaURL, reqestData );
185
+ if ( resultData ) {
186
+ if ( resultData.status_code == '200' ) {
187
+ return res.sendSuccess( resultData );
188
+ } else {
189
+ return res.sendError( 'No Content', 204 );
190
+ }
191
+ } else {
192
+ return res.sendError( 'No Content', 204 );
193
+ }
194
+ } catch ( error ) {
195
+ logger.error( { error: error, message: req.query, function: 'cardsFunnelV1' } );
196
+ return res.sendError( { error: error }, 500 );
197
+ }
198
+ };
199
+
200
+ export const demographicChartV1 = async ( req, res ) => {
201
+ try {
202
+ let reqestData = req.body;
203
+ let LamdaURL = 'https://7mslk3sde3m663mrgmwlc4rfou0alphk.lambda-url.ap-south-1.on.aws/';
204
+ let resultData = await LamdaServiceCall( LamdaURL, reqestData );
205
+ if ( resultData ) {
206
+ if ( resultData.status_code == '200' ) {
207
+ return res.sendSuccess( resultData );
208
+ } else {
209
+ return res.sendError( 'No Content', 204 );
210
+ }
211
+ } else {
212
+ return res.sendError( 'No Content', 204 );
213
+ }
214
+ } catch ( error ) {
215
+ logger.error( { error: error, message: req.query, function: 'cardsFunnelV1' } );
216
+ return res.sendError( { error: error }, 500 );
217
+ }
218
+ };
219
+
220
+ export const buyerChartV1 = async ( req, res ) => {
221
+ try {
222
+ let reqestData = req.body;
223
+ let LamdaURL = 'https://2i76wug6swytd7fej3d2fvd2xa0ujxhz.lambda-url.ap-south-1.on.aws/';
224
+ let resultData = await LamdaServiceCall( LamdaURL, reqestData );
225
+ if ( resultData ) {
226
+ if ( resultData.status_code == '200' ) {
227
+ return res.sendSuccess( resultData );
228
+ } else {
229
+ return res.sendError( 'No Content', 204 );
230
+ }
231
+ } else {
232
+ return res.sendError( 'No Content', 204 );
233
+ }
234
+ } catch ( error ) {
235
+ logger.error( { error: error, message: req.query, function: 'cardsFunnelV1' } );
236
+ return res.sendError( { error: error }, 500 );
237
+ }
238
+ };
239
+
240
+ export const footfallDirectoryFoldersV1 = async ( req, res ) => {
241
+ try {
242
+ let reqestData = req.body;
243
+ reqestData.hourFormat = 12;
244
+ let LamdaURL = 'https://waxlhd7lfdlmyrkrdyv77najka0ayihq.lambda-url.ap-south-1.on.aws/';
245
+ let resultData = await LamdaServiceCall( LamdaURL, reqestData );
246
+ if ( resultData ) {
247
+ if ( resultData.status_code == '200' ) {
248
+ return res.sendSuccess( resultData );
249
+ } else {
250
+ return res.sendError( 'No Content', 204 );
251
+ }
252
+ } else {
253
+ return res.sendError( 'No Content', 204 );
254
+ }
255
+ } catch ( error ) {
256
+ logger.error( { error: error, message: req.query, function: 'cardsFunnelV1' } );
257
+ return res.sendError( { error: error }, 500 );
258
+ }
259
+ };
260
+
261
+ export const footfallDirectoryV1 = async ( req, res ) => {
262
+ try {
263
+ let reqestData = req.body;
264
+ let LamdaURL = 'https://waxlhd7lfdlmyrkrdyv77najka0ayihq.lambda-url.ap-south-1.on.aws/';
265
+ let resultData = await LamdaServiceCall( LamdaURL, reqestData );
266
+ if ( resultData ) {
267
+ if ( resultData.status_code == '200' ) {
268
+ return res.sendSuccess( resultData );
269
+ } else {
270
+ return res.sendError( 'No Content', 204 );
271
+ }
272
+ } else {
273
+ return res.sendError( 'No Content', 204 );
274
+ }
275
+ } catch ( error ) {
276
+ logger.error( { error: error, message: req.query, function: 'cardsFunnelV1' } );
277
+ return res.sendError( { error: error }, 500 );
278
+ }
279
+ };
280
+
281
+ export const footfallTrendV1 = async ( req, res ) => {
282
+ try {
283
+ let reqestData = req.body;
284
+ let LamdaURL = 'https://l5uacls7kfyham5d7pd3i6c6pq0pflem.lambda-url.ap-south-1.on.aws/';
285
+ let resultData = await LamdaServiceCall( LamdaURL, reqestData );
286
+ if ( resultData ) {
287
+ if ( resultData.status_code == '200' ) {
288
+ return res.sendSuccess( resultData );
289
+ } else {
290
+ return res.sendError( 'No Content', 204 );
291
+ }
292
+ } else {
293
+ return res.sendError( 'No Content', 204 );
294
+ }
295
+ } catch ( error ) {
296
+ logger.error( { error: error, message: req.query, function: 'cardsFunnelV1' } );
297
+ return res.sendError( { error: error }, 500 );
298
+ }
299
+ };
300
+
301
+ export const storeOperationV1 = async ( req, res ) => {
302
+ try {
303
+ let reqestData = req.body;
304
+ let LamdaURL = 'https://mezoc2jy25t73v6eit57s3px6i0hxkwk.lambda-url.ap-south-1.on.aws/';
305
+ let resultData = await LamdaServiceCall( LamdaURL, reqestData );
306
+ if ( resultData ) {
307
+ if ( resultData.status_code == '200' ) {
308
+ return res.sendSuccess( resultData );
309
+ } else {
310
+ return res.sendError( 'No Content', 204 );
311
+ }
312
+ } else {
313
+ return res.sendError( 'No Content', 204 );
314
+ }
315
+ } catch ( error ) {
316
+ logger.error( { error: error, message: req.query, function: 'cardsFunnelV1' } );
317
+ return res.sendError( { error: error }, 500 );
318
+ }
319
+ };
320
+
321
+ export const performanceMatrixV1 = async ( req, res ) => {
322
+ try {
323
+ let reqestData = req.body;
324
+ let LamdaURL = 'https://5l3pjpivqpyboludmbridailpu0axrov.lambda-url.ap-south-1.on.aws/';
325
+ let resultData = await LamdaServiceCall( LamdaURL, reqestData );
326
+ if ( resultData ) {
327
+ if ( resultData.status_code == '200' ) {
328
+ return res.sendSuccess( resultData );
329
+ } else {
330
+ return res.sendError( 'No Content', 204 );
331
+ }
332
+ } else {
333
+ return res.sendError( 'No Content', 204 );
334
+ }
335
+ } catch ( error ) {
336
+ logger.error( { error: error, message: req.query, function: 'performanceMatrixV1' } );
337
+ return res.sendError( { error: error }, 500 );
338
+ }
339
+ };
340
+
341
+ export const zoneDwellTimeSplitV1 = async ( req, res ) => {
342
+ try {
343
+ let reqestData = req.body;
344
+ let LamdaURL = 'https://7tfzazsi6lcejnjdzijv7bwg7y0yxhdx.lambda-url.ap-south-1.on.aws/';
345
+ let resultData = await LamdaServiceCall( LamdaURL, reqestData );
346
+ if ( resultData ) {
347
+ if ( resultData.status_code == '200' ) {
348
+ return res.sendSuccess( resultData );
349
+ } else {
350
+ return res.sendError( 'No Content', 204 );
351
+ }
352
+ } else {
353
+ return res.sendError( 'No Content', 204 );
354
+ }
355
+ } catch ( error ) {
356
+ logger.error( { error: error, message: req.query, function: 'trafficCards' } );
357
+ return res.sendError( { error: error }, 500 );
358
+ }
359
+ };
360
+
361
+ export async function isAllowedClient( req, res, next ) {
362
+ try {
363
+ let reqestData = req.body;
364
+ let getUserEmail = req.user.email;
365
+ let getUserType = req.user.userType;
366
+ let getClientId = req.user.clientId;
367
+ let getRole = req.user.role;
368
+
369
+ if ( getUserType == 'tango' ) {
370
+ if ( getRole == 'superadmin' ) {
371
+ next();
372
+ } else {
373
+ const assignedQuery = {
374
+ userEmail: getUserEmail,
375
+ assignedType: 'client',
376
+ assignedValue: reqestData.clientId,
377
+ };
378
+ const getAssignedType = await findOneUserAssignedStore( assignedQuery );
379
+ if ( getAssignedType ) {
380
+ next();
381
+ } else {
382
+ return res.sendError( 'Client Not Assigned', 400 );
383
+ }
384
+ }
385
+ } else if ( getUserType == 'client' ) {
386
+ if ( getClientId == reqestData.clientId ) {
387
+ next();
388
+ } else {
389
+ return res.sendError( 'Client Not Assigned', 400 );
390
+ }
391
+ } else {
392
+ return res.sendError( 'Client Not Assigned', 400 );
393
+ }
394
+ } catch ( error ) {
395
+ logger.error( { error: error, function: 'isAllowedClient' } );
396
+ return res.sendError( error, 500 );
397
+ }
398
+ }
399
+
400
+
401
+ export const getMySubscription = async ( req, res ) => {
402
+ try {
403
+ let reqestData = req.body;
404
+ let getClientData = await clientService.findOne( { clientId: reqestData.clientId }, { planDetails: 1 } );
405
+ if ( getClientData ) {
406
+ if ( getClientData.planDetails && getClientData.planDetails.product && getClientData.planDetails.product.length>0 ) {
407
+ let clientSubscription = {};
408
+ let clientProducts = {
409
+ tangoTraffic: false,
410
+ tangoZone: false,
411
+ tangoTrax: false,
412
+ };
413
+ clientSubscription.subscriptionType = getClientData.planDetails.subscriptionType;
414
+ let actualProduct = getClientData.planDetails.product;
415
+ for ( let clientIndex = 0; clientIndex < actualProduct.length; clientIndex++ ) {
416
+ if ( actualProduct[clientIndex].productName == 'tangoTraffic' ) {
417
+ clientProducts.tangoTraffic = true;
418
+ }
419
+ if ( actualProduct[clientIndex].productName == 'tangoZone' ) {
420
+ clientProducts.tangoZone = true;
421
+ }
422
+ if ( actualProduct[clientIndex].tangoTrax == 'tangoTrax' ) {
423
+ clientProducts.tangoTrax = true;
424
+ }
425
+ }
426
+ clientSubscription.product = clientProducts;
427
+ let storeSubscription = {};
428
+ let storeProducts = {
429
+ tangoTraffic: false,
430
+ tangoZone: false,
431
+ tangoTrax: false,
432
+ };
433
+
434
+ if ( reqestData.storeId && reqestData.storeId.length>0 ) {
435
+ let getStoreData = await findOneStore( { clientId: reqestData.clientId, storeId: { $in: reqestData.storeId[0] } }, { product: 1 } );
436
+ if ( getStoreData ) {
437
+ for ( let storeIndex = 0; storeIndex < getStoreData.product.length; storeIndex++ ) {
438
+ if ( getStoreData.product[storeIndex] == 'tangoTraffic' ) {
439
+ storeProducts.tangoTraffic = true;
440
+ }
441
+
442
+ if ( getStoreData.product[storeIndex] == 'tangoZone' ) {
443
+ storeProducts.tangoZone = true;
444
+ }
445
+
446
+ if ( getStoreData.product[storeIndex] == 'tangoTrax' ) {
447
+ storeProducts.tangoTrax = true;
448
+ }
449
+ }
450
+ storeSubscription.product = storeProducts;
451
+ } else {
452
+ storeSubscription.product = [];
453
+ }
454
+ } else {
455
+ storeSubscription.product = [];
456
+ }
457
+
458
+ let resultData = { clientSubscription, storeSubscription };
459
+ return res.sendSuccess( resultData );
460
+ } else {
461
+ return res.sendError( 'Not Subscribe', 400 );
462
+ }
463
+ } else {
464
+ return res.sendError( 'Invalid Client Id', 400 );
465
+ }
466
+ } catch ( error ) {
467
+ logger.error( { error: error, message: req.query, function: 'getMySubscription' } );
468
+ return res.sendError( { error: error }, 500 );
469
+ }
470
+ };
@@ -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 = {
@@ -0,0 +1,191 @@
1
+ import express from 'express';
2
+ import { validate, isAllowedSessionHandler, authorize } from 'tango-app-api-middleware';
3
+ import * as validationDtos from '../dtos/validation.dtos.js';
4
+ export const mobileTrafficAnalysisRouter = express.Router();
5
+ import {
6
+ cardsFunnelV1,
7
+ cardsGraphsV1,
8
+ recapVideoV1,
9
+ densityDwellV1,
10
+ overallCardsV1,
11
+ overallHourlyChartV1,
12
+ overallChartV1,
13
+ singleStoreChartV1,
14
+ demographicChartV1,
15
+ footfallDirectoryFoldersV1,
16
+ footfallDirectoryV1,
17
+ footfallTrendV1,
18
+ storeOperationV1,
19
+ performanceMatrixV1,
20
+ zoneDwellTimeSplitV1,
21
+ isAllowedClient,
22
+ getMySubscription,
23
+ buyerChartV1,
24
+ } from '../controllers/mobileTraffic.controllers.js';
25
+
26
+ mobileTrafficAnalysisRouter
27
+ .post( '/cardsFunnel_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
28
+
29
+ userType: [ 'tango', 'client' ], access: [
30
+
31
+ { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
32
+
33
+ ],
34
+
35
+ } ), validate( validationDtos.validateCardFunnelParams ), cardsFunnelV1 )
36
+
37
+ .post( '/cardsGraphs_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
38
+
39
+ userType: [ 'tango', 'client' ], access: [
40
+
41
+ { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
42
+
43
+ ],
44
+
45
+ } ), validate( validationDtos.validateCardGraphParams ), cardsGraphsV1 )
46
+
47
+ .post( '/recapVideo_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
48
+
49
+ userType: [ 'tango', 'client' ], access: [
50
+
51
+ { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
52
+
53
+ ],
54
+
55
+ } ), validate( validationDtos.validateRecapVideoParams ), recapVideoV1 )
56
+
57
+ .post( '/densityDwell_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
58
+
59
+ userType: [ 'tango', 'client' ], access: [
60
+
61
+ { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
62
+
63
+ ],
64
+
65
+ } ), validate( validationDtos.validateDensityDwellParams ), densityDwellV1 )
66
+
67
+ .post( '/overallCards_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
68
+
69
+ userType: [ 'tango', 'client' ], access: [
70
+
71
+ { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
72
+
73
+ ],
74
+
75
+ } ), validate( validationDtos.validateOverallCharParams ), overallCardsV1 )
76
+
77
+ .post( '/overallHourlyChart_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
78
+
79
+ userType: [ 'tango', 'client' ], access: [
80
+
81
+ { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
82
+
83
+ ],
84
+
85
+ } ), validate( validationDtos.validateOverallCharParams ), overallHourlyChartV1 )
86
+
87
+ .post( '/overallChart_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
88
+
89
+ userType: [ 'tango', 'client' ], access: [
90
+
91
+ { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
92
+
93
+ ],
94
+
95
+ } ), validate( validationDtos.validateOverallCharParams ), overallChartV1 )
96
+
97
+ .post( '/singleStoreChart_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
98
+
99
+ userType: [ 'tango', 'client' ], access: [
100
+
101
+ { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
102
+
103
+ ],
104
+
105
+ } ), validate( validationDtos.validateSingleStoreChartParams ), singleStoreChartV1 )
106
+
107
+ .post( '/demographicChart_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
108
+
109
+ userType: [ 'tango', 'client' ], access: [
110
+
111
+ { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
112
+
113
+ ],
114
+
115
+ } ), validate( validationDtos.validateDemographicChartParams ), demographicChartV1 )
116
+
117
+ .post( '/buyerChart_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
118
+
119
+ userType: [ 'tango', 'client' ], access: [
120
+
121
+ { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
122
+
123
+ ],
124
+
125
+ } ), validate( validationDtos.validateBuyerChartParams ), buyerChartV1 )
126
+
127
+ .post( '/footfallDirectoryFolders_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
128
+
129
+ userType: [ 'tango', 'client' ], access: [
130
+
131
+ { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
132
+
133
+ ],
134
+
135
+ } ), validate( validationDtos.validateFootfallDirectoryFoldersParams ), footfallDirectoryFoldersV1 )
136
+
137
+ .post( '/footfallDirectory_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
138
+
139
+ userType: [ 'tango', 'client' ], access: [
140
+
141
+ { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
142
+
143
+ ],
144
+
145
+ } ), validate( validationDtos.validateFootfallDirectoryParams ), footfallDirectoryV1 )
146
+
147
+ .post( '/footfallTrend_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
148
+
149
+ userType: [ 'tango', 'client' ], access: [
150
+
151
+ { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
152
+
153
+ ],
154
+
155
+ } ), validate( validationDtos.validateFootfallTrendParams ), footfallTrendV1 )
156
+
157
+ .post( '/storeOperation_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
158
+
159
+ userType: [ 'tango', 'client' ], access: [
160
+
161
+ { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
162
+
163
+ ],
164
+
165
+ } ), validate( validationDtos.validateStoreOperationParams ), storeOperationV1 )
166
+
167
+ .post( '/performanceMatrix_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
168
+
169
+ userType: [ 'tango', 'client' ], access: [
170
+
171
+ { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
172
+
173
+ ],
174
+
175
+ } ), validate( validationDtos.validateperformanceMatrixParams ), performanceMatrixV1 )
176
+
177
+ .post( '/zoneDwellTimeSplit_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
178
+
179
+ userType: [ 'tango', 'client' ], access: [
180
+
181
+ { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
182
+
183
+ ],
184
+
185
+ } ), validate( validationDtos.validateStoreOperationParams ), zoneDwellTimeSplitV1 )
186
+
187
+ .post( '/getMySubscription_v1', isAllowedSessionHandler, validate( validationDtos.getMyProductParams ), getMySubscription );
188
+
189
+
190
+ export default mobileTrafficAnalysisRouter;
191
+
@@ -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;