tango-app-api-analysis-traffic 3.0.0-alpha.45 → 3.0.0-alpha.47

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.45",
3
+ "version": "3.0.0-alpha.47",
4
4
  "description": "Traffic Analysis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -255,13 +255,29 @@ export async function getNobData( req, res ) {
255
255
  }
256
256
  } );
257
257
 
258
+ let conversionCount;
259
+
258
260
  if ( count === 1 ) {
261
+ switch ( getClient?.featureConfigs?.conversionCalculation ) {
262
+ case 'footfall-count':
263
+ conversionCount = temp[0]?.footfallCount? ( data?._source?.nobCount/temp[0]?.footfallCount )*100 : null;
264
+ break;
265
+ case 'billable-entities':
266
+ conversionCount = temp[0]?.potentialBuyers? ( data?._source?.nobCount/temp[0]?.potentialBuyers )*100 : null;
267
+ break;
268
+ case 'engagers-count':
269
+ conversionCount = temp[0]?.engagersCount? ( data?._source?.nobCount/temp[0]?.engagersCount )*100 : null;
270
+ break;
271
+ default:
272
+ conversionCount = temp[0]?.engagersCount? ( data?._source?.nobCount/temp[0]?.engagersCount )*100 : null;
273
+ }
259
274
  result.push( {
260
275
 
261
276
  ...data._source,
262
277
  footfallCount: temp[0]?.footfallCount || null,
263
278
  engagersCount: temp[0]?.engagersCount || null,
264
279
  potentialBuyers: temp[0]?.potentialBuyers || null,
280
+ conversionRate: parseFloat( conversionCount.toFixed( 1 ) ),
265
281
 
266
282
  } );
267
283
  } else {
@@ -271,6 +287,7 @@ export async function getNobData( req, res ) {
271
287
  footfallCount: null,
272
288
  engagersCount: null,
273
289
  potentialBuyers: null,
290
+ conversionRate: null,
274
291
 
275
292
  } );
276
293
  }
@@ -279,17 +296,31 @@ export async function getNobData( req, res ) {
279
296
  const chunkedMappingData = await chunkArray( result, 10 );
280
297
  const promises = chunkedMappingData.map( async ( chunk ) => {
281
298
  const exportData = [];
282
- chunk.forEach( ( element ) => {
299
+
300
+
301
+ chunk.forEach( ( element, index ) => {
283
302
  exportData.push( {
284
303
  'Store Name': element.storeName,
285
304
  'Store Id': element.storeId,
286
- 'Date': element.nobDate,
287
- 'Footfall': element.footfallCount,
305
+ 'Date': dayjs( element.nobDate ).format( 'D MMM,YYYY' ),
288
306
  'NoB\'s Count': element.nobCount,
289
- 'Conversion Rate': `${( element.footfallCount/element.nobCount )*100}%`,
307
+ 'Conversion Rate': `${element.conversionRate} %`,
290
308
 
291
309
 
292
310
  } );
311
+ switch ( getClient?.featureConfigs?.conversionCalculation ) {
312
+ case 'footfall-count':
313
+ exportData['Footfall'] = element.footfallCount;
314
+ break;
315
+ case 'billable-entities':
316
+ exportData['Potential Buyers'] = element.potentialBuyers;
317
+ break;
318
+ case 'engagers-count':
319
+ exportData['Engagers Count'] = element.engagersCount;
320
+ break;
321
+ default:
322
+ exportData['Engagers Count'] = element.engagersCount;
323
+ }
293
324
  } );
294
325
  return exportData;
295
326
  } );