tango-app-api-analysis-traffic 3.0.0-alpha.57 → 3.0.0-alpha.59
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.
|
|
3
|
+
"version": "3.0.0-alpha.59",
|
|
4
4
|
"description": "Traffic Analysis",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"nodemon": "^3.1.4",
|
|
25
25
|
"swagger-ui-express": "^5.0.1",
|
|
26
26
|
"tango-api-schema": "^2.2.7",
|
|
27
|
-
"tango-app-api-middleware": "^3.1.
|
|
27
|
+
"tango-app-api-middleware": "^3.1.47",
|
|
28
28
|
"winston": "^3.13.1",
|
|
29
29
|
"winston-daily-rotate-file": "^5.0.0"
|
|
30
30
|
},
|
|
@@ -99,7 +99,7 @@ export async function getNobData( req, res ) {
|
|
|
99
99
|
},
|
|
100
100
|
{
|
|
101
101
|
range: { nobDate: { gte: dateRange.start,
|
|
102
|
-
|
|
102
|
+
lte: dateRange.end } },
|
|
103
103
|
},
|
|
104
104
|
];
|
|
105
105
|
if ( req.user.role !== 'superadmin' && req.user.userType !== 'tango' ) {
|
|
@@ -161,7 +161,7 @@ export async function getNobData( req, res ) {
|
|
|
161
161
|
const getNobData=await getOpenSearchData( openSearch.nob, nobQuery );
|
|
162
162
|
const nobData = getNobData?.body?.hits?.hits;
|
|
163
163
|
if ( !nobData ||nobData?.length == 0 ) {
|
|
164
|
-
if ( inputData.searchValue && inputData.searchValue!== '' ) {
|
|
164
|
+
if ( inputData.searchValue && inputData.searchValue!== '' || inputData.offset> 1 ) {
|
|
165
165
|
return res.sendError( 'No Data Found', 204 );
|
|
166
166
|
} else {
|
|
167
167
|
return res.sendSuccess( { initialInsert: false } );
|
|
@@ -169,9 +169,7 @@ export async function getNobData( req, res ) {
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
const footfallQuery={
|
|
172
|
-
'
|
|
173
|
-
'exclude': [ 'storeName' ], // Specify the fields to exclude
|
|
174
|
-
},
|
|
172
|
+
'size': 10000,
|
|
175
173
|
'query': {
|
|
176
174
|
'bool': {
|
|
177
175
|
'must': [
|
|
@@ -191,14 +189,14 @@ export async function getNobData( req, res ) {
|
|
|
191
189
|
|
|
192
190
|
const getFootfall= await getOpenSearchData( openSearch.footfall, footfallQuery );
|
|
193
191
|
const footfall = getFootfall?.body?.hits?.hits;
|
|
194
|
-
logger.info( { footfall:
|
|
192
|
+
logger.info( { footfall: getFootfall, nobData: nobData } );
|
|
195
193
|
let result=[];
|
|
196
|
-
nobData.map( ( data ) => {
|
|
194
|
+
nobData.map( async ( data ) => {
|
|
197
195
|
let count = 0;
|
|
198
196
|
let temp=[];
|
|
199
197
|
|
|
200
198
|
data._source.isUpdated = data._source.createdAt !== data._source.updatedAt? true : false;
|
|
201
|
-
footfall.
|
|
199
|
+
footfall.map( ( item ) => {
|
|
202
200
|
if ( ( data._source.dateString === item._source.date_string ) && ( data._source.storeId === item._source.store_id ) ) {
|
|
203
201
|
count = 1;
|
|
204
202
|
temp =[
|
|
@@ -238,6 +236,8 @@ export async function getNobData( req, res ) {
|
|
|
238
236
|
|
|
239
237
|
} );
|
|
240
238
|
} else {
|
|
239
|
+
// const getStore = await findOneStore( { storeId: data.storeId }, { _id: 0, storeName: 1 } );
|
|
240
|
+
// data._source.storeName = getStore.storeName || data.storeName;
|
|
241
241
|
result.push( {
|
|
242
242
|
|
|
243
243
|
...data._source,
|
|
@@ -276,7 +276,7 @@ export async function getNobData( req, res ) {
|
|
|
276
276
|
default:
|
|
277
277
|
exportData[index]['Engagers Count'] = element.engagersCount;
|
|
278
278
|
}
|
|
279
|
-
element.conversionRate? exportData[index]['Conversion Rate'] = `${element.conversionRate}
|
|
279
|
+
element.conversionRate? exportData[index]['Conversion Rate'] = `${element.conversionRate}` : exportData[index]['Conversion Rate'] =null;
|
|
280
280
|
} );
|
|
281
281
|
return exportData;
|
|
282
282
|
} );
|
|
@@ -7,7 +7,7 @@ export async function clientValidations( req, res, next ) {
|
|
|
7
7
|
const inputData = req.method === 'POST' ? req.body : req.query;
|
|
8
8
|
const clientId = req.user.userType === 'tango' ? inputData.clientId :req.user.clientId;
|
|
9
9
|
if ( !clientId ) {
|
|
10
|
-
return res.sendError( '
|
|
10
|
+
return res.sendError( 'Please enter a valid clientId', 400 );
|
|
11
11
|
}
|
|
12
12
|
req.clientId = clientId;
|
|
13
13
|
return next();
|
|
@@ -23,7 +23,7 @@ export async function roleVerification( req, res, next ) {
|
|
|
23
23
|
if ( [ 'admin', 'superadmin' ].includes( req?.user?.role ) ) {
|
|
24
24
|
return next();
|
|
25
25
|
} else {
|
|
26
|
-
return res.sendError( '
|
|
26
|
+
return res.sendError( 'Access Denied', 403 );
|
|
27
27
|
}
|
|
28
28
|
} catch ( error ) {
|
|
29
29
|
logger.error( { error: error, message: req.body, function: 'nob-roleVerification' } );
|
|
@@ -36,7 +36,7 @@ export async function fieldValidation( req, res, next ) {
|
|
|
36
36
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
37
37
|
const inputData = req.body;
|
|
38
38
|
if ( req.user.role !== 'superadmin' && req.user.userType !== 'tango'&& ( inputData?.assignedStores?.length == 0 || !inputData?.assignedStores ) ) {
|
|
39
|
-
return res.sendError( '
|
|
39
|
+
return res.sendError( 'Access Denied', 403 );
|
|
40
40
|
}
|
|
41
41
|
let tempInserData = [];
|
|
42
42
|
let filter = [];
|
|
@@ -53,7 +53,7 @@ export async function fieldValidation( req, res, next ) {
|
|
|
53
53
|
if ( seen.has( key ) ) {
|
|
54
54
|
logger.info( { message: 'deupkilicare' } );
|
|
55
55
|
// duplicates.push( { ...item, originalIndex: index } );
|
|
56
|
-
return res.sendError( `
|
|
56
|
+
return res.sendError( `Dublicate record exist`, 403 );
|
|
57
57
|
} else {
|
|
58
58
|
seen.set( key, i );
|
|
59
59
|
}
|
|
@@ -84,7 +84,7 @@ export async function fieldValidation( req, res, next ) {
|
|
|
84
84
|
];
|
|
85
85
|
let storeData= await aggregateStore( query );
|
|
86
86
|
if ( storeData?.length ==0 ) {
|
|
87
|
-
return res.sendError( `
|
|
87
|
+
return res.sendError( `Store ID / Store Code is not associated with this brand`, 403 );
|
|
88
88
|
} else {
|
|
89
89
|
let searchQuery={
|
|
90
90
|
'size': 1,
|
|
@@ -107,7 +107,7 @@ export async function fieldValidation( req, res, next ) {
|
|
|
107
107
|
};
|
|
108
108
|
let searchData=await getOpenSearchData( openSearch.nob, searchQuery );
|
|
109
109
|
if ( searchData?.body?.hits?.hits.length > 0 && searchData?.body?.hits?.hits[0]?._source?.createdAt !== searchData?.body?.hits?.hits[0]?._source?.updatedAt ) {
|
|
110
|
-
return res.sendError( `
|
|
110
|
+
return res.sendError( `You are restricted to re-upload/edit more than one time`, 403 );
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
let nobDateIso =new Date( inputFilter[i]?.nobDate );
|
|
@@ -132,11 +132,11 @@ export async function fieldValidation( req, res, next ) {
|
|
|
132
132
|
req.tempInserData = tempInserData;
|
|
133
133
|
return next();
|
|
134
134
|
} else {
|
|
135
|
-
return res.sendError( '
|
|
135
|
+
return res.sendError( 'One or more value is missing in row or column', 400 );
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
return res.sendError( '
|
|
139
|
+
return res.sendError( 'One or more value is missing in row or column', 400 );
|
|
140
140
|
} catch ( error ) {
|
|
141
141
|
logger.error( { error: error, message: req.body, function: 'nob-roleVerification' } );
|
|
142
142
|
return res.sendError( error, 500 );
|