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

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.36",
4
4
  "description": "Traffic Analysis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -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 );
@@ -1522,13 +1528,17 @@ async function getLocationStores( userClientId, cityList, req ) {
1522
1528
  async function getclusterList( userClientId, req ) {
1523
1529
  try {
1524
1530
  if ( userClientId && userClientId !='' ) {
1531
+ let filter = [
1532
+ { clientId: { $eq: userClientId } },
1533
+ ];
1534
+ if ( req.body.assignedStores&&req.body.assignedStores.length>0 ) {
1535
+ filter.push( { 'stores.storeId': { $in: req.body.assignedStores } } );
1536
+ }
1537
+
1525
1538
  let clusterQuery = [
1526
1539
  {
1527
1540
  $match: {
1528
- $and: [
1529
- { clientId: { $eq: userClientId } },
1530
- { 'stores.storeId': { $in: req.body.assignedStores } },
1531
- ],
1541
+ $and: filter,
1532
1542
  },
1533
1543
  },
1534
1544
  {