tango-app-api-analysis-traffic 3.3.1-alpha.16 → 3.3.1-alpha.17
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,10 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
3
|
import { analysisTrafficRouter } from './src/routes/traffic.routes.js';
|
|
4
|
-
import { revopRouter } from './src/routes/revop.routes.js';
|
|
5
4
|
import { mobileTrafficAnalysisRouter } from './src/routes/mobileTraffic.routes.js';
|
|
6
5
|
import { nobDocs } from './src/docs/nob.docs.js';
|
|
7
6
|
import nobRouter from './src/routes/nob.routes.js';
|
|
8
7
|
|
|
9
|
-
export { analysisTrafficRouter, mobileTrafficAnalysisRouter, nobDocs, nobRouter
|
|
8
|
+
export { analysisTrafficRouter, mobileTrafficAnalysisRouter, nobDocs, nobRouter };
|
|
10
9
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-analysis-traffic",
|
|
3
|
-
"version": "3.3.1-alpha.
|
|
3
|
+
"version": "3.3.1-alpha.17",
|
|
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.
|
|
26
|
+
"tango-api-schema": "^2.2.7",
|
|
27
27
|
"tango-app-api-middleware": "^3.1.55",
|
|
28
28
|
"winston": "^3.13.1",
|
|
29
29
|
"winston-daily-rotate-file": "^5.0.0"
|
|
@@ -567,7 +567,7 @@ 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://
|
|
570
|
+
let LamdaURL = 'https://waxlhd7lfdlmyrkrdyv77najka0ayihq.lambda-url.ap-south-1.on.aws/';
|
|
571
571
|
let resultData = await LamdaServiceCall( LamdaURL, reqestData );
|
|
572
572
|
if ( resultData ) {
|
|
573
573
|
if ( resultData.status_code == '200' ) {
|
|
@@ -588,6 +588,19 @@ export const summaryTableV3 = async ( req, res ) => {
|
|
|
588
588
|
try {
|
|
589
589
|
let reqestData = req.body;
|
|
590
590
|
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';
|
|
591
604
|
if ( !getClientData ) {
|
|
592
605
|
return res.sendError( 'Invalid Client Id', 400 );
|
|
593
606
|
}
|
|
@@ -628,11 +641,10 @@ export const summaryTableV3 = async ( req, res ) => {
|
|
|
628
641
|
'Store ID': element.storeId,
|
|
629
642
|
...( req.body.storeId.length ==1 ) ? { Date: element['date'] }:{},
|
|
630
643
|
'Footfall': element.footfallCount,
|
|
631
|
-
'Bounced
|
|
644
|
+
'Bounced Footfall': element.bouncedCount,
|
|
632
645
|
'Engagers': element.engagersCount,
|
|
633
|
-
'
|
|
646
|
+
'Missed Opportunity': element.missedOpportunityCount,
|
|
634
647
|
'Potential Buyers': element.potentialBuyersCount,
|
|
635
|
-
'Conversion Rate': element.conversionRate,
|
|
636
648
|
'NOB Count': element.NOBCount,
|
|
637
649
|
'Avg.Dwell Time': element.avgDwellTime,
|
|
638
650
|
'Avg.Infra DownTime': element.avgInfraDowntime,
|
|
@@ -647,15 +659,38 @@ export const summaryTableV3 = async ( req, res ) => {
|
|
|
647
659
|
'Male': element.male,
|
|
648
660
|
'Female': element.female,
|
|
649
661
|
} );
|
|
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
|
+
} );
|
|
650
685
|
} else {
|
|
651
686
|
exportdata.push( {
|
|
652
687
|
'Store Name': element.storeName,
|
|
653
688
|
'Store ID': element.storeId,
|
|
654
689
|
...( req.body.storeId.length ==1 ) ? { Date: element['date'] }:{},
|
|
655
690
|
'Footfall': element.footfallCount,
|
|
656
|
-
'Bounced
|
|
691
|
+
'Bounced Footfall': element.bouncedCount,
|
|
657
692
|
'Engagers': element.engagersCount,
|
|
658
|
-
'
|
|
693
|
+
'Missed Opportunity': element.missedOpportunityCount,
|
|
659
694
|
'Potential Buyers': element.potentialBuyersCount,
|
|
660
695
|
'Conversion Rate': element.conversionRate,
|
|
661
696
|
'NOB Count': element.NOBCount,
|
|
@@ -2007,7 +2042,7 @@ async function getGroupStoresIds( userClientId, storeIds, getRole, getUserType,
|
|
|
2007
2042
|
|
|
2008
2043
|
async function getClientConfig( clientId ) {
|
|
2009
2044
|
try {
|
|
2010
|
-
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 } );
|
|
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
2046
|
if ( !getClientData ) {
|
|
2012
2047
|
return false;
|
|
2013
2048
|
}
|
|
@@ -1,119 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
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;
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
};
|