tango-app-api-analysis-traffic 3.8.12 → 3.8.14

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/.eslintrc.cjs CHANGED
@@ -36,7 +36,7 @@ module.exports = {
36
36
  'no-unused-vars': 'error',
37
37
  'new-cap': [ 'error', { 'newIsCap': true, 'capIsNew': false } ],
38
38
  'prefer-const': 'off',
39
- // 'no-console': 'error',
39
+ 'no-console': 'error',
40
40
  },
41
41
  };
42
42
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-analysis-traffic",
3
- "version": "3.8.12",
3
+ "version": "3.8.14",
4
4
  "description": "Traffic Analysis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -3,7 +3,7 @@ import { aggregateStore } from '../services/stores.service.js';
3
3
  import { findOneNobBilling, updateOneNobBilling } from '../services/nob.service.js';
4
4
  import dayjs from 'dayjs';
5
5
  import { findOne } from '../services/clients.services.js';
6
- import { find } from '../services/tagging.service.js';
6
+ import { find, aggregate } from '../services/tagging.service.js';
7
7
 
8
8
  export async function storeList( req, res ) {
9
9
  try {
@@ -63,8 +63,7 @@ export async function addBills( req, res ) {
63
63
  let resData = [];
64
64
  const openSearch = JSON.parse( process.env.OPENSEARCH );
65
65
  const inputData = req.tempInserData;
66
- console.log( '🚀 ~ addBills ~ inputData:', inputData );
67
-
66
+ // return;
68
67
  for ( let i = 0; i < inputData?.length; i++ ) {
69
68
  await updateOneNobBilling( inputData[i]?.query, inputData[i]?.data );
70
69
  const getData = await findOneNobBilling( inputData[i]?.query, { _id: 0 } );
@@ -315,7 +314,26 @@ function escapeSpecialChars( str ) {
315
314
 
316
315
  export async function zonelist( req, res ) {
317
316
  try {
318
- let zonelist = await find( { storeId: { $in: req.body.storeId }, productName: 'tangoZone', coordinates: { $ne: [] } }, { tagName: 1 } );
317
+ let zonelist = await aggregate( [
318
+ {
319
+ $match: {
320
+ storeId: { $in: req.body.storeId },
321
+ productName: 'tangoZone',
322
+ coordinates: { $ne: [] },
323
+ },
324
+ },
325
+ {
326
+ $group: {
327
+ _id: '$tagName',
328
+ },
329
+ },
330
+ {
331
+ $project: {
332
+ _id: 0,
333
+ tagName: '$_id',
334
+ },
335
+ },
336
+ ] );
319
337
  return res.sendSuccess( zonelist );
320
338
  } catch ( error ) {
321
339
  const err = error.message || 'Internal Server Error';
@@ -331,6 +349,7 @@ export async function zonetemplate( req, res ) {
331
349
  {
332
350
  $match: {
333
351
  clientId: req.body.clientId,
352
+ status: 'active',
334
353
  },
335
354
  },
336
355
  ],
@@ -593,7 +593,6 @@ export async function expireReviewStatus( req, res ) {
593
593
 
594
594
  cutoffDate.setUTCHours( 23, 59, 59, 0 );
595
595
 
596
- console.log( cutoffDate );
597
596
  if ( Number.isNaN( cutoffDate.getTime() ) ) {
598
597
  return res.sendError( 'Invalid thresholdDate', 400 );
599
598
  }
@@ -1010,14 +1009,7 @@ export async function storeProcessedData( req, res ) {
1010
1009
  const footfallDirRes = await getOpenSearchData( openSearch.footfallDirectory, footfallDirQuery );
1011
1010
  const hit = footfallDirRes?.body?.hits?.hits?.[0];
1012
1011
  receivedfootfall = hit._source.footfallCount;
1013
- if ( hit?._source?.mappingInfo && Array.isArray( hit._source.mappingInfo ) ) {
1014
- for ( let i = 0; i < hit._source.mappingInfo.length; i++ ) {
1015
- if ( hit._source.mappingInfo[i].type === 'tagging' ) {
1016
- ticketStatus = hit._source.mappingInfo[i].status;
1017
- break;
1018
- }
1019
- }
1020
- }
1012
+ ticketStatus = hit?._source?.status;
1021
1013
  } catch ( err ) {
1022
1014
  logger.warn( { message: 'Could not get ticket status from footfallDirectory', error: err } );
1023
1015
  }
@@ -1044,7 +1036,6 @@ export async function storeProcessedData( req, res ) {
1044
1036
  raisedStatusEnabled,
1045
1037
  footfallticketCount: statusArray.includes( ticketStatus )?receivedfootfall:processedData?.footfall_count,
1046
1038
  } );
1047
- console.log( '🚀 ~ storeProcessedData ~ ticketStatus:', ticketStatus );
1048
1039
 
1049
1040
  if ( raisedStatusEnabled === 'block' ) {
1050
1041
  // Calculate the number of days from currentDate + 1 to the end of the month
@@ -1274,6 +1265,9 @@ export async function footFallImages( req, res ) {
1274
1265
  // temp.length? temp[0].status = 'open': null;
1275
1266
 
1276
1267
  if ( resultData.status_code == '200' ) {
1268
+ if ( !req?.store?.footfallDirectoryConfigs?.contactEmail ||( req?.store?.footfallDirectoryConfigs && req?.store?.footfallDirectoryConfigs?.contactEmail && req?.store?.footfallDirectoryConfigs?.contactEmail === '' ) ) {
1269
+ req.store.footfallDirectoryConfigs.contactEmail = getFinal?.contactEmail || '';
1270
+ }
1277
1271
  return res.sendSuccess( { ...resultData, ticketStatus: temp?.length > 0 && ticketDetails? temp : null, config: req?.store?.footfallDirectoryConfigs } );
1278
1272
  } else {
1279
1273
  return res.sendError( 'No Content', 204 );
@@ -1,7 +1,6 @@
1
1
  import nobBillingModel from 'tango-api-schema/schema/nobBilling.model.js';
2
2
 
3
3
  export async function updateOneNobBilling( query, record ) {
4
- console.log( '🚀 ~ updateOneNobBilling ~ record:', record );
5
4
  return await nobBillingModel.updateOne( query, { $set: record }, { upsert: true } );
6
5
  }
7
6
 
@@ -284,6 +284,14 @@ export async function mappingConfig( req, res, next ) {
284
284
  },
285
285
  },
286
286
  ],
287
+ must_not: [
288
+ {
289
+ term: {
290
+ 'parent': inputData?.tempId || '', // Exclude current tempId if it's a duplicate tagging (to avoid counting the same image twice)
291
+ },
292
+ },
293
+ ],
294
+
287
295
  },
288
296
  },
289
297
  };