tango-app-api-analysis-traffic 3.0.0-alpha.36 → 3.0.0-alpha.38

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.36",
3
+ "version": "3.0.0-alpha.38",
4
4
  "description": "Traffic Analysis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -22,7 +22,7 @@
22
22
  "mongodb": "^6.8.0",
23
23
  "nodemon": "^3.1.4",
24
24
  "tango-api-schema": "^2.0.131",
25
- "tango-app-api-middleware": "^3.1.43-alpha.6",
25
+ "tango-app-api-middleware": "^3.1.43-alpha.8",
26
26
  "winston": "^3.13.1",
27
27
  "winston-daily-rotate-file": "^5.0.0"
28
28
  },
@@ -823,13 +823,13 @@ export async function headerClustersV2( req, res ) {
823
823
  }
824
824
  } else {
825
825
  if ( getUserType == 'tango' ) {
826
- clusterNames = await getclusterList( requestData.clientId, req );
826
+ clusterNames = await getclusterList( requestData.clientId, getUserType, getRole, req );
827
827
  console.log( clusterNames );
828
828
  } else if ( getUserType == 'client' ) {
829
829
  if ( getRole == 'superadmin' ) {
830
- clusterNames = await getclusterList( requestData.clientId, req );
830
+ clusterNames = await getclusterList( requestData.clientId, getUserType, getRole, req );
831
831
  } else {
832
- clusterNames = await getclusterList( requestData.clientId, req );
832
+ clusterNames = await getclusterList( requestData.clientId, getUserType, getRole, req );
833
833
  }
834
834
  }
835
835
  }
@@ -898,6 +898,7 @@ async function getClusterStoresIds( userClientId, storeIds, getRole, getUserType
898
898
  $and: [
899
899
  { clientId: { $eq: userClientId } },
900
900
  { 'stores.storeId': { $in: storeIds } },
901
+ { 'Teamlead.email': req.user.email },
901
902
  ],
902
903
  },
903
904
  },
@@ -915,6 +916,7 @@ async function getClusterStoresIds( userClientId, storeIds, getRole, getUserType
915
916
  }
916
917
  }
917
918
  } else if ( getUserType == 'tango' ) {
919
+ console.log( storeIds );
918
920
  clusterQuery = [
919
921
  {
920
922
  $match: {
@@ -1525,7 +1527,7 @@ async function getLocationStores( userClientId, cityList, req ) {
1525
1527
  return false;
1526
1528
  }
1527
1529
  }
1528
- async function getclusterList( userClientId, req ) {
1530
+ async function getclusterList( userClientId, getUserType, req ) {
1529
1531
  try {
1530
1532
  if ( userClientId && userClientId !='' ) {
1531
1533
  let filter = [
@@ -1534,6 +1536,11 @@ async function getclusterList( userClientId, req ) {
1534
1536
  if ( req.body.assignedStores&&req.body.assignedStores.length>0 ) {
1535
1537
  filter.push( { 'stores.storeId': { $in: req.body.assignedStores } } );
1536
1538
  }
1539
+ console.log( req.user.email );
1540
+ if ( getUserType == 'client'&&getRole!='superadmin' ) {
1541
+ filter.push( { 'Teamlead.email': req.user.email } );
1542
+ }
1543
+
1537
1544
 
1538
1545
  let clusterQuery = [
1539
1546
  {
@@ -1884,7 +1891,7 @@ export const getStoreMapData = async ( req, res ) => {
1884
1891
  reqestData.fromDate = dayjs( fromDate ).format( 'YYYY-MM-DD' );
1885
1892
  let footfallLamdaURL = 'https://3ircml3r6dm7fbiif3ti2wwdee0zqhyb.lambda-url.ap-south-1.on.aws/';
1886
1893
  let footfallResultData = await LamdaServiceCall( footfallLamdaURL, reqestData );
1887
- if ( footfallResultData && footfallResultData.avgData.length>0 ) {
1894
+ if ( footfallResultData && footfallResultData.avgData&&footfallResultData.avgData.length>0 ) {
1888
1895
  avgData.avgFootfall = footfallResultData.avgData[0].avgFootfall;
1889
1896
  avgData.avgWeekdayFootfall = footfallResultData.avgData[0].avgWeekdayFootfall;
1890
1897
  avgData.avgWeekendFootfall = footfallResultData.avgData[0].avgWeekendFootfall;