tango-app-api-analysis-traffic 3.3.1-alpha.17 → 3.3.1-alpha.18

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,9 +1,10 @@
1
1
 
2
2
 
3
3
  import { analysisTrafficRouter } from './src/routes/traffic.routes.js';
4
+ import { revopRouter } from './src/routes/revop.routes.js';
4
5
  import { mobileTrafficAnalysisRouter } from './src/routes/mobileTraffic.routes.js';
5
6
  import { nobDocs } from './src/docs/nob.docs.js';
6
7
  import nobRouter from './src/routes/nob.routes.js';
7
8
 
8
- export { analysisTrafficRouter, mobileTrafficAnalysisRouter, nobDocs, nobRouter };
9
+ export { analysisTrafficRouter, mobileTrafficAnalysisRouter, nobDocs, nobRouter, revopRouter };
9
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-analysis-traffic",
3
- "version": "3.3.1-alpha.17",
3
+ "version": "3.3.1-alpha.18",
4
4
  "description": "Traffic Analysis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -23,7 +23,7 @@
23
23
  "mongodb": "^6.8.0",
24
24
  "nodemon": "^3.1.4",
25
25
  "swagger-ui-express": "^5.0.1",
26
- "tango-api-schema": "^2.2.7",
26
+ "tango-api-schema": "^2.2.109",
27
27
  "tango-app-api-middleware": "^3.1.55",
28
28
  "winston": "^3.13.1",
29
29
  "winston-daily-rotate-file": "^5.0.0"
@@ -0,0 +1,119 @@
1
+ import { logger, insertOpenSearchData, getOpenSearchData, updateOpenSearchData } from 'tango-app-api-middleware';
2
+ import { findOnerevopConfig } from '../services/revopConfig.service.js';
3
+
4
+ export async function getconfig( req, res ) {
5
+ try {
6
+ let result = await findOnerevopConfig( { clientId: req.query.clientId } );
7
+ if ( result===null ) {
8
+ return res.sendError( 'no data found', 204 );
9
+ }
10
+ return res.sendSuccess( result );
11
+ } catch ( error ) {
12
+ logger.error( { error: error, message: req.query, function: 'getconfig' } );
13
+ return res.sendError( { error: error }, 500 );
14
+ }
15
+ }
16
+
17
+ export async function revoptagging( req, res ) {
18
+ try {
19
+ const openSearch = JSON.parse( process.env.OPENSEARCH );
20
+ console.log( req.body );
21
+ for ( let item of req.body ) {
22
+ let searchQuery={
23
+ 'size': 1,
24
+ 'query': {
25
+ 'bool': {
26
+ 'must': [
27
+ {
28
+ 'term': {
29
+ 'storeId.keyword': item.storeId,
30
+ },
31
+ },
32
+ {
33
+ 'term': {
34
+ 'processType': item.processType,
35
+ },
36
+ },
37
+ {
38
+ 'term': {
39
+ 'dateString': item.dateString,
40
+ },
41
+ },
42
+ {
43
+ 'term': {
44
+ 'tempId': item.tempId,
45
+ },
46
+ },
47
+ ],
48
+ },
49
+ },
50
+ };
51
+ let respo= await getOpenSearchData( openSearch.revops, searchQuery );
52
+ const revopData = respo?.body?.hits?.hits;
53
+ console.log( revopData );
54
+ if ( revopData&& revopData.length>0 ) {
55
+ await updateOpenSearchData( openSearch.revops, revopData[0]._id, { doc: item } );
56
+ return res.sendSuccess( 'Customer has been tagged successfully' );
57
+ } else {
58
+ item.createdAt = new Date();
59
+ item.updatedAt = new Date();
60
+ await insertOpenSearchData( openSearch.revops, item );
61
+ return res.sendSuccess( 'Customer has been tagged successfully.' );
62
+ }
63
+ }
64
+ } catch ( error ) {
65
+ logger.error( { error: error, message: req.query, function: 'revoptagging' } );
66
+ return res.sendError( { error: error }, 500 );
67
+ }
68
+ }
69
+ export async function getrevoptagging( req, res ) {
70
+ try {
71
+ const openSearch = JSON.parse( process.env.OPENSEARCH );
72
+ console.log( req.body );
73
+ let searchQuery={
74
+ 'size': 1,
75
+ 'query': {
76
+ 'bool': {
77
+ 'must': [
78
+ {
79
+ 'term': {
80
+ 'storeId.keyword': req.body.storeId,
81
+ },
82
+ },
83
+ {
84
+ 'term': {
85
+ 'processType': req.body.processType,
86
+ },
87
+ },
88
+ {
89
+ 'term': {
90
+ 'dateString': req.body.dateString,
91
+ },
92
+ },
93
+ // {
94
+ // 'term': {
95
+ // 'timeStamp': req.body.timeStamp,
96
+ // },
97
+ // },
98
+ {
99
+ 'term': {
100
+ 'tempId': req.body.tempId,
101
+ },
102
+ },
103
+ ],
104
+ },
105
+ },
106
+ };
107
+ let respo= await getOpenSearchData( openSearch.revops, searchQuery );
108
+ const revopData = respo?.body?.hits?.hits;
109
+ console.log( revopData );
110
+ if ( revopData.length>0 ) {
111
+ return res.sendSuccess( revopData[0]._source );
112
+ } else {
113
+ return res.sendError( 'no data found', 204 );
114
+ }
115
+ } catch ( error ) {
116
+ logger.error( { error: error, message: req.query, function: 'getrevoptagging' } );
117
+ return res.sendError( { error: error }, 500 );
118
+ }
119
+ }
@@ -567,7 +567,8 @@ export const footfallDirectoryV3 = async ( req, res ) => {
567
567
  return res.sendError( 'Invalid Client Id', 400 );
568
568
  }
