tango-app-api-analysis-traffic 3.8.2-alpha.2 → 3.8.2-alpha.4

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,11 +1,11 @@
1
1
  {
2
2
  "name": "tango-app-api-analysis-traffic",
3
- "version": "3.8.2-alpha.2",
3
+ "version": "3.8.2-alpha.4",
4
4
  "description": "Traffic Analysis",
5
5
  "main": "index.js",
6
6
  "type": "module",
7
7
  "scripts": {
8
- "start": "nodemon --exec \"eslint --fix . && node app.js\""
8
+ "start": "nodemon --exec \"eslint --fix . && node index.js\""
9
9
  },
10
10
  "engines": {
11
11
  "node": ">=18.10.0"
@@ -991,7 +991,7 @@ export const headerStoresV1 = async ( req, res ) => {
991
991
  let getUserType = req.user.userType;
992
992
  let getRole = req.user.role;
993
993
  let getClientId = reqestData.clientId;
994
- let totalStores = await getAllStores( getUserEmail, getClientId, getUserType, getRole );
994
+ let totalStores = await getAllStores( getUserEmail, getClientId, getUserType, getRole, reqestData );
995
995
  if ( totalStores && totalStores.length>0 ) {
996
996
  let storeQuery = [];
997
997
  if ( reqestData.city.length>0 && reqestData.group.length>0 ) {
@@ -1054,7 +1054,7 @@ export const headerStoresV1 = async ( req, res ) => {
1054
1054
  },
1055
1055
  ];
1056
1056
  } else {
1057
- let totalStores = await getAllStores( getUserEmail, getClientId, getUserType, getRole );
1057
+ let totalStores = await getAllStores( getUserEmail, getClientId, getUserType, getRole, reqestData );
1058
1058
  storeQuery = [
1059
1059
  {
1060
1060
  $match: {
@@ -1205,14 +1205,14 @@ async function getStoresList( getUserEmail, getClientId, getUserType, getRole, r
1205
1205
  if ( getUserEmail && getUserEmail !='' && getClientId && getClientId !='' && getUserType && getUserType !='' && getRole && getRole!='' ) {
1206
1206
  let overAllStores = [];
1207
1207
  if ( getUserType == 'tango' ) {
1208
- let getAllS = await getAssignedAllStores( getClientId );
1208
+ let getAllS = await getAssignedAllStores( getClientId, req.body );
1209
1209
  if ( getAllS && getAllS.length >0 ) {
1210
1210
  overAllStores = getAllS;
1211
1211
  }
1212
1212
  return overAllStores;
1213
1213
  } else if ( getUserType == 'client' ) {
1214
1214
  if ( getRole == 'superadmin' ) {
1215
- let getAllS = await getAssignedAllStores( getClientId );
1215
+ let getAllS = await getAssignedAllStores( getClientId, req.body );
1216
1216
  if ( getAllS && getAllS.length >0 ) {
1217
1217
  overAllStores = getAllS;
1218
1218
  }
@@ -1230,19 +1230,19 @@ async function getStoresList( getUserEmail, getClientId, getUserType, getRole, r
1230
1230
  };
1231
1231
 
1232
1232
 
1233
- async function getAllStores( getUserEmail, getClientId, getUserType, getRole ) {
1233
+ async function getAllStores( getUserEmail, getClientId, getUserType, getRole, reqestData ) {
1234
1234
  try {
1235
1235
  if ( getUserEmail && getUserEmail !='' && getClientId && getClientId !='' && getUserType && getUserType !='' && getRole && getRole!='' ) {
1236
1236
  let overAllStores = [];
1237
1237
  if ( getUserType == 'tango' ) {
1238
- let getAllS = await getAssignedAllStores( getClientId );
1238
+ let getAllS = await getAssignedAllStores( getClientId, reqestData );
1239
1239
  if ( getAllS && getAllS.length >0 ) {
1240
1240
  overAllStores = getAllS;
1241
1241
  }
1242
1242
  return overAllStores;
1243
1243
  } else if ( getUserType == 'client' ) {
1244
1244
  if ( getRole == 'superadmin' ) {
1245
- let getAllS = await getAssignedAllStores( getClientId );
1245
+ let getAllS = await getAssignedAllStores( getClientId, reqestData );
1246
1246
  if ( getAllS && getAllS.length >0 ) {
1247
1247
  overAllStores = getAllS;
1248
1248
  }
@@ -1396,7 +1396,7 @@ async function getAssignedGroupStores( clientId, userEmail, assignedType ) {
1396
1396
  }
1397
1397
  }
1398
1398
 
1399
- async function getAssignedAllStores( userClientId ) {
1399
+ async function getAssignedAllStores( userClientId, reqestData ) {
1400
1400
  try {
1401
1401
  if ( userClientId && userClientId !='' ) {
1402
1402
  let storeQuery = [
@@ -1404,7 +1404,7 @@ async function getAssignedAllStores( userClientId ) {
1404
1404
  $match: {
1405
1405
  $and: [
1406
1406
  { clientId: { $eq: userClientId } },
1407
- { status: { $eq: 'active' } },
1407
+ { status: { $in: reqestData.status } },
1408
1408
  { 'edge.firstFile': true },
1409
1409
  ],
1410
1410
  },
@@ -1433,7 +1433,7 @@ async function getAssignedAllStores( userClientId ) {
1433
1433
  }
1434
1434
 
1435
1435
 
1436
- async function getClusterStores( userClientId, ClusterList ) {
1436
+ async function getClusterStores( userClientId, ClusterList, req ) {
1437
1437
  try {
1438
1438
  if ( userClientId && userClientId !='' && ClusterList && ClusterList.length >0 ) {
1439
1439
  let ClusterQuery = [
@@ -1540,7 +1540,7 @@ async function getLocationStores( userClientId, cityList, req ) {
1540
1540
  if ( req.body.assignedStores&&req.body.assignedStores.length>0 ) {
1541
1541
  filter.push( { storeId: { $in: req.body.assignedStores } } );
1542
1542
  }
1543
- filter.push( { 'edge.firstFile': true }, { status: { $eq: 'active' } } );
1543
+ filter.push( { 'edge.firstFile': true }, { status: { $in: req.body.status } } );
1544
1544
 
1545
1545
  let storeQuery = [
1546
1546
  {
@@ -2038,7 +2038,7 @@ async function getCountryStores( userClientId, countryList, req ) {
2038
2038
  if ( req.body.assignedStores&&req.body.assignedStores.length>0 ) {
2039
2039
  filter.push( { storeId: { $in: req.body.assignedStores } } );
2040
2040
  }
2041
- filter.push( { 'edge.firstFile': true }, { status: { $eq: 'active' } } );
2041
+ filter.push( { 'edge.firstFile': true }, { status: { $in: req.body.status } } );
2042
2042
 
2043
2043
  let storeQuery = [
2044
2044
  { $match: { $and: filter } },
@@ -2085,12 +2085,12 @@ export const headerStoresV2 = async ( req, res ) => {
2085
2085
  }
2086
2086
 
2087
2087
  if ( reqestData.clusters && reqestData.clusters.length>0 ) {
2088
- let unqueGroupStores = await getClusterStores( getClientId, reqestData.clusters );
2088
+ let unqueGroupStores = await getClusterStores( getClientId, reqestData.clusters, req );
2089
2089
  andQuery.push( { storeId: { $in: unqueGroupStores } } );
2090
2090
  }
2091
2091
 
2092
2092
  andQuery.push( { 'edge.firstFile': true } );
2093
- andQuery.push( { status: { $eq: 'active' } } );
2093
+ andQuery.push( { status: { $in: req.body.status } } );
2094
2094
 
2095
2095
  storeQuery.push(
2096
2096
  { $match: { $and: andQuery } },
@@ -211,6 +211,7 @@ export const validateHeaderSchema = joi.object( {
211
211
  clientId: joi.string().required().allow( '' ),
212
212
  city: joi.array().required(),
213
213
  group: joi.array().required(),
214
+ status: joi.array().required(),
214
215
  country: joi.array().optional().empty(),
215
216
  } );
216
217
 
@@ -218,6 +219,7 @@ export const validateHeaderSchemav2 = joi.object( {
218
219
  clientId: joi.string().required(),
219
220
  city: joi.array().required(),
220
221
  clusters: joi.array().required(),
222
+ status: joi.array().required(),
221
223
  country: joi.array().optional().empty(),
222
224
  } );
223
225
  export const validateHeaderParams = {