tango-app-api-analysis-traffic 3.3.1-alpha.14 → 3.3.1-alpha.16
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.
|
|
3
|
+
"version": "3.3.1-alpha.16",
|
|
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.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
|
+
}
|
|
@@ -99,7 +99,7 @@ export const conversionCardsV3 = async ( req, res ) => {
|
|
|
99
99
|
reqestData.featureConfigs = getClientData.featureConfigs;
|
|
100
100
|
reqestData.currency = getClientData.paymentInvoice?.currencyType || 'inr';
|
|
101
101
|
reqestData.revenue = getClientData.averageTransactionValue || '0';
|
|
102
|
-
let LamdaURL = 'https://
|
|
102
|
+
let LamdaURL = 'https://shi4an3zee5kvaiqfgslwjrupq0srglf.lambda-url.ap-south-1.on.aws/';
|
|
103
103
|
let resultData = await LamdaServiceCall( LamdaURL, reqestData );
|
|
104
104
|
if ( resultData ) {
|
|
105
105
|
if ( resultData.status_code == '200' ) {
|
|
@@ -261,7 +261,7 @@ export const funnelV3 = async ( req, res ) => {
|
|
|
261
261
|
reqestData.featureConfigs = getClientData.featureConfigs;
|
|
262
262
|
reqestData.currency = getClientData.paymentInvoice?.currencyType || 'inr';
|
|
263
263
|
reqestData.revenue = getClientData.averageTransactionValue || '0';
|
|
264
|
-
let LamdaURL = 'https://
|
|
264
|
+
let LamdaURL = 'https://oeewcchsgznkfr5qwgjtdj4vhu0amilj.lambda-url.ap-south-1.on.aws/';
|
|
265
265
|
let resultData = await LamdaServiceCall( LamdaURL, reqestData );
|
|
266
266
|
if ( resultData ) {
|
|
267
267
|
if ( resultData.status_code == '200' ) {
|
|
@@ -390,7 +390,7 @@ export const overallCardsV3 = async ( req, res ) => {
|
|
|
390
390
|
reqestData.featureConfigs = getClientData.featureConfigs;
|
|
391
391
|
reqestData.currency = getClientData.paymentInvoice?.currencyType || 'inr';
|
|
392
392
|
reqestData.revenue = getClientData.averageTransactionValue || '0';
|
|
393
|
-
let LamdaURL = 'https://
|
|
393
|
+
let LamdaURL = 'https://s3wltaeo66nbj7udu5qraqqqvu0dhqao.lambda-url.ap-south-1.on.aws/';
|
|
394
394
|
let resultData = await LamdaServiceCall( LamdaURL, reqestData );
|
|
395
395
|
if ( resultData ) {
|
|
396
396
|
if ( resultData.status_code == '200' ) {
|
|
@@ -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://cncmzszloku7y3bewxbpiy6nkm0yunqe.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,24 +588,11 @@ 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 Count` :
|
|
597
|
-
'Bounced Count';
|
|
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
|
-
'MissedOpportunity';
|
|
604
591
|
if ( !getClientData ) {
|
|
605
592
|
return res.sendError( 'Invalid Client Id', 400 );
|
|
606
593
|
}
|
|
607
594
|
reqestData.featureConfigs = getClientData.featureConfigs;
|
|
608
|
-
let LamdaURL = 'https://
|
|
595
|
+
let LamdaURL = 'https://ewen2vlmxmhieea4elztlbjuey0ddqee.lambda-url.ap-south-1.on.aws/';
|
|
609
596
|
let resultData;
|
|
610
597
|
if ( reqestData.export ) {
|
|
611
598
|
let limit = 10000;
|
|
@@ -645,6 +632,7 @@ export const summaryTableV3 = async ( req, res ) => {
|
|
|
645
632
|
'Engagers': element.engagersCount,
|
|
646
633
|
'MissedOpportunity': element.missedOpportunityCount,
|
|
647
634
|
'Potential Buyers': element.potentialBuyersCount,
|
|
635
|
+
'Conversion Rate': element.conversionRate,
|
|
648
636
|
'NOB Count': element.NOBCount,
|
|
649
637
|
'Avg.Dwell Time': element.avgDwellTime,
|
|
650
638
|
'Avg.Infra DownTime': element.avgInfraDowntime,
|
|
@@ -659,29 +647,6 @@ export const summaryTableV3 = async ( req, res ) => {
|
|
|
659
647
|
'Male': element.male,
|
|
660
648
|
'Female': element.female,
|
|
661
649
|
} );
|
|
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
650
|
} else {
|
|
686
651
|
exportdata.push( {
|
|
687
652
|
'Store Name': element.storeName,
|
|
@@ -735,7 +700,7 @@ export const footfallTrendV3 = async ( req, res ) => {
|
|
|
735
700
|
return res.sendError( 'Invalid Client Id', 400 );
|
|
736
701
|
}
|
|
737
702
|
reqestData.featureConfigs = getClientData.featureConfigs;
|
|
738
|
-
let LamdaURL = 'https://
|
|
703
|
+
let LamdaURL = 'https://x6sjlqwaqd64kyioxhwrwfesbm0jjitx.lambda-url.ap-south-1.on.aws/';
|
|
739
704
|
let resultData = await LamdaServiceCall( LamdaURL, reqestData );
|
|
740
705
|
if ( resultData ) {
|
|
741
706
|
if ( resultData.status_code == '200' ) {
|
|
@@ -2042,7 +2007,7 @@ async function getGroupStoresIds( userClientId, storeIds, getRole, getUserType,
|
|
|
2042
2007
|
|
|
2043
2008
|
async function getClientConfig( clientId ) {
|
|
2044
2009
|
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
|
|
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 } );
|
|
2046
2011
|
if ( !getClientData ) {
|
|
2047
2012
|
return false;
|
|
2048
2013
|
}
|
|
@@ -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
|
+
};
|