569
569
  reqestData.featureConfigs = getClientData.featureConfigs;
570
- let LamdaURL = 'https://waxlhd7lfdlmyrkrdyv77najka0ayihq.lambda-url.ap-south-1.on.aws/';
570
+ let LamdaURL = 'https://cncmzszloku7y3bewxbpiy6nkm0yunqe.lambda-url.ap-south-1.on.aws/';
571
+ console.log( LamdaURL );
571
572
  let resultData = await LamdaServiceCall( LamdaURL, reqestData );
572
573
  if ( resultData ) {
573
574
  if ( resultData.status_code == '200' ) {
@@ -588,19 +589,6 @@ export const summaryTableV3 = async ( req, res ) => {
588
589
  try {
589
590
  let reqestData = req.body;
590
591
  let getClientData = await getClientConfig( reqestData.clientId );
591
- let featureConfigs = getClientData?.featureConfigs || {};
592
- const engagersLabel = featureConfigs?.bouncedLimit?.value ?
593
- `More than ${featureConfigs.bouncedLimit.value} mins` :
594
- 'Engagers';
595
- const bouncedLabel = featureConfigs?.bouncedLimit?.value ?
596
- `Less than ${featureConfigs.bouncedLimit.value} mins Footfall` :
597
- 'Bounced Footfall';
598
- const conversionLabel = featureConfigs?.conversion?.value ?
599
- `More than ${featureConfigs.conversion.value} mins Rate` :
600
- 'Conversion Rate';
601
- const missedlabel = featureConfigs?.bouncedLimit?.value && featureConfigs?.conversion?.value ?
602
- `${featureConfigs.bouncedLimit.value} - ${featureConfigs.conversion.value} mins` :
603
- 'Missed Opportunity';
604
592
  if ( !getClientData ) {
605
593
  return res.sendError( 'Invalid Client Id', 400 );
606
594
  }
@@ -641,10 +629,11 @@ export const summaryTableV3 = async ( req, res ) => {
641
629
  'Store ID': element.storeId,
642
630
  ...( req.body.storeId.length ==1 ) ? { Date: element['date'] }:{},
643
631
  'Footfall': element.footfallCount,
644
- 'Bounced Footfall': element.bouncedCount,
632
+ 'Bounced Count': element.bouncedCount,
645
633
  'Engagers': element.engagersCount,
646
- 'Missed Opportunity': element.missedOpportunityCount,
634
+ 'MissedOpportunity': element.missedOpportunityCount,
647
635
  'Potential Buyers': element.potentialBuyersCount,
636
+ 'Conversion Rate': element.conversionRate,
648
637
  'NOB Count': element.NOBCount,
649
638
  'Avg.Dwell Time': element.avgDwellTime,
650
639
  'Avg.Infra DownTime': element.avgInfraDowntime,
@@ -659,38 +648,15 @@ export const summaryTableV3 = async ( req, res ) => {
659
648
  'Male': element.male,
660
649
  'Female': element.female,
661
650
  } );
662
- } else if ( reqestData.clientId === '452' ) {
663
- exportdata.push( {
664
- 'Store Name': element.storeName,
665
- 'Store ID': element.storeId,
666
- ...( req.body.storeId.length ==1 ) ? { Date: element['date'] }:{},
667
- 'Footfall': element.footfallCount,
668
- ...( bouncedLabel ? { [bouncedLabel]: element.bouncedCount } : {} ),
669
- ...( engagersLabel ? { [engagersLabel]: element.engagersCount } : {} ),
670
- ...( missedlabel ? { [missedlabel]: element.missedOpportunityCount } : {} ),
671
- ...( conversionLabel ? { [conversionLabel]: element.conversionRate } : {} ),
672
- 'NOB Count': element.NOBCount,
673
- 'Avg.Dwell Time': element.avgDwellTime,
674
- 'Avg.Infra DownTime': element.avgInfraDowntime,
675
- ...( element.passerBy_count !== undefined ? { 'Passer By': element.passerBy_count } : {} ),
676
- 'Below12': element.below12,
677
- '13-19': element['13-19'],
678
- '20-30': element['20-30'],
679
- '31-45': element['31-45'],
680
- '46-59': element['46-59'],
681
- '60 above': element['60 above'],
682
- 'Male': element.male,
683
- 'Female': element.female,
684
- } );
685
651
  } else {
686
652
  exportdata.push( {
687
653
  'Store Name': element.storeName,
688
654
  'Store ID': element.storeId,
689
655
  ...( req.body.storeId.length ==1 ) ? { Date: element['date'] }:{},
690
656
  'Footfall': element.footfallCount,
691
- 'Bounced Footfall': element.bouncedCount,
657
+ 'Bounced Count': element.bouncedCount,
692
658
  'Engagers': element.engagersCount,
693
- 'Missed Opportunity': element.missedOpportunityCount,
659
+ 'MissedOpportunity': element.missedOpportunityCount,
694
660
  'Potential Buyers': element.potentialBuyersCount,
695
661
  'Conversion Rate': element.conversionRate,
696
662
  'NOB Count': element.NOBCount,
@@ -2042,7 +2008,7 @@ async function getGroupStoresIds( userClientId, storeIds, getRole, getUserType,
2042
2008
 
2043
2009
  async function getClientConfig( clientId ) {
2044
2010
  try {
2045
- let getClientData = await clientService.findOne( { clientId: clientId }, { 'paymentInvoice.currencyType': 1, 'averageTransactionValue': 1, 'featureConfigs.billableCalculation': 1, 'featureConfigs.missedOpportunityCalculation': 1, 'featureConfigs.conversionCalculation': 1, 'featureConfigs.open': 1, 'featureConfigs.close': 1, 'isFootfallAuditStores': 1, 'featureConfigs.bouncedLimit': 1, 'featureConfigs.conversion': 1 } );
2011
+ let getClientData = await clientService.findOne( { clientId: clientId }, { 'paymentInvoice.currencyType': 1, 'averageTransactionValue': 1, 'featureConfigs.billableCalculation': 1, 'featureConfigs.missedOpportunityCalculation': 1, 'featureConfigs.conversionCalculation': 1, 'featureConfigs.open': 1, 'featureConfigs.close': 1, 'isFootfallAuditStores': 1 } );
2046
2012
  if ( !getClientData ) {
2047
2013
  return false;
2048
2014
  }
@@ -0,0 +1,13 @@
1
+
2
+ import express from 'express';
3
+ import { getconfig, revoptagging, getrevoptagging } from '../controllers/revop.controller.js';
4
+ import { isAllowedSessionHandler, isAllowedClient } from 'tango-app-api-middleware';
5
+
6
+ export const revopRouter = express.Router();
7
+
8
+ revopRouter
9
+ .get( '/getconfig', isAllowedSessionHandler, isAllowedClient, getconfig )
10
+ .post( '/tagging', isAllowedSessionHandler, isAllowedClient, revoptagging )
11
+ .post( '/getrevoptagging', isAllowedSessionHandler, isAllowedClient, getrevoptagging );
12
+
13
+ export default revopRouter;
@@ -0,0 +1,16 @@
1
+ import revopConfigModel from 'tango-api-schema/schema/revopConfig.model.js';
2
+
3
+
4
+ export async function createrevopConfig( field = {} ) {
5
+ return await revopConfigModel.create( field );
6
+ };
7
+ export async function findOnerevopConfig( query = {} ) {
8
+ return await revopConfigModel.findOne( query );
9
+ };
10
+
11
+ export async function updaterevopConfig( data={}, field = {} ) {
12
+ return await revopConfigModel.updateOne( data, { $set: field } );
13
+ };
14
+ export async function aggregaterevopconfig( data ) {
15
+ return await revopConfigModel.aggregate( data );
16
+ };