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

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.34",
3
+ "version": "3.0.0-alpha.35",
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.41",
25
+ "tango-app-api-middleware": "^3.1.43-alpha.6",
26
26
  "winston": "^3.13.1",
27
27
  "winston-daily-rotate-file": "^5.0.0"
28
28
  },
@@ -5,6 +5,7 @@ import {
5
5
  findOneStore,
6
6
  } from '../services/stores.service.js';
7
7
  import { aggregateUserAssignedStore, findOneUserAssignedStore } from '../services/userAssignedStore.service.js';
8
+ import { aggregateCluster } from '../services/cluster.service.js';
8
9
  import { aggregateGroup } from '../services/group.service.js';
9
10
  import dayjs from 'dayjs';
10
11
  import mongoose from 'mongoose';
@@ -682,7 +683,56 @@ export const headerLocationsV1 = async ( req, res ) => {
682
683
  return res.sendError( { error: error }, 500 );
683
684
  }
684
685
  };
685
-
686
+ export const headerLocationsV2 = async ( req, res ) => {
687
+ try {
688
+ let reqestData = req.body;
689
+ let getUserEmail = req.user.email;
690
+ let getUserType = req.user.userType;
691
+ let getRole = req.user.role;
692
+ let getClientId = reqestData.clientId;
693
+ let totalStores = await getStoresList( getUserEmail, getClientId, getUserType, getRole, req );
694
+ if ( totalStores && totalStores.length>0 ) {
695
+ let storeQuery = [
696
+ {
697
+ $match: {
698
+ $and: [
699
+ { clientId: { $eq: getClientId } },
700
+ { storeId: { $in: totalStores } },
701
+ ],
702
+ },
703
+ },
704
+ {
705
+ $group: {
706
+ _id: '$storeProfile.city',
707
+ },
708
+ },
709
+ {
710
+ $project: {
711
+ _id: 0,
712
+ city: '$_id',
713
+ },
714
+ },
715
+ {
716
+ $sort: {
717
+ city: -1,
718
+ },
719
+ },
720
+ ];
721
+ const cityList = await aggregateStore( storeQuery );
722
+ if ( cityList && cityList.length > 0 ) {
723
+ let city = cityList.filter( ( data ) => data.city!='' );
724
+ return res.sendSuccess( { locationData: city } );
725
+ } else {
726
+ return res.sendError( 'No City', 400 );
727
+ }
728
+ } else {
729
+ return res.sendError( 'No stores', 400 );
730
+ }
731
+ } catch ( error ) {
732
+ logger.error( { error: error, message: req.query, function: 'trafficCards' } );
733
+ return res.sendError( { error: error }, 500 );
734
+ }
735
+ };
686
736
  export const headerGroupsV1 = async ( req, res ) => {
687
737
  try {
688
738
  let requestData = req.body;
@@ -691,7 +741,7 @@ export const headerGroupsV1 = async ( req, res ) => {
691
741
  let getRole = req.user.role;
692
742
  let groupIds;
693
743
  if ( requestData.city && requestData.city.length>0 ) {
694
- let getGroupIds = await getCityStores( requestData.clientId, getUserEmail, getRole, requestData.city, getUserType );
744
+ let getGroupIds = await getCityStores( requestData.clientId, getUserEmail, getRole, requestData.city, getUserType, req );
695
745
  if ( getGroupIds && getGroupIds.length>0 ) {
696
746
  groupIds = getGroupIds;
697
747
  } else {
@@ -757,7 +807,141 @@ export const headerGroupsV1 = async ( req, res ) => {
757
807
  return res.sendError( { error: error }, 500 );
758
808
  }
759
809
  };
810
+ export async function headerClustersV2( req, res ) {
811
+ try {
812
+ let requestData = req.body;
813
+ let getUserEmail = req.user.email;
814
+ let getUserType = req.user.userType;
815
+ let getRole = req.user.role;
816
+ let clusterNames=[];
817
+ if ( requestData.city && requestData.city.length>0 ) {
818
+ let getcityclustes = await getCityClusters( requestData.clientId, getUserEmail, getRole, requestData.city, getUserType, req );
819
+ if ( getcityclustes && getcityclustes.length>0 ) {
820
+ clusterNames = getcityclustes;
821
+ } else {
822
+ clusterNames = [];
823
+ }
824
+ } else {
825
+ if ( getUserType == 'tango' ) {
826
+ clusterNames = await getclusterList( requestData.clientId, req );
827
+ } else if ( getUserType == 'client' ) {
828
+ if ( getRole == 'superadmin' ) {
829
+ clusterNames = await getclusterList( requestData.clientId, req );
830
+ } else {
831
+ clusterNames = await getclusterList( requestData.clientId, req );
832
+ }
833
+ }
834
+ }
835
+ const dataObjects = clusterNames.map( ( item ) => ( { groupName: item } ) );
836
+ res.sendSuccess( { groupData: dataObjects } );
837
+ } catch ( error ) {
838
+ logger.error( { error: error, message: req.query, function: 'headerClustersV2' } );
839
+ return res.sendError( { error: error }, 500 );
840
+ }
841
+ }
842
+
760
843
 
844
+ async function getCityClusters( userClientId, getUserEmail, getRole, requestCity, getUserType, req ) {
845
+ try {
846
+ if ( userClientId && userClientId !='' && getUserEmail && getUserEmail !='', getRole && getRole !='', requestCity && requestCity.length>0 ) {
847
+ let cityStores = await getLocationStores( userClientId, requestCity, req );
848
+ if ( cityStores && cityStores.length > 0 ) {
849
+ let storeGroups = await getClusterStoresIds( userClientId, cityStores, getRole, getUserType, getUserEmail );
850
+ if ( storeGroups && storeGroups.length > 0 ) {
851
+ return storeGroups;
852
+ } else {
853
+ return false;
854
+ }
855
+ } else {
856
+ return false;
857
+ }
858
+ } else {
859
+ return false;
860
+ }
861
+ } catch ( error ) {
862
+ logger.error( { error: error, function: 'getCityClusters' } );
863
+ return false;
864
+ }
865
+ }
866
+ async function getClusterStoresIds( userClientId, storeIds, getRole, getUserType, getUserEmail ) {
867
+ try {
868
+ if ( userClientId && userClientId !='' && storeIds && storeIds !='' && getRole && getRole !='' && getUserType && getUserType !='', getUserEmail && getUserEmail !='' ) {
869
+ let clusterQuery = [];
870
+ if ( getUserType == 'client' ) {
871
+ if ( getRole == 'superadmin' ) {
872
+ clusterQuery = [
873
+ {
874
+ $match: {
875
+ $and: [
876
+ { clientId: { $eq: userClientId } },
877
+ { 'stores.storeId': { $in: storeIds } },
878
+ ],
879
+ },
880
+ },
881
+ {
882
+ $group: {
883
+ _id: null,
884
+ clusterName: { $push: '$clusterName' },
885
+ },
886
+ },
887
+ ];
888
+ } else {
889
+ let getAssignedGroupIds = [
890
+ {
891
+ $match: {
892
+ $and: [
893
+ { clientId: { $eq: userClientId } },
894
+ { 'stores.storeId': { $in: storeIds } },
895
+ ],
896
+ },
897
+ },
898
+ {
899
+ $group: {
900
+ _id: null,
901
+ clusterName: { $push: '$clusterName' },
902
+ },
903
+ },
904
+ ];
905
+ const assignedclusters = await aggregateCluster( getAssignedGroupIds );
906
+ if ( assignedclusters && assignedclusters.length>0 && assignedclusters[0]?.clusterName.length > 0 ) {
907
+ let uniqueclusters = [ ...new Set( assignedclusters[0].clusterName ) ];
908
+ return uniqueclusters;
909
+ }
910
+ }
911
+ } else if ( getUserType == 'tango' ) {
912
+ clusterQuery = [
913
+ {
914
+ $match: {
915
+ $and: [
916
+ { clientId: { $eq: userClientId } },
917
+ { 'stores.storeId': { $in: storeIds } },
918
+ ],
919
+ },
920
+ },
921
+ {
922
+ $group: {
923
+ _id: null,
924
+ clusterName: { $push: '$clusterName' },
925
+ },
926
+ },
927
+ ];
928
+ }
929
+
930
+ const assignedclusters = await aggregateCluster( clusterQuery );
931
+ if ( assignedclusters && assignedclusters.length>0 && assignedclusters[0]?.clusterName.length > 0 ) {
932
+ let uniqueclusters = [ ...new Set( assignedclusters[0].clusterName ) ];
933
+ return uniqueclusters;
934
+ } else {
935
+ return false;
936
+ }
937
+ } else {
938
+ return false;
939
+ }
940
+ } catch ( error ) {
941
+ logger.error( { error: error, function: 'getGroupIds' } );
942
+ return false;
943
+ }
944
+ }
761
945
  export const headerStoresV1 = async ( req, res ) => {
762
946
  try {
763
947
  let reqestData = req.body;
@@ -861,6 +1045,140 @@ export const headerStoresV1 = async ( req, res ) => {
861
1045
  return res.sendError( { error: error }, 500 );
862
1046
  }
863
1047
  };
1048
+ export const headerStoresV2 = async ( req, res ) => {
1049
+ try {
1050
+ let reqestData = req.body;
1051
+ let getUserEmail = req.user.email;
1052
+ let getUserType = req.user.userType;
1053
+ let getRole = req.user.role;
1054
+ let getClientId = reqestData.clientId;
1055
+ let totalStores = await getStoresList( getUserEmail, getClientId, getUserType, getRole, req );
1056
+ if ( totalStores && totalStores.length>0 ) {
1057
+ let storeQuery = [];
1058
+ if ( reqestData.city.length>0 && reqestData.clusters.length>0 ) {
1059
+ let unqueCityStores = await getLocationStores( getClientId, reqestData.city, req );
1060
+ let unqueGroupStores = await getClusterStores( getClientId, reqestData.clusters );
1061
+ storeQuery = [
1062
+ {
1063
+ $match: {
1064
+ $and: [
1065
+ { storeId: { $in: totalStores } },
1066
+ { storeId: { $in: unqueCityStores } },
1067
+ { storeId: { $in: unqueGroupStores } },
1068
+ ],
1069
+ },
1070
+ },
1071
+ {
1072
+ $project: {
1073
+ _id: 0,
1074
+ storeId: '$storeId',
1075
+ storeName: '$storeName',
1076
+ },
1077
+ },
1078
+ ];
1079
+ } else if ( reqestData.city.length>0 ) {
1080
+ let uniqueCityStores = await getLocationStores( getClientId, reqestData.city, req );
1081
+ storeQuery = [
1082
+ {
1083
+ $match: {
1084
+ $and: [
1085
+ { storeId: { $in: totalStores } },
1086
+ { storeId: { $in: uniqueCityStores } },
1087
+ ],
1088
+ },
1089
+ },
1090
+ {
1091
+ $project: {
1092
+ _id: 0,
1093
+ storeId: '$storeId',
1094
+ storeName: '$storeName',
1095
+ },
1096
+ },
1097
+ ];
1098
+ } else if ( reqestData.clusters.length>0 ) {
1099
+ let uniqueclusterStores = await getClusterStores( getClientId, reqestData.clusters );
1100
+ storeQuery = [
1101
+ {
1102
+ $match: {
1103
+ $and: [
1104
+ { storeId: { $in: totalStores } },
1105
+ { storeId: { $in: uniqueclusterStores } },
1106
+ ],
1107
+ },
1108
+ },
1109
+ {
1110
+ $project: {
1111
+ _id: 0,
1112
+ storeId: '$storeId',
1113
+ storeName: '$storeName',
1114
+ },
1115
+ },
1116
+ ];
1117
+ } else {
1118
+ let totalStores = await getStoresList( getUserEmail, getClientId, getUserType, getRole, req );
1119
+ storeQuery = [
1120
+ {
1121
+ $match: {
1122
+ $and: [
1123
+ { storeId: { $in: totalStores } },
1124
+ ],
1125
+ },
1126
+ },
1127
+ {
1128
+ $project: {
1129
+ _id: 0,
1130
+ storeId: '$storeId',
1131
+ storeName: '$storeName',
1132
+ },
1133
+ },
1134
+ ];
1135
+ }
1136
+
1137
+ const storeList = await aggregateStore( storeQuery );
1138
+ if ( storeList && storeList.length > 0 ) {
1139
+ return res.sendSuccess( { storesData: storeList } );
1140
+ } else {
1141
+ return res.sendError( 'No Stores', 400 );
1142
+ }
1143
+ } else {
1144
+ return res.sendError( 'No Stores', 400 );
1145
+ }
1146
+ } catch ( error ) {
1147
+ logger.error( { error: error, message: req.query, function: 'headerStoresV2' } );
1148
+ return res.sendError( { error: error }, 500 );
1149
+ }
1150
+ };
1151
+
1152
+
1153
+ async function getStoresList( getUserEmail, getClientId, getUserType, getRole, req ) {
1154
+ try {
1155
+ if ( getUserEmail && getUserEmail !='' && getClientId && getClientId !='' && getUserType && getUserType !='' && getRole && getRole!='' ) {
1156
+ let overAllStores = [];
1157
+ if ( getUserType == 'tango' ) {
1158
+ let getAllS = await getAssignedAllStores( getClientId );
1159
+ if ( getAllS && getAllS.length >0 ) {
1160
+ overAllStores = getAllS;
1161
+ }
1162
+ return overAllStores;
1163
+ } else if ( getUserType == 'client' ) {
1164
+ if ( getRole == 'superadmin' ) {
1165
+ let getAllS = await getAssignedAllStores( getClientId );
1166
+ if ( getAllS && getAllS.length >0 ) {
1167
+ overAllStores = getAllS;
1168
+ }
1169
+ return overAllStores;
1170
+ } else {
1171
+ return req.body.assignedStores;
1172
+ }
1173
+ }
1174
+ } else {
1175
+ return false;
1176
+ }
1177
+ } catch ( error ) {
1178
+ logger.error( { error: error, message: req.query, function: 'getAllStores' } );
1179
+ }
1180
+ };
1181
+
864
1182
 
865
1183
  async function getAllStores( getUserEmail, getClientId, getUserType, getRole ) {
866
1184
  try {
@@ -1063,6 +1381,59 @@ async function getAssignedAllStores( userClientId ) {
1063
1381
  }
1064
1382
  }
1065
1383
 
1384
+
1385
+ async function getClusterStores( userClientId, ClusterList ) {
1386
+ try {
1387
+ if ( userClientId && userClientId !='' && ClusterList && ClusterList.length >0 ) {
1388
+ let ClusterQuery = [
1389
+ {
1390
+ $match: {
1391
+ $and: [
1392
+ { clientId: { $eq: userClientId } },
1393
+ { clusterName: { $in: ClusterList } },
1394
+ ],
1395
+ },
1396
+ },
1397
+ {
1398
+ $unwind: {
1399
+ path: '$storeList', preserveNullAndEmptyArrays: true,
1400
+ },
1401
+ },
1402
+ {
1403
+ $group: {
1404
+ _id: null,
1405
+ storesList: { $push: '$stores' },
1406
+ },
1407
+ },
1408
+ {
1409
+ $project: {
1410
+ storesList: {
1411
+ $reduce: {
1412
+ input: '$storesList', // Merge arrays using $reduce
1413
+ initialValue: [],
1414
+ in: { $concatArrays: [ '$$value', '$$this' ] },
1415
+ },
1416
+ },
1417
+ },
1418
+ },
1419
+ ];
1420
+ const clusterStoreList = await aggregateCluster( ClusterQuery );
1421
+ if ( clusterStoreList && clusterStoreList.length>0 && clusterStoreList[0]?.storesList.length > 0 ) {
1422
+ let storeIds = clusterStoreList[0].storesList.map( ( data ) => data.storeId );
1423
+ let uniqueStores = [ ...new Set( storeIds ) ];
1424
+ return uniqueStores;
1425
+ } else {
1426
+ return false;
1427
+ }
1428
+ } else {
1429
+ return false;
1430
+ }
1431
+ } catch ( error ) {
1432
+ logger.error( { error: error, message: data, function: 'getClusterStores' } );
1433
+ return false;
1434
+ }
1435
+ }
1436
+
1066
1437
  async function getGroupStores( userClientId, groupList ) {
1067
1438
  try {
1068
1439
  if ( userClientId && userClientId !='' && groupList && groupList.length >0 ) {
@@ -1103,16 +1474,21 @@ async function getGroupStores( userClientId, groupList ) {
1103
1474
  }
1104
1475
  }
1105
1476
 
1106
- async function getLocationStores( userClientId, cityList ) {
1477
+ async function getLocationStores( userClientId, cityList, req ) {
1107
1478
  try {
1108
1479
  if ( userClientId && userClientId !='' && cityList && cityList.length >0 ) {
1480
+ let filter = [
1481
+ { clientId: { $eq: userClientId } },
1482
+ { 'storeProfile.city': { $in: cityList } },
1483
+ ];
1484
+ if ( req.body.assignedStores&&req.body.assignedStores.length>0 ) {
1485
+ filter.push( { storeId: { $in: req.body.assignedStores } } );
1486
+ }
1487
+
1109
1488
  let storeQuery = [
1110
1489
  {
1111
1490
  $match: {
1112
- $and: [
1113
- { clientId: { $eq: userClientId } },
1114
- { 'storeProfile.city': { $in: cityList } },
1115
- ],
1491
+ $and: filter,
1116
1492
  },
1117
1493
  },
1118
1494
  {
@@ -1132,6 +1508,40 @@ async function getLocationStores( userClientId, cityList ) {
1132
1508
  if ( cityStoreList && cityStoreList.length>0 && cityStoreList[0]?.stores.length > 0 ) {
1133
1509
  let uniqueStores = [ ...new Set( cityStoreList[0].stores ) ];
1134
1510
  return uniqueStores;
1511
+ } else {
1512
+ return [];
1513
+ }
1514
+ } else {
1515
+ return [];
1516
+ }
1517
+ } catch ( error ) {
1518
+ logger.error( { error: error, function: 'getLocationStores' } );
1519
+ return false;
1520
+ }
1521
+ }
1522
+ async function getclusterList( userClientId, req ) {
1523
+ try {
1524
+ if ( userClientId && userClientId !='' ) {
1525
+ let clusterQuery = [
1526
+ {
1527
+ $match: {
1528
+ $and: [
1529
+ { clientId: { $eq: userClientId } },
1530
+ { 'stores.storeId': { $in: req.body.assignedStores } },
1531
+ ],
1532
+ },
1533
+ },
1534
+ {
1535
+ $group: {
1536
+ _id: null,
1537
+ clusterName: { $push: '$clusterName' },
1538
+ },
1539
+ },
1540
+ ];
1541
+ const clusterIds = await aggregateCluster( clusterQuery );
1542
+ if ( clusterIds && clusterIds.length>0 && clusterIds[0]?.clusterName.length > 0 ) {
1543
+ let uniqueclusterIds = [ ...new Set( clusterIds[0].clusterName ) ];
1544
+ return uniqueclusterIds;
1135
1545
  } else {
1136
1546
  return false;
1137
1547
  }
@@ -1139,11 +1549,10 @@ async function getLocationStores( userClientId, cityList ) {
1139
1549
  return false;
1140
1550
  }
1141
1551
  } catch ( error ) {
1142
- logger.error( { error: error, message: data, function: 'getLocationStores' } );
1552
+ logger.error( { error: error, function: 'getclusterList' } );
1143
1553
  return false;
1144
1554
  }
1145
1555
  }
1146
-
1147
1556
  async function getGroupIds( userClientId ) {
1148
1557
  try {
1149
1558
  if ( userClientId && userClientId !='' ) {
@@ -1218,10 +1627,10 @@ async function getAssignedGroupIds( userClientId, getUserEmail ) {
1218
1627
  }
1219
1628
  }
1220
1629
 
1221
- async function getCityStores( userClientId, getUserEmail, getRole, requestCity, getUserType ) {
1630
+ async function getCityStores( userClientId, getUserEmail, getRole, requestCity, getUserType, req ) {
1222
1631
  try {
1223
1632
  if ( userClientId && userClientId !='' && getUserEmail && getUserEmail !='', getRole && getRole !='', requestCity && requestCity.length>0 ) {
1224
- let cityStores = await getLocationStores( userClientId, requestCity );
1633
+ let cityStores = await getLocationStores( userClientId, requestCity, req );
1225
1634
  if ( cityStores && cityStores.length > 0 ) {
1226
1635
  let storeGroups = await getGroupStoresIds( userClientId, cityStores, getRole, getUserType, getUserEmail );
1227
1636
  if ( storeGroups && storeGroups.length > 0 ) {
@@ -202,10 +202,17 @@ export const validateHeaderSchema = joi.object( {
202
202
  group: joi.array().required(),
203
203
  } );
204
204
 
205
+ export const validateHeaderSchemav2 = joi.object( {
206
+ clientId: joi.string().required(),
207
+ city: joi.array().required(),
208
+ clusters: joi.array().required(),
209
+ } );
205
210
  export const validateHeaderParams = {
206
211
  body: validateHeaderSchema,
207
212
  };
208
-
213
+ export const validateHeaderParamsv2 = {
214
+ body: validateHeaderSchemav2,
215
+ };
209
216
  export const getMyProductSchema = joi.object( {
210
217
  clientId: joi.string().required(),
211
218
  storeId: joi.array().optional().empty(),
@@ -1,5 +1,5 @@
1
1
  import express from 'express';
2
- import { validate, isAllowedSessionHandler, authorize, isAllowedClient } from 'tango-app-api-middleware';
2
+ import { validate, isAllowedSessionHandler, isAllowedClient, getAssinedStore } from 'tango-app-api-middleware';
3
3
  import * as validationDtos from '../dtos/validation.dtos.js';
4
4
 
5
5
  export const analysisTrafficRouter = express.Router();
@@ -54,6 +54,9 @@ import {
54
54
  getMySubscription,
55
55
  getStoreMapData,
56
56
  funnelV1,
57
+ headerStoresV2,
58
+ headerClustersV2,
59
+ headerLocationsV2,
57
60
  } from '../controllers/tangoTrafficV1.controllers.js';
58
61
 
59
62
 
@@ -80,117 +83,33 @@ analysisTrafficRouter
80
83
  .post( '/headerLocations', headerLocations )
81
84
  .post( '/headerGroups', headerGroups )
82
85
  .post( '/headerStores', headerStores )
83
- .post( '/cardsFunnel_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
84
- userType: [ 'tango', 'client' ], access: [
85
- { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
86
- ],
87
- } ), validate( validationDtos.validateCardFunnelParams ), cardsFunnelV1 )
88
- .post( '/funnel_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
89
- userType: [ 'tango', 'client' ], access: [
90
- { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
91
- ],
92
- } ), validate( validationDtos.validateCardFunnelParams ), funnelV1 )
93
- .post( '/cardsGraphs_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
94
- userType: [ 'tango', 'client' ], access: [
95
- { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
96
- ],
97
- } ), validate( validationDtos.validateCardGraphParams ), cardsGraphsV1 )
98
- .post( '/recapVideo_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
99
- userType: [ 'tango', 'client' ], access: [
100
- { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
101
- ],
102
- } ), validate( validationDtos.validateRecapVideoParams ), recapVideoV1 )
103
- .post( '/densityDwell_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
104
- userType: [ 'tango', 'client' ], access: [
105
- { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
106
- ],
107
- } ), validate( validationDtos.validateDensityDwellParams ), densityDwellV1 )
108
- .post( '/overallCards_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
109
- userType: [ 'tango', 'client' ], access: [
110
- { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
111
- ],
112
- } ), validate( validationDtos.validateOverallCharParams ), overallCardsV1 )
113
- .post( '/overallHourlyChart_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
114
- userType: [ 'tango', 'client' ], access: [
115
- { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
116
- ],
117
- } ), validate( validationDtos.validateOverallCharParams ), overallHourlyChartV1 )
118
- .post( '/overallChart_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
119
- userType: [ 'tango', 'client' ], access: [
120
- { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
121
- ],
122
- } ), validate( validationDtos.validateOverallCharParams ), overallChartV1 )
123
- .post( '/singleStoreChart_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
124
- userType: [ 'tango', 'client' ], access: [
125
- { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
126
- ],
127
- } ), validate( validationDtos.validateSingleStoreChartParams ), singleStoreChartV1 )
128
- .post( '/demographicChart_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
129
- userType: [ 'tango', 'client' ], access: [
130
- { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
131
- ],
132
- } ), validate( validationDtos.validateDemographicChartParams ), demographicChartV1 )
133
- .post( '/buyerChart_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
134
- userType: [ 'tango', 'client' ], access: [
135
- { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
136
- ],
137
- } ), validate( validationDtos.validateBuyerChartParams ), buyerChartV1 )
138
- .post( '/footfallDirectoryFolders_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
139
- userType: [ 'tango', 'client' ], access: [
140
- { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
141
- ],
142
- } ), validate( validationDtos.validateFootfallDirectoryFoldersParams ), footfallDirectoryFoldersV1 )
143
- .post( '/footfallDirectory_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
144
- userType: [ 'tango', 'client' ], access: [
145
- { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
146
- ],
147
- } ), validate( validationDtos.validateFootfallDirectoryParams ), footfallDirectoryV1 )
148
- .post( '/summaryTable_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
149
- userType: [ 'tango', 'client' ], access: [
150
- { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
151
- ],
152
- } ), validate( validationDtos.validateSummaryTableParams ), summaryTableV1 )
153
- .post( '/footfallTrend_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
154
- userType: [ 'tango', 'client' ], access: [
155
- { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
156
- ],
157
- } ), validate( validationDtos.validateFootfallTrendParams ), footfallTrendV1 )
158
- .post( '/storeOperation_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
159
- userType: [ 'tango', 'client' ], access: [
160
- { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
161
- ],
162
- } ), validate( validationDtos.validateStoreOperationParams ), storeOperationV1 )
163
- .post( '/performanceMatrix_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
164
- userType: [ 'tango', 'client' ], access: [
165
- { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
166
- ],
167
- } ), validate( validationDtos.validateperformanceMatrixParams ), performanceMatrixV1 )
168
- .post( '/zoneDwellTimeSplit_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
169
- userType: [ 'tango', 'client' ], access: [
170
- { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
171
- ],
172
- } ), validate( validationDtos.validateStoreOperationParams ), zoneDwellTimeSplitV1 )
173
- .post( '/storesMap_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
174
- userType: [ 'tango', 'client' ], access: [
175
- { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
176
- ],
177
- } ), validate( validationDtos.validateStoresMapParams ), storesMapV1 )
178
- .post( '/headerLocations_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
179
- userType: [ 'tango', 'client' ], access: [
180
- { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
181
- ],
182
- } ), validate( validationDtos.validateHeaderParams ), headerLocationsV1 )
183
- .post( '/headerGroups_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
184
- userType: [ 'tango', 'client' ], access: [
185
- { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
186
- ],
187
- } ), validate( validationDtos.validateHeaderParams ), headerGroupsV1 )
188
- .post( '/headerStores_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
189
- userType: [ 'tango', 'client' ], access: [
190
- { featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
191
- ],
192
- } ), validate( validationDtos.validateHeaderParams ), headerStoresV1 )
86
+ .post( '/cardsFunnel_v1', isAllowedSessionHandler, isAllowedClient, validate( validationDtos.validateCardFunnelParams ), cardsFunnelV1 )
87
+ .post( '/funnel_v1', isAllowedSessionHandler, isAllowedClient, validate( validationDtos.validateCardFunnelParams ), funnelV1 )
88
+ .post( '/cardsGraphs_v1', isAllowedSessionHandler, isAllowedClient, validate( validationDtos.validateCardGraphParams ), cardsGraphsV1 )
89
+ .post( '/recapVideo_v1', isAllowedSessionHandler, isAllowedClient, validate( validationDtos.validateRecapVideoParams ), recapVideoV1 )
90
+ .post( '/densityDwell_v1', isAllowedSessionHandler, isAllowedClient, validate( validationDtos.validateDensityDwellParams ), densityDwellV1 )
91
+ .post( '/overallCards_v1', isAllowedSessionHandler, isAllowedClient, validate( validationDtos.validateOverallCharParams ), overallCardsV1 )
92
+ .post( '/overallHourlyChart_v1', isAllowedSessionHandler, isAllowedClient, validate( validationDtos.validateOverallCharParams ), overallHourlyChartV1 )
93
+ .post( '/overallChart_v1', isAllowedSessionHandler, isAllowedClient, validate( validationDtos.validateOverallCharParams ), overallChartV1 )
94
+ .post( '/singleStoreChart_v1', isAllowedSessionHandler, isAllowedClient, validate( validationDtos.validateSingleStoreChartParams ), singleStoreChartV1 )
95
+ .post( '/demographicChart_v1', isAllowedSessionHandler, isAllowedClient, validate( validationDtos.validateDemographicChartParams ), demographicChartV1 )
96
+ .post( '/buyerChart_v1', isAllowedSessionHandler, isAllowedClient, validate( validationDtos.validateBuyerChartParams ), buyerChartV1 )
97
+ .post( '/footfallDirectoryFolders_v1', isAllowedSessionHandler, isAllowedClient, validate( validationDtos.validateFootfallDirectoryFoldersParams ), footfallDirectoryFoldersV1 )
98
+ .post( '/footfallDirectory_v1', isAllowedSessionHandler, isAllowedClient, validate( validationDtos.validateFootfallDirectoryParams ), footfallDirectoryV1 )
99
+ .post( '/summaryTable_v1', isAllowedSessionHandler, isAllowedClient, validate( validationDtos.validateSummaryTableParams ), summaryTableV1 )
100
+ .post( '/footfallTrend_v1', isAllowedSessionHandler, isAllowedClient, validate( validationDtos.validateFootfallTrendParams ), footfallTrendV1 )
101
+ .post( '/storeOperation_v1', isAllowedSessionHandler, isAllowedClient, validate( validationDtos.validateStoreOperationParams ), storeOperationV1 )
102
+ .post( '/performanceMatrix_v1', isAllowedSessionHandler, isAllowedClient, validate( validationDtos.validateperformanceMatrixParams ), performanceMatrixV1 )
103
+ .post( '/zoneDwellTimeSplit_v1', isAllowedSessionHandler, isAllowedClient, validate( validationDtos.validateStoreOperationParams ), zoneDwellTimeSplitV1 )
104
+ .post( '/storesMap_v1', isAllowedSessionHandler, isAllowedClient, validate( validationDtos.validateStoresMapParams ), storesMapV1 )
105
+ .post( '/headerLocations_v1', isAllowedSessionHandler, isAllowedClient, validate( validationDtos.validateHeaderParams ), headerLocationsV1 )
106
+ .post( '/headerGroups_v1', isAllowedSessionHandler, isAllowedClient, validate( validationDtos.validateHeaderParams ), headerGroupsV1 )
107
+ .post( '/headerStores_v1', isAllowedSessionHandler, isAllowedClient, validate( validationDtos.validateHeaderParams ), headerStoresV1 )
193
108
  .post( '/getMySubscription', isAllowedSessionHandler, validate( validationDtos.getMyProductParams ), getMySubscription )
194
- .post( '/getStoreMapData', isAllowedSessionHandler, validate( validationDtos.getStoreCameraImageParams ), getStoreMapData );
109
+ .post( '/getStoreMapData', isAllowedSessionHandler, validate( validationDtos.getStoreCameraImageParams ), getStoreMapData )
110
+ .post( '/headerStores_v2', isAllowedSessionHandler, isAllowedClient, validate( validationDtos.validateHeaderParamsv2 ), getAssinedStore, headerStoresV2 )
111
+ .post( '/headercluster_v2', isAllowedSessionHandler, isAllowedClient, validate( validationDtos.validateHeaderParams ), getAssinedStore, headerClustersV2 )
112
+ .post( '/headerLocations_v2', isAllowedSessionHandler, isAllowedClient, validate( validationDtos.validateHeaderParams ), getAssinedStore, headerLocationsV2 );
113
+
195
114
 
196
115
  export default analysisTrafficRouter;
@@ -0,0 +1,28 @@
1
+ import clusterModel from 'tango-api-schema/schema/cluster.model.js';
2
+
3
+ export async function updateOneCluster( query, record ) {
4
+ return await clusterModel.updateOne( query, { $set: record } );
5
+ };
6
+
7
+ export async function updateCluster( query, record ) {
8
+ return await clusterModel.updateMany( query, record );
9
+ };
10
+
11
+ export async function aggregateCluster( query ) {
12
+ return await clusterModel.aggregate( query );
13
+ };
14
+
15
+ export async function findOneCluster( query ={}, field={} ) {
16
+ return await clusterModel.findOne( query, field );
17
+ };
18
+ export async function deleteCluster( query ={} ) {
19
+ return await clusterModel.deleteOne( query );
20
+ };
21
+
22
+ export async function createclusterModel( data ) {
23
+ return await clusterModel.create( data );
24
+ };
25
+
26
+ export async function findcluster( query, project ) {
27
+ return await clusterModel.find( query, project );
28
+ };