tango-app-api-analysis-traffic 3.0.0-alpha.35 → 3.0.0-alpha.37

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.35",
3
+ "version": "3.0.0-alpha.37",
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
  },
@@ -824,6 +824,7 @@ export async function headerClustersV2( req, res ) {
824
824
  } else {
825
825
  if ( getUserType == 'tango' ) {
826
826
  clusterNames = await getclusterList( requestData.clientId, req );
827
+ console.log( clusterNames );
827
828
  } else if ( getUserType == 'client' ) {
828
829
  if ( getRole == 'superadmin' ) {
829
830
  clusterNames = await getclusterList( requestData.clientId, req );
@@ -832,8 +833,13 @@ export async function headerClustersV2( req, res ) {
832
833
  }
833
834
  }
834
835
  }
835
- const dataObjects = clusterNames.map( ( item ) => ( { groupName: item } ) );
836
- res.sendSuccess( { groupData: dataObjects } );
836
+ console.log( clusterNames );
837
+ if ( clusterNames.length>0 ) {
838
+ const dataObjects = clusterNames.map( ( item ) => ( { groupName: item } ) );
839
+ res.sendSuccess( { groupData: dataObjects } );
840
+ } else {
841
+ res.sendSuccess( { groupData: [] } );
842
+ }
837
843
  } catch ( error ) {
838
844
  logger.error( { error: error, message: req.query, function: 'headerClustersV2' } );
839
845
  return res.sendError( { error: error }, 500 );
@@ -892,6 +898,7 @@ async function getClusterStoresIds( userClientId, storeIds, getRole, getUserType
892
898
  $and: [
893
899
  { clientId: { $eq: userClientId } },
894
900
  { 'stores.storeId': { $in: storeIds } },
901
+ { 'Teamlead.email': req.user.email },
895
902
  ],
896
903
  },
897
904
  },
@@ -1522,13 +1529,19 @@ async function getLocationStores( userClientId, cityList, req ) {
1522
1529
  async function getclusterList( userClientId, req ) {
1523
1530
  try {
1524
1531
  if ( userClientId && userClientId !='' ) {
1532
+ let filter = [
1533
+ { clientId: { $eq: userClientId } },
1534
+ ];
1535
+ if ( req.body.assignedStores&&req.body.assignedStores.length>0 ) {
1536
+ filter.push( { 'stores.storeId': { $in: req.body.assignedStores } } );
1537
+ }
1538
+ console.log( req.user.email );
1539
+ filter.push( { 'Teamlead.email': req.user.email } );
1540
+
1525
1541
  let clusterQuery = [
1526
1542
  {
1527
1543
  $match: {
1528
- $and: [
1529
- { clientId: { $eq: userClientId } },
1530
- { 'stores.storeId': { $in: req.body.assignedStores } },
1531
- ],
1544
+ $and: filter,
1532
1545
  },
1533
1546
  },
1534
1547
  {
@@ -1874,7 +1887,7 @@ export const getStoreMapData = async ( req, res ) => {
1874
1887
  reqestData.fromDate = dayjs( fromDate ).format( 'YYYY-MM-DD' );
1875
1888
  let footfallLamdaURL = 'https://3ircml3r6dm7fbiif3ti2wwdee0zqhyb.lambda-url.ap-south-1.on.aws/';
1876
1889
  let footfallResultData = await LamdaServiceCall( footfallLamdaURL, reqestData );
1877
- if ( footfallResultData && footfallResultData.avgData.length>0 ) {
1890
+ if ( footfallResultData && footfallResultData.avgData&&footfallResultData.avgData.length>0 ) {
1878
1891
  avgData.avgFootfall = footfallResultData.avgData[0].avgFootfall;
1879
1892
  avgData.avgWeekdayFootfall = footfallResultData.avgData[0].avgWeekdayFootfall;
1880
1893
  avgData.avgWeekendFootfall = footfallResultData.avgData[0].avgWeekendFootfall;