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

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.8.2-alpha.4",
3
+ "version": "3.8.2-alpha.6",
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.203",
27
- "tango-app-api-middleware": "^3.1.92",
27
+ "tango-app-api-middleware": "^3.6.5",
28
28
  "winston": "^3.13.1",
29
29
  "winston-daily-rotate-file": "^5.0.0"
30
30
  },
@@ -383,11 +383,11 @@ export const summaryTableV1 = async ( req, res ) => {
383
383
  if ( reqestData.export ) {
384
384
  let limit = 10000;
385
385
  let count = 0;
386
- for ( let i=0; i<=limit; i += 1000 ) {
386
+ for ( let i = 0; i <= limit; i += 1000 ) {
387
387
  reqestData.limit = 1000;
388
388
  reqestData.offset = count;
389
389
  let data = await LamdaServiceCall( LamdaURL, reqestData );
390
- count ++;
390
+ count++;
391
391
  if ( data.status_code == '200' && data.summaryData.length ) {
392
392
  data = {
393
393
  'status_code': '200',
@@ -405,13 +405,13 @@ export const summaryTableV1 = async ( req, res ) => {
405
405
  if ( resultData ) {
406
406
  if ( resultData.status_code == '200' ) {
407
407
  if ( reqestData.export ) {
408
- if ( resultData.summaryData.length>0 ) {
408
+ if ( resultData.summaryData.length > 0 ) {
409
409
  const exportdata = [];
410
410
  resultData.summaryData.forEach( ( element ) => {
411
411
  exportdata.push( {
412
412
  'Store Name': element.storeName,
413
413
  'Store ID': element.storeId,
414
- ...( req.body.storeId.length ==1 ) ? { Date: element['date'] }:{},
414
+ ...( req.body.storeId.length == 1 ) ? { Date: element['date'] } : {},
415
415
  'Footfall': element.footfallCount,
416
416
  'Bounced Count': element.bouncedCount,
417
417
  'Engagers': element.engagersCount,
@@ -622,7 +622,7 @@ export const storesMapV1 = async ( req, res ) => {
622
622
  if ( !getStores ) {
623
623
  return res.sendError( 'No Content', 204 );
624
624
  } else {
625
- if ( getStores.length >0 ) {
625
+ if ( getStores.length > 0 ) {
626
626
  return res.sendSuccess( { storeData: getStores } );
627
627
  } else {
628
628
  return res.sendError( 'No Content', 204 );
@@ -642,7 +642,7 @@ export const headerLocationsV1 = async ( req, res ) => {
642
642
  let getRole = req.user.role;
643
643
  let getClientId = reqestData.clientId;
644
644
  let totalStores = await getAllStores( getUserEmail, getClientId, getUserType, getRole );
645
- if ( totalStores && totalStores.length>0 ) {
645
+ if ( totalStores && totalStores.length > 0 ) {
646
646
  let storeQuery = [
647
647
  {
648
648
  $match: {
@@ -685,17 +685,21 @@ export const headerLocationsV1 = async ( req, res ) => {
685
685
  };
686
686
  export const headerLocationsV2 = async ( req, res ) => {
687
687
  try {
688
+ if ( req.body && ( !req.body.status || req.body.status.length === 0 ) ) {
689
+ req.body.status = [ 'active' ];
690
+ }
691
+
688
692
  let reqestData = req.body;
689
693
  let getUserEmail = req.user.email;
690
694
  let getUserType = req.user.userType;
691
695
  let getRole = req.user.role;
692
696
  let getClientId = reqestData.clientId;
693
697
  let totalStores = await getStoresList( getUserEmail, getClientId, getUserType, getRole, req );
694
- if ( totalStores && totalStores.length>0 ) {
698
+ if ( totalStores && totalStores.length > 0 ) {
695
699
  let storeQuery = [];
696
700
  storeQuery.push( { $match: { $and: [ { clientId: { $eq: getClientId } }, { storeId: { $in: totalStores } } ] } } );
697
701
 
698
- if ( reqestData.country && reqestData.country.length>0 ) {
702
+ if ( reqestData.country && reqestData.country.length > 0 ) {
699
703
  storeQuery.push( { $match: { $and: [ { 'storeProfile.country': { $in: reqestData.country || [] } } ] } } );
700
704
  }
701
705
 
@@ -706,7 +710,7 @@ export const headerLocationsV2 = async ( req, res ) => {
706
710
  );
707
711
  const cityList = await aggregateStore( storeQuery );
708
712
  if ( cityList && cityList.length > 0 ) {
709
- let city = cityList.filter( ( data ) => data.city!='' );
713
+ let city = cityList.filter( ( data ) => data.city != '' );
710
714
  return res.sendSuccess( { locationData: city } );
711
715
  } else {
712
716
  return res.sendError( 'No City', 400 );
@@ -721,13 +725,17 @@ export const headerLocationsV2 = async ( req, res ) => {
721
725
  };
722
726
  export const headerCountryV2 = async ( req, res ) => {
723
727
  try {
728
+ if ( req.body && ( !req.body.status || req.body.status.length === 0 ) ) {
729
+ req.body.status = [ 'active' ];
730
+ }
731
+
724
732
  let reqestData = req.body;
725
733
  let getUserEmail = req.user.email;
726
734
  let getUserType = req.user.userType;
727
735
  let getRole = req.user.role;
728
736
  let getClientId = reqestData.clientId;
729
737
  let totalStores = await getStoresList( getUserEmail, getClientId, getUserType, getRole, req );
730
- if ( totalStores && totalStores.length>0 ) {
738
+ if ( totalStores && totalStores.length > 0 ) {
731
739
  let storeQuery = [
732
740
  {
733
741
  $match: {
@@ -756,7 +764,7 @@ export const headerCountryV2 = async ( req, res ) => {
756
764
  ];
757
765
  const countryList = await aggregateStore( storeQuery );
758
766
  if ( countryList && countryList.length > 0 ) {
759
- let country = countryList.filter( ( data ) => data.country!='' );
767
+ let country = countryList.filter( ( data ) => data.country != '' );
760
768
  return res.sendSuccess( { countryData: country } );
761
769
  } else {
762
770
  return res.sendError( 'No City', 400 );
@@ -776,9 +784,9 @@ export const headerGroupsV1 = async ( req, res ) => {
776
784
  let getUserType = req.user.userType;
777
785
  let getRole = req.user.role;
778
786
  let groupIds;
779
- if ( requestData.city && requestData.city.length>0 ) {
787
+ if ( requestData.city && requestData.city.length > 0 ) {
780
788
  let getGroupIds = await getCityStores( requestData.clientId, getUserEmail, getRole, requestData.city, getUserType, req );
781
- if ( getGroupIds && getGroupIds.length>0 ) {
789
+ if ( getGroupIds && getGroupIds.length > 0 ) {
782
790
  groupIds = getGroupIds;
783
791
  } else {
784
792
  groupIds = [];
@@ -845,15 +853,19 @@ export const headerGroupsV1 = async ( req, res ) => {
845
853
  };
846
854
  export async function headerClustersV2( req, res ) {
847
855
  try {
856
+ if ( req.body && ( !req.body.status || req.body.status.length === 0 ) ) {
857
+ req.body.status = [ 'active' ];
858
+ }
859
+
848
860
  let requestData = req.body;
849
861
  let getUserEmail = req.user.email;
850
862
  let clientId = req?.user?.clientId;
851
863
  let getUserType = req.user.userType;
852
864
  let getRole = req.user.role;
853
- let clusterNames=[];
854
- if ( requestData.city && requestData.city.length>0 ) {
865
+ let clusterNames = [];
866
+ if ( requestData.city && requestData.city.length > 0 ) {
855
867
  let getcityclustes = await getCityClusters( requestData.clientId, getUserEmail, getRole, requestData.city, getUserType, req );
856
- if ( getcityclustes && getcityclustes.length>0 ) {
868
+ if ( getcityclustes && getcityclustes.length > 0 ) {
857
869
  clusterNames = getcityclustes;
858
870
  } else {
859
871
  clusterNames = [];
@@ -869,7 +881,7 @@ export async function headerClustersV2( req, res ) {
869
881
  }
870
882
  }
871
883
  }
872
- if ( clusterNames.length>0 ) {
884
+ if ( clusterNames.length > 0 ) {
873
885
  const dataObjects = clusterNames.map( ( item ) => ( { groupName: item } ) );
874
886
  res.sendSuccess( { groupData: dataObjects } );
875
887
  } else {
@@ -884,7 +896,7 @@ export async function headerClustersV2( req, res ) {
884
896
 
885
897
  async function getCityClusters( userClientId, getUserEmail, getRole, requestCity, getUserType, req ) {
886
898
  try {
887
- if ( userClientId && userClientId !='' && getUserEmail && getUserEmail !='', getRole && getRole !='', requestCity && requestCity.length>0 ) {
899
+ if ( userClientId && userClientId != '' && getUserEmail && getUserEmail != '', getRole && getRole != '', requestCity && requestCity.length > 0 ) {
888
900
  let cityStores = await getLocationStores( userClientId, requestCity, req );
889
901
  if ( cityStores && cityStores.length > 0 ) {
890
902
  let storeGroups = await getClusterStoresIds( userClientId, cityStores, getRole, getUserType, getUserEmail, req );
@@ -906,7 +918,7 @@ async function getCityClusters( userClientId, getUserEmail, getRole, requestCity
906
918
  }
907
919
  async function getClusterStoresIds( userClientId, storeIds, getRole, getUserType, getUserEmail, req ) {
908
920
  try {
909
- if ( userClientId && userClientId !='' && storeIds && storeIds !='' && getRole && getRole !='' && getUserType && getUserType !='', getUserEmail && getUserEmail !='' ) {
921
+ if ( userClientId && userClientId != '' && storeIds && storeIds != '' && getRole && getRole != '' && getUserType && getUserType != '', getUserEmail && getUserEmail != '' ) {
910
922
  let clusterQuery = [];
911
923
  if ( getUserType == 'client' ) {
912
924
  if ( getRole == 'superadmin' ) {
@@ -945,7 +957,7 @@ async function getClusterStoresIds( userClientId, storeIds, getRole, getUserType
945
957
  },
946
958
  ];
947
959
  const assignedclusters = await aggregateCluster( getAssignedGroupIds );
948
- if ( assignedclusters && assignedclusters.length>0 && assignedclusters[0]?.clusterName.length > 0 ) {
960
+ if ( assignedclusters && assignedclusters.length > 0 && assignedclusters[0]?.clusterName.length > 0 ) {
949
961
  let uniqueclusters = [ ...new Set( assignedclusters[0].clusterName ) ];
950
962
  return uniqueclusters;
951
963
  }
@@ -970,7 +982,7 @@ async function getClusterStoresIds( userClientId, storeIds, getRole, getUserType
970
982
  }
971
983
 
972
984
  const assignedclusters = await aggregateCluster( clusterQuery );
973
- if ( assignedclusters && assignedclusters.length>0 && assignedclusters[0]?.clusterName.length > 0 ) {
985
+ if ( assignedclusters && assignedclusters.length > 0 && assignedclusters[0]?.clusterName.length > 0 ) {
974
986
  let uniqueclusters = [ ...new Set( assignedclusters[0].clusterName ) ];
975
987
  return uniqueclusters;
976
988
  } else {
@@ -992,9 +1004,9 @@ export const headerStoresV1 = async ( req, res ) => {
992
1004
  let getRole = req.user.role;
993
1005
  let getClientId = reqestData.clientId;
994
1006
  let totalStores = await getAllStores( getUserEmail, getClientId, getUserType, getRole, reqestData );
995
- if ( totalStores && totalStores.length>0 ) {
1007
+ if ( totalStores && totalStores.length > 0 ) {
996
1008
  let storeQuery = [];
997
- if ( reqestData.city.length>0 && reqestData.group.length>0 ) {
1009
+ if ( reqestData.city.length > 0 && reqestData.group.length > 0 ) {
998
1010
  let unqueCityStores = await getLocationStores( getClientId, reqestData.city );
999
1011
  let unqueGroupStores = await getGroupStores( getClientId, reqestData.group );
1000
1012
  storeQuery = [
@@ -1015,7 +1027,7 @@ export const headerStoresV1 = async ( req, res ) => {
1015
1027
  },
1016
1028
  },
1017
1029
  ];
1018
- } else if ( reqestData.city.length>0 ) {
1030
+ } else if ( reqestData.city.length > 0 ) {
1019
1031
  let unqueCityStores = await getLocationStores( getClientId, reqestData.city );
1020
1032
  storeQuery = [
1021
1033
  {
@@ -1034,7 +1046,7 @@ export const headerStoresV1 = async ( req, res ) => {
1034
1046
  },
1035
1047
  },
1036
1048
  ];
1037
- } else if ( reqestData.group.length>0 ) {
1049
+ } else if ( reqestData.group.length > 0 ) {
1038
1050
  let unqueGroupStores = await getGroupStores( getClientId, reqestData.group );
1039
1051
  storeQuery = [
1040
1052
  {
@@ -1095,9 +1107,9 @@ export const headerStoresV2OLD = async ( req, res ) => {
1095
1107
  let getRole = req.user.role;
1096
1108
  let getClientId = reqestData.clientId;
1097
1109
  let totalStores = await getStoresList( getUserEmail, getClientId, getUserType, getRole, req );
1098
- if ( totalStores && totalStores.length>0 ) {
1110
+ if ( totalStores && totalStores.length > 0 ) {
1099
1111
  let storeQuery = [];
1100
- if ( reqestData.city.length>0 && reqestData.clusters.length>0 ) {
1112
+ if ( reqestData.city.length > 0 && reqestData.clusters.length > 0 ) {
1101
1113
  let unqueCityStores = await getLocationStores( getClientId, reqestData.city, req );
1102
1114
  let unqueGroupStores = await getClusterStores( getClientId, reqestData.clusters );
1103
1115
  storeQuery = [
@@ -1120,7 +1132,7 @@ export const headerStoresV2OLD = async ( req, res ) => {
1120
1132
  },
1121
1133
  },
1122
1134
  ];
1123
- } else if ( reqestData.city.length>0 ) {
1135
+ } else if ( reqestData.city.length > 0 ) {
1124
1136
  let uniqueCityStores = await getLocationStores( getClientId, reqestData.city, req );
1125
1137
  storeQuery = [
1126
1138
  {
@@ -1141,7 +1153,7 @@ export const headerStoresV2OLD = async ( req, res ) => {
1141
1153
  },
1142
1154
  },
1143
1155
  ];
1144
- } else if ( reqestData.clusters.length>0 ) {
1156
+ } else if ( reqestData.clusters.length > 0 ) {
1145
1157
  let uniqueclusterStores = await getClusterStores( getClientId, reqestData.clusters );
1146
1158
  storeQuery = [
1147
1159
  {
@@ -1202,18 +1214,18 @@ export const headerStoresV2OLD = async ( req, res ) => {
1202
1214
 
1203
1215
  async function getStoresList( getUserEmail, getClientId, getUserType, getRole, req ) {
1204
1216
  try {
1205
- if ( getUserEmail && getUserEmail !='' && getClientId && getClientId !='' && getUserType && getUserType !='' && getRole && getRole!='' ) {
1217
+ if ( getUserEmail && getUserEmail != '' && getClientId && getClientId != '' && getUserType && getUserType != '' && getRole && getRole != '' ) {
1206
1218
  let overAllStores = [];
1207
1219
  if ( getUserType == 'tango' ) {
1208
1220
  let getAllS = await getAssignedAllStores( getClientId, req.body );
1209
- if ( getAllS && getAllS.length >0 ) {
1221
+ if ( getAllS && getAllS.length > 0 ) {
1210
1222
  overAllStores = getAllS;
1211
1223
  }
1212
1224
  return overAllStores;
1213
1225
  } else if ( getUserType == 'client' ) {
1214
1226
  if ( getRole == 'superadmin' ) {
1215
1227
  let getAllS = await getAssignedAllStores( getClientId, req.body );
1216
- if ( getAllS && getAllS.length >0 ) {
1228
+ if ( getAllS && getAllS.length > 0 ) {
1217
1229
  overAllStores = getAllS;
1218
1230
  }
1219
1231
  return overAllStores;
@@ -1232,18 +1244,18 @@ async function getStoresList( getUserEmail, getClientId, getUserType, getRole, r
1232
1244
 
1233
1245
  async function getAllStores( getUserEmail, getClientId, getUserType, getRole, reqestData ) {
1234
1246
  try {
1235
- if ( getUserEmail && getUserEmail !='' && getClientId && getClientId !='' && getUserType && getUserType !='' && getRole && getRole!='' ) {
1247
+ if ( getUserEmail && getUserEmail != '' && getClientId && getClientId != '' && getUserType && getUserType != '' && getRole && getRole != '' ) {
1236
1248
  let overAllStores = [];
1237
1249
  if ( getUserType == 'tango' ) {
1238
1250
  let getAllS = await getAssignedAllStores( getClientId, reqestData );
1239
- if ( getAllS && getAllS.length >0 ) {
1251
+ if ( getAllS && getAllS.length > 0 ) {
1240
1252
  overAllStores = getAllS;
1241
1253
  }
1242
1254
  return overAllStores;
1243
1255
  } else if ( getUserType == 'client' ) {
1244
1256
  if ( getRole == 'superadmin' ) {
1245
1257
  let getAllS = await getAssignedAllStores( getClientId, reqestData );
1246
- if ( getAllS && getAllS.length >0 ) {
1258
+ if ( getAllS && getAllS.length > 0 ) {
1247
1259
  overAllStores = getAllS;
1248
1260
  }
1249
1261
  return overAllStores;
@@ -1255,18 +1267,18 @@ async function getAllStores( getUserEmail, getClientId, getUserType, getRole, re
1255
1267
  const getAssignedType = await findOneUserAssignedStore( assignedQuery );
1256
1268
  if ( getAssignedType ) {
1257
1269
  if ( getAssignedType.userType == 'client' ) {
1258
- if ( getAssignedType.assignedType && getAssignedType.assignedType !='' ) {
1270
+ if ( getAssignedType.assignedType && getAssignedType.assignedType != '' ) {
1259
1271
  let overAllStores = [];
1260
1272
  switch ( getAssignedType.assignedType ) {
1261
1273
  case 'store':
1262
1274
  let getAS = await getAssignedStores( getClientId, getUserEmail, 'store' );
1263
- if ( getAS && getAS.length >0 ) {
1275
+ if ( getAS && getAS.length > 0 ) {
1264
1276
  overAllStores = getAS;
1265
1277
  }
1266
1278
  break;
1267
1279
  case 'group':
1268
1280
  let getAGS = await getAssignedGroupStores( getClientId, getUserEmail, 'group' );
1269
- if ( getAGS && getAGS.length >0 ) {
1281
+ if ( getAGS && getAGS.length > 0 ) {
1270
1282
  overAllStores = getAGS;
1271
1283
  }
1272
1284
  break;
@@ -1295,7 +1307,7 @@ async function getAllStores( getUserEmail, getClientId, getUserType, getRole, re
1295
1307
 
1296
1308
  async function getAssignedStores( clientId, userEmail, assignedType ) {
1297
1309
  try {
1298
- if ( clientId && clientId !='' && userEmail && userEmail !='' && assignedType && assignedType !='' ) {
1310
+ if ( clientId && clientId != '' && userEmail && userEmail != '' && assignedType && assignedType != '' ) {
1299
1311
  let storeQuery = [
1300
1312
  {
1301
1313
  $match: {
@@ -1314,7 +1326,7 @@ async function getAssignedStores( clientId, userEmail, assignedType ) {
1314
1326
  },
1315
1327
  ];
1316
1328
  const storeList = await aggregateUserAssignedStore( storeQuery );
1317
- if ( storeList && storeList.length>0 && storeList[0]?.stores.length > 0 ) {
1329
+ if ( storeList && storeList.length > 0 && storeList[0]?.stores.length > 0 ) {
1318
1330
  let uniqueStores = [ ...new Set( storeList[0].stores ) ];
1319
1331
  return uniqueStores;
1320
1332
  } else {
@@ -1331,7 +1343,7 @@ async function getAssignedStores( clientId, userEmail, assignedType ) {
1331
1343
 
1332
1344
  async function getAssignedGroupStores( clientId, userEmail, assignedType ) {
1333
1345
  try {
1334
- if ( clientId && clientId !='' && userEmail && userEmail !='' && assignedType && assignedType !='' ) {
1346
+ if ( clientId && clientId != '' && userEmail && userEmail != '' && assignedType && assignedType != '' ) {
1335
1347
  const groupQuery = [
1336
1348
  {
1337
1349
  $match: {
@@ -1381,7 +1393,7 @@ async function getAssignedGroupStores( clientId, userEmail, assignedType ) {
1381
1393
  },
1382
1394
  ];
1383
1395
  const groupStoreList = await aggregateUserAssignedStore( groupQuery );
1384
- if ( groupStoreList && groupStoreList.length>0 && groupStoreList[0]?.stores.length > 0 ) {
1396
+ if ( groupStoreList && groupStoreList.length > 0 && groupStoreList[0]?.stores.length > 0 ) {
1385
1397
  let uniqueStores = [ ...new Set( groupStoreList[0].stores ) ];
1386
1398
  return uniqueStores;
1387
1399
  } else {
@@ -1398,7 +1410,7 @@ async function getAssignedGroupStores( clientId, userEmail, assignedType ) {
1398
1410
 
1399
1411
  async function getAssignedAllStores( userClientId, reqestData ) {
1400
1412
  try {
1401
- if ( userClientId && userClientId !='' ) {
1413
+ if ( userClientId && userClientId != '' ) {
1402
1414
  let storeQuery = [
1403
1415
  {
1404
1416
  $match: {
@@ -1417,7 +1429,7 @@ async function getAssignedAllStores( userClientId, reqestData ) {
1417
1429
  },
1418
1430
  ];
1419
1431
  const storeList = await aggregateStore( storeQuery );
1420
- if ( storeList && storeList.length>0 && storeList[0]?.stores.length > 0 ) {
1432
+ if ( storeList && storeList.length > 0 && storeList[0]?.stores.length > 0 ) {
1421
1433
  let uniqueStores = [ ...new Set( storeList[0].stores ) ];
1422
1434
  return uniqueStores;
1423
1435
  } else {
@@ -1435,7 +1447,7 @@ async function getAssignedAllStores( userClientId, reqestData ) {
1435
1447
 
1436
1448
  async function getClusterStores( userClientId, ClusterList, req ) {
1437
1449
  try {
1438
- if ( userClientId && userClientId !='' && ClusterList && ClusterList.length >0 ) {
1450
+ if ( userClientId && userClientId != '' && ClusterList && ClusterList.length > 0 ) {
1439
1451
  let ClusterQuery = [
1440
1452
  {
1441
1453
  $match: {
@@ -1469,7 +1481,7 @@ async function getClusterStores( userClientId, ClusterList, req ) {
1469
1481
  },
1470
1482
  ];
1471
1483
  const clusterStoreList = await aggregateCluster( ClusterQuery );
1472
- if ( clusterStoreList && clusterStoreList.length>0 && clusterStoreList[0]?.storesList.length > 0 ) {
1484
+ if ( clusterStoreList && clusterStoreList.length > 0 && clusterStoreList[0]?.storesList.length > 0 ) {
1473
1485
  let storeIds = clusterStoreList[0].storesList.map( ( data ) => data.storeId );
1474
1486
  let uniqueStores = [ ...new Set( storeIds ) ];
1475
1487
  return uniqueStores;
@@ -1487,7 +1499,7 @@ async function getClusterStores( userClientId, ClusterList, req ) {
1487
1499
 
1488
1500
  async function getGroupStores( userClientId, groupList ) {
1489
1501
  try {
1490
- if ( userClientId && userClientId !='' && groupList && groupList.length >0 ) {
1502
+ if ( userClientId && userClientId != '' && groupList && groupList.length > 0 ) {
1491
1503
  let groupQuery = [
1492
1504
  {
1493
1505
  $match: {
@@ -1510,7 +1522,7 @@ async function getGroupStores( userClientId, groupList ) {
1510
1522
  },
1511
1523
  ];
1512
1524
  const groupStoreList = await aggregateGroup( groupQuery );
1513
- if ( groupStoreList && groupStoreList.length>0 && groupStoreList[0]?.stores.length > 0 ) {
1525
+ if ( groupStoreList && groupStoreList.length > 0 && groupStoreList[0]?.stores.length > 0 ) {
1514
1526
  let uniqueStores = [ ...new Set( groupStoreList[0].stores ) ];
1515
1527
  return uniqueStores;
1516
1528
  } else {
@@ -1527,17 +1539,17 @@ async function getGroupStores( userClientId, groupList ) {
1527
1539
 
1528
1540
  async function getLocationStores( userClientId, cityList, req ) {
1529
1541
  try {
1530
- if ( userClientId && userClientId !='' && cityList && cityList.length >0 ) {
1542
+ if ( userClientId && userClientId != '' && cityList && cityList.length > 0 ) {
1531
1543
  let filter = [
1532
1544
  { clientId: { $eq: userClientId } },
1533
1545
  { 'storeProfile.city': { $in: cityList } },
1534
1546
  ];
1535
1547
 
1536
- if ( req.body.country && req.body.country.length>0 ) {
1548
+ if ( req.body.country && req.body.country.length > 0 ) {
1537
1549
  filter.push( { 'storeProfile.country': { $in: req.body.country || [] } } );
1538
1550
  }
1539
1551
 
1540
- if ( req.body.assignedStores&&req.body.assignedStores.length>0 ) {
1552
+ if ( req.body.assignedStores && req.body.assignedStores.length > 0 ) {
1541
1553
  filter.push( { storeId: { $in: req.body.assignedStores } } );
1542
1554
  }
1543
1555
  filter.push( { 'edge.firstFile': true }, { status: { $in: req.body.status } } );
@@ -1562,7 +1574,7 @@ async function getLocationStores( userClientId, cityList, req ) {
1562
1574
  },
1563
1575
  ];
1564
1576
  const cityStoreList = await aggregateStore( storeQuery );
1565
- if ( cityStoreList && cityStoreList.length>0 && cityStoreList[0]?.stores.length > 0 ) {
1577
+ if ( cityStoreList && cityStoreList.length > 0 && cityStoreList[0]?.stores.length > 0 ) {
1566
1578
  let uniqueStores = [ ...new Set( cityStoreList[0].stores ) ];
1567
1579
  return uniqueStores;
1568
1580
  } else {
@@ -1578,16 +1590,16 @@ async function getLocationStores( userClientId, cityList, req ) {
1578
1590
  }
1579
1591
  async function getclusterList( userClientId, getUserType, getRole, req ) {
1580
1592
  try {
1581
- if ( userClientId && userClientId !='' || getUserType === 'tango' ) {
1593
+ if ( userClientId && userClientId != '' || getUserType === 'tango' ) {
1582
1594
  let filter = [];
1583
- if ( userClientId && userClientId !='' ) {
1595
+ if ( userClientId && userClientId != '' ) {
1584
1596
  filter.push( { clientId: { $eq: userClientId } },
1585
1597
  );
1586
1598
  }
1587
- if ( req.body.assignedStores&&req.body.assignedStores.length>0 ) {
1599
+ if ( req.body.assignedStores && req.body.assignedStores.length > 0 ) {
1588
1600
  filter.push( { 'stores.storeId': { $in: req.body.assignedStores } } );
1589
1601
  }
1590
- if ( getUserType == 'client'&&getRole!='superadmin' ) {
1602
+ if ( getUserType == 'client' && getRole != 'superadmin' ) {
1591
1603
  filter.push( { 'Teamlead.email': req.user.email } );
1592
1604
  }
1593
1605
  let clusterQuery = [];
@@ -1603,7 +1615,7 @@ async function getclusterList( userClientId, getUserType, getRole, req ) {
1603
1615
  },
1604
1616
  } );
1605
1617
  const clusterIds = await aggregateCluster( clusterQuery );
1606
- if ( clusterIds && clusterIds.length>0 && clusterIds[0]?.clusterName.length > 0 ) {
1618
+ if ( clusterIds && clusterIds.length > 0 && clusterIds[0]?.clusterName.length > 0 ) {
1607
1619
  let uniqueclusterIds = [ ...new Set( clusterIds[0].clusterName ) ];
1608
1620
  return uniqueclusterIds;
1609
1621
  } else {
@@ -1619,7 +1631,7 @@ async function getclusterList( userClientId, getUserType, getRole, req ) {
1619
1631
  }
1620
1632
  async function getGroupIds( userClientId ) {
1621
1633
  try {
1622
- if ( userClientId && userClientId !='' ) {
1634
+ if ( userClientId && userClientId != '' ) {
1623
1635
  let groupQuery = [
1624
1636
  {
1625
1637
  $match: {
@@ -1636,7 +1648,7 @@ async function getGroupIds( userClientId ) {
1636
1648
  },
1637
1649
  ];
1638
1650
  const groupGroupIds = await aggregateGroup( groupQuery );
1639
- if ( groupGroupIds && groupGroupIds.length>0 && groupGroupIds[0]?.groupName.length > 0 ) {
1651
+ if ( groupGroupIds && groupGroupIds.length > 0 && groupGroupIds[0]?.groupName.length > 0 ) {
1640
1652
  let uniqueGroupIds = [ ...new Set( groupGroupIds[0].groupName ) ];
1641
1653
  return uniqueGroupIds;
1642
1654
  } else {
@@ -1653,7 +1665,7 @@ async function getGroupIds( userClientId ) {
1653
1665
 
1654
1666
  async function getAssignedGroupIds( userClientId, getUserEmail ) {
1655
1667
  try {
1656
- if ( userClientId && userClientId !='' && getUserEmail && getUserEmail !='' ) {
1668
+ if ( userClientId && userClientId != '' && getUserEmail && getUserEmail != '' ) {
1657
1669
  let groupQuery = [
1658
1670
  {
1659
1671
  $match: {
@@ -1672,7 +1684,7 @@ async function getAssignedGroupIds( userClientId, getUserEmail ) {
1672
1684
  },
1673
1685
  ];
1674
1686
  const groupStoreList = await aggregateUserAssignedStore( groupQuery );
1675
- if ( groupStoreList && groupStoreList.length>0 && groupStoreList[0]?.groupName.length > 0 ) {
1687
+ if ( groupStoreList && groupStoreList.length > 0 && groupStoreList[0]?.groupName.length > 0 ) {
1676
1688
  let uniqueGroupIdsData = [ ...new Set( groupStoreList[0].groupName ) ];
1677
1689
  let uniqueGroupIds = [];
1678
1690
  for ( let i = 0; i < uniqueGroupIdsData.length; i++ ) {
@@ -1693,7 +1705,7 @@ async function getAssignedGroupIds( userClientId, getUserEmail ) {
1693
1705
 
1694
1706
  async function getCityStores( userClientId, getUserEmail, getRole, requestCity, getUserType, req ) {
1695
1707
  try {
1696
- if ( userClientId && userClientId !='' && getUserEmail && getUserEmail !='', getRole && getRole !='', requestCity && requestCity.length>0 ) {
1708
+ if ( userClientId && userClientId != '' && getUserEmail && getUserEmail != '', getRole && getRole != '', requestCity && requestCity.length > 0 ) {
1697
1709
  let cityStores = await getLocationStores( userClientId, requestCity, req );
1698
1710
  if ( cityStores && cityStores.length > 0 ) {
1699
1711
  let storeGroups = await getGroupStoresIds( userClientId, cityStores, getRole, getUserType, getUserEmail );
@@ -1716,7 +1728,7 @@ async function getCityStores( userClientId, getUserEmail, getRole, requestCity,
1716
1728
 
1717
1729
  async function getGroupStoresIds( userClientId, storeIds, getRole, getUserType, getUserEmail ) {
1718
1730
  try {
1719
- if ( userClientId && userClientId !='' && storeIds && storeIds !='' && getRole && getRole !='' && getUserType && getUserType !='', getUserEmail && getUserEmail !='' ) {
1731
+ if ( userClientId && userClientId != '' && storeIds && storeIds != '' && getRole && getRole != '' && getUserType && getUserType != '', getUserEmail && getUserEmail != '' ) {
1720
1732
  let groupQuery = [];
1721
1733
  if ( getUserType == 'client' ) {
1722
1734
  if ( getRole == 'superadmin' ) {
@@ -1754,7 +1766,7 @@ async function getGroupStoresIds( userClientId, storeIds, getRole, getUserType,
1754
1766
  },
1755
1767
  ];
1756
1768
  const assignedGroups = await aggregateUserAssignedStore( getAssignedGroupIds );
1757
- if ( assignedGroups && assignedGroups.length>0 && assignedGroups[0]?.groupName.length > 0 ) {
1769
+ if ( assignedGroups && assignedGroups.length > 0 && assignedGroups[0]?.groupName.length > 0 ) {
1758
1770
  let uniqueGroups = [ ...new Set( assignedGroups[0].groupName ) ];
1759
1771
  let uniqueGroupIds = [];
1760
1772
  for ( let i = 0; i < uniqueGroups.length; i++ ) {
@@ -1799,7 +1811,7 @@ async function getGroupStoresIds( userClientId, storeIds, getRole, getUserType,
1799
1811
  }
1800
1812
 
1801
1813
  const groupGroupIds = await aggregateGroup( groupQuery );
1802
- if ( groupGroupIds && groupGroupIds.length>0 && groupGroupIds[0]?.groupName.length > 0 ) {
1814
+ if ( groupGroupIds && groupGroupIds.length > 0 && groupGroupIds[0]?.groupName.length > 0 ) {
1803
1815
  let uniqueGroupIds = [ ...new Set( groupGroupIds[0].groupName ) ];
1804
1816
  return uniqueGroupIds;
1805
1817
  } else {
@@ -1832,7 +1844,7 @@ export const getMySubscription = async ( req, res ) => {
1832
1844
  let reqestData = req.body;
1833
1845
  let getClientData = await clientService.findOne( { clientId: reqestData.clientId }, { planDetails: 1 } );
1834
1846
  if ( getClientData ) {
1835
- if ( getClientData.planDetails && getClientData.planDetails.product && getClientData.planDetails.product.length>0 ) {
1847
+ if ( getClientData.planDetails && getClientData.planDetails.product && getClientData.planDetails.product.length > 0 ) {
1836
1848
  let clientSubscription = {};
1837
1849
  let clientProducts = {
1838
1850
  tangoTraffic: false,
@@ -1859,7 +1871,7 @@ export const getMySubscription = async ( req, res ) => {
1859
1871
  tangoZone: false,
1860
1872
  tangoTrax: false,
1861
1873
  };
1862
- if ( reqestData.storeId && reqestData.storeId.length>0 ) {
1874
+ if ( reqestData.storeId && reqestData.storeId.length > 0 ) {
1863
1875
  let getStoreData = await findOneStore( { clientId: reqestData.clientId, storeId: { $in: reqestData.storeId[0] } }, { product: 1 } );
1864
1876
  if ( getStoreData ) {
1865
1877
  for ( let storeIndex = 0; storeIndex < getStoreData.product.length; storeIndex++ ) {
@@ -1904,7 +1916,7 @@ export const getStoreMapData = async ( req, res ) => {
1904
1916
  }
1905
1917
  reqestData.featureConfigs = getClientData.featureConfigs;
1906
1918
  let cameraBaseImage = '';
1907
- const bucket= JSON.parse( process.env.BUCKET );
1919
+ const bucket = JSON.parse( process.env.BUCKET );
1908
1920
  if ( bucket && bucket.baseImage && bucket.baseImage != '' ) {
1909
1921
  const camera = await findCamera( { storeId: reqestData.storeId[0], isUp: true, isActivated: true }, { thumbnailImage: 1 } );
1910
1922
  if ( camera && camera.thumbnailImage && camera.thumbnailImage != '' ) {
@@ -1929,7 +1941,7 @@ export const getStoreMapData = async ( req, res ) => {
1929
1941
  };
1930
1942
  let hourlyLamdaURL = 'https://ksxkjnhwwzvrgp7ngttw2ribsy0twqip.lambda-url.ap-south-1.on.aws/';
1931
1943
  let hourlyResultData = await LamdaServiceCall( hourlyLamdaURL, reqestData );
1932
- if ( hourlyResultData && hourlyResultData.hourData.length>0 ) {
1944
+ if ( hourlyResultData && hourlyResultData.hourData.length > 0 ) {
1933
1945
  hourlyData.hourlyFootfall = hourlyResultData.hourData[0].hourlyFootfall;
1934
1946
  hourlyData.openTime = hourlyResultData.hourData[0].openTime;
1935
1947
  hourlyData.closeTime = hourlyResultData.hourData[0].closeTime;
@@ -1938,7 +1950,7 @@ export const getStoreMapData = async ( req, res ) => {
1938
1950
  reqestData.fromDate = dayjs( fromDate ).format( 'YYYY-MM-DD' );
1939
1951
  let footfallLamdaURL = 'https://3ircml3r6dm7fbiif3ti2wwdee0zqhyb.lambda-url.ap-south-1.on.aws/';
1940
1952
  let footfallResultData = await LamdaServiceCall( footfallLamdaURL, reqestData );
1941
- if ( footfallResultData && footfallResultData.avgData&&footfallResultData.avgData.length>0 ) {
1953
+ if ( footfallResultData && footfallResultData.avgData && footfallResultData.avgData.length > 0 ) {
1942
1954
  avgData.avgFootfall = footfallResultData.avgData[0].avgFootfall;
1943
1955
  avgData.avgWeekdayFootfall = footfallResultData.avgData[0].avgWeekdayFootfall;
1944
1956
  avgData.avgWeekendFootfall = footfallResultData.avgData[0].avgWeekendFootfall;
@@ -2029,13 +2041,13 @@ export async function getUserEmails( req, res ) {
2029
2041
 
2030
2042
  async function getCountryStores( userClientId, countryList, req ) {
2031
2043
  try {
2032
- if ( userClientId && userClientId !='' && countryList && countryList.length >0 ) {
2044
+ if ( userClientId && userClientId != '' && countryList && countryList.length > 0 ) {
2033
2045
  let filter = [
2034
2046
  { clientId: { $eq: userClientId } },
2035
2047
  { 'storeProfile.country': { $in: countryList } },
2036
2048
  ];
2037
2049
 
2038
- if ( req.body.assignedStores&&req.body.assignedStores.length>0 ) {
2050
+ if ( req.body.assignedStores && req.body.assignedStores.length > 0 ) {
2039
2051
  filter.push( { storeId: { $in: req.body.assignedStores } } );
2040
2052
  }
2041
2053
  filter.push( { 'edge.firstFile': true }, { status: { $in: req.body.status } } );
@@ -2046,7 +2058,7 @@ async function getCountryStores( userClientId, countryList, req ) {
2046
2058
  { $group: { _id: null, stores: { $push: '$storeId' } } },
2047
2059
  ];
2048
2060
  const countryStoreList = await aggregateStore( storeQuery );
2049
- if ( countryStoreList && countryStoreList.length>0 && countryStoreList[0]?.stores.length > 0 ) {
2061
+ if ( countryStoreList && countryStoreList.length > 0 && countryStoreList[0]?.stores.length > 0 ) {
2050
2062
  let uniqueStores = [ ...new Set( countryStoreList[0].stores ) ];
2051
2063
  return uniqueStores;
2052
2064
  } else {
@@ -2062,29 +2074,34 @@ async function getCountryStores( userClientId, countryList, req ) {
2062
2074
  }
2063
2075
  export const headerStoresV2 = async ( req, res ) => {
2064
2076
  try {
2077
+ if ( req.body && ( !req.body.status || req.body.status.length === 0 ) ) {
2078
+ req.body.status = [ 'active' ];
2079
+ }
2080
+
2081
+
2065
2082
  let reqestData = req.body;
2066
2083
  let getUserEmail = req.user.email;
2067
2084
  let getUserType = req.user.userType;
2068
2085
  let getRole = req.user.role;
2069
2086
  let getClientId = reqestData.clientId;
2070
2087
  let totalStores = await getStoresList( getUserEmail, getClientId, getUserType, getRole, req );
2071
- if ( totalStores && totalStores.length>0 ) {
2088
+ if ( totalStores && totalStores.length > 0 ) {
2072
2089
  let storeQuery = [];
2073
2090
  let andQuery = [];
2074
2091
 
2075
2092
  andQuery.push( { storeId: { $in: totalStores } } );
2076
2093
 
2077
- if ( reqestData.country && reqestData.country.length>0 ) {
2094
+ if ( reqestData.country && reqestData.country.length > 0 ) {
2078
2095
  let unqueCountryStores = await getCountryStores( getClientId, reqestData.country, req );
2079
2096
  andQuery.push( { storeId: { $in: unqueCountryStores } } );
2080
2097
  }
2081
2098
 
2082
- if ( reqestData.city && reqestData.city.length>0 ) {
2099
+ if ( reqestData.city && reqestData.city.length > 0 ) {
2083
2100
  let unqueCityStores = await getLocationStores( getClientId, reqestData.city, req );
2084
2101
  andQuery.push( { storeId: { $in: unqueCityStores } } );
2085
2102
  }
2086
2103
 
2087
- if ( reqestData.clusters && reqestData.clusters.length>0 ) {
2104
+ if ( reqestData.clusters && reqestData.clusters.length > 0 ) {
2088
2105
  let unqueGroupStores = await getClusterStores( getClientId, reqestData.clusters, req );
2089
2106
  andQuery.push( { storeId: { $in: unqueGroupStores } } );
2090
2107
  }
@@ -1,4 +1,4 @@
1
- import { logger, download, signedUrl } from 'tango-app-api-middleware';
1
+ import { logger, download, downloadint, signedUrl } from 'tango-app-api-middleware';
2
2
  import * as clientService from '../services/clients.services.js';
3
3
  import {
4
4
  aggregateStore,
@@ -1560,7 +1560,7 @@ export const summaryTableV3 = async ( req, res ) => {
1560
1560
  } );
1561
1561
  }
1562
1562
  } );
1563
- return await download( exportdata, res );
1563
+ return await downloadint( exportdata, res );
1564
1564
  } else {
1565
1565
  return res.sendError( 'No Content', 204 );
1566
1566
  }
@@ -211,7 +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
+ status: joi.array().optional().empty(),
215
215
  country: joi.array().optional().empty(),
216
216
  } );
217
217
 
@@ -219,7 +219,7 @@ export const validateHeaderSchemav2 = joi.object( {
219
219
  clientId: joi.string().required(),
220
220
  city: joi.array().required(),
221
221
  clusters: joi.array().required(),
222
- status: joi.array().required(),
222
+ status: joi.array().optional().empty(),
223
223
  country: joi.array().optional().empty(),
224
224
  } );
225
225
  export const validateHeaderParams = {
@@ -233,6 +233,7 @@ export const validateCountryHeaderSchemav2 = joi.object( {
233
233
  clientId: joi.string().required(),
234
234
  city: joi.array().optional().allow( '' ),
235
235
  clusters: joi.array().optional().allow( '' ),
236
+ status: joi.array().optional().allow( '' ),
236
237
  country: joi.array().optional().allow( '' ),
237
238
  } );
238
239
  export const validateCountryHeaderParamsv2 = {