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

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.47",
3
+ "version": "3.0.0-alpha.48",
4
4
  "description": "Traffic Analysis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -156,7 +156,7 @@ export async function getNobData( req, res ) {
156
156
  return res.sendError( 'No data found', 204 );
157
157
  }
158
158
  const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( new Date( inputData.toDate ) ) );
159
-
159
+ let temp ={};
160
160
  let filter = [
161
161
  {
162
162
  'terms': {
@@ -170,28 +170,47 @@ export async function getNobData( req, res ) {
170
170
  ];
171
171
  if ( req.user.role !== 'superadmin' && req.user.userType !== 'tango' ) {
172
172
  filter.push(
173
- req.user.userType !== 'tango',
173
+ {
174
+ 'terms': {
175
+ 'storeId.keyword': inputData?.assignedStores,
176
+ },
177
+ },
174
178
  );
175
179
  }
180
+ temp = {
181
+ 'must': filter,
182
+ };
176
183
 
177
184
  if ( inputData.searchValue && inputData.searchValue!== '' ) {
178
185
  const searchValue = escapeSpecialChars( inputData.searchValue );
179
186
  logger.info( { searchvalue: inputData.searchValue, searchValue: searchValue } );
180
- filter.push(
187
+ temp = {
188
+ 'must': filter,
189
+ 'should': [
181
190
  {
182
191
  'wildcard': {
183
192
  'storeId.keyword': {
184
193
  'value': `${searchValue}*`,
185
194
  },
195
+ },
196
+ },
197
+ {
198
+ 'wildcard': {
186
199
  'storeCode.keyword': {
187
200
  'value': `${searchValue}*`,
188
201
  },
202
+ },
203
+ },
204
+ {
205
+ 'wildcard': {
189
206
  'storeName.keyword': {
190
207
  'value': `${searchValue}*`,
191
208
  },
192
209
  },
193
210
  },
194
- );
211
+ ],
212
+ 'minimum_should_match': 1,
213
+ };
195
214
  }
196
215
  const getClient = await findOne( { clientId: req.clientId }, { featureConfigs: 1 } );
197
216
  const openSearch = JSON.parse( process.env.OPENSEARCH );
@@ -201,9 +220,7 @@ export async function getNobData( req, res ) {
201
220
  'from': skip,
202
221
  'size': limit,
203
222
  'query': {
204
- 'bool': {
205
- 'must': filter,
206
- },
223
+ 'bool': temp,
207
224
  },
208
225
  };
209
226
 
@@ -214,8 +231,6 @@ export async function getNobData( req, res ) {
214
231
  }
215
232
 
216
233
  const footfallQuery={
217
- // 'from': skip,
218
- // 'size': limit,
219
234
  'query': {
220
235
  'bool': {
221
236
  'must': [
@@ -304,24 +319,24 @@ export async function getNobData( req, res ) {
304
319
  'Store Id': element.storeId,
305
320
  'Date': dayjs( element.nobDate ).format( 'D MMM,YYYY' ),
306
321
  'NoB\'s Count': element.nobCount,
307
- 'Conversion Rate': `${element.conversionRate} %`,
308
-
309
322
 
310
323
  } );
311
324
  switch ( getClient?.featureConfigs?.conversionCalculation ) {
312
325
  case 'footfall-count':
313
- exportData['Footfall'] = element.footfallCount;
326
+ exportData[index]['Footfall'] = element.footfallCount;
314
327
  break;
315
328
  case 'billable-entities':
316
- exportData['Potential Buyers'] = element.potentialBuyers;
329
+ exportData[index]['Potential Buyers'] = element.potentialBuyers;
317
330
  break;
318
331
  case 'engagers-count':
319
- exportData['Engagers Count'] = element.engagersCount;
332
+ exportData[index]['Engagers Count'] = element.engagersCount;
320
333
  break;
321
334
  default:
322
- exportData['Engagers Count'] = element.engagersCount;
335
+ exportData[index]['Engagers Count'] = element.engagersCount;
323
336
  }
337
+ element.conversionRate? exportData[index]['Conversion Rate'] = `${element.conversionRate} %` : exportData[index]['Conversion Rate'] =null;
324
338
  } );
339
+ logger.info( { exportData: exportData } );
325
340
  return exportData;
326
341
  } );
327
342
  const mappedArrays = await Promise.all( promises );