tango-app-api-analysis-traffic 3.3.1-alpha.1 → 3.3.1-alpha.10-airtel

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.3.1-alpha.1",
3
+ "version": "3.3.1-alpha.10-airtel",
4
4
  "description": "Traffic Analysis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1070,6 +1070,8 @@ export const headerStoresV2 = async ( req, res ) => {
1070
1070
  { storeId: { $in: totalStores } },
1071
1071
  { storeId: { $in: unqueCityStores } },
1072
1072
  { storeId: { $in: unqueGroupStores } },
1073
+ { 'edge.firstFile': true },
1074
+ { status: { $eq: 'active' } },
1073
1075
  ],
1074
1076
  },
1075
1077
  },
@@ -1089,6 +1091,8 @@ export const headerStoresV2 = async ( req, res ) => {
1089
1091
  $and: [
1090
1092
  { storeId: { $in: totalStores } },
1091
1093
  { storeId: { $in: uniqueCityStores } },
1094
+ { 'edge.firstFile': true },
1095
+ { status: { $eq: 'active' } },
1092
1096
  ],
1093
1097
  },
1094
1098
  },
@@ -1108,6 +1112,8 @@ export const headerStoresV2 = async ( req, res ) => {
1108
1112
  $and: [
1109
1113
  { storeId: { $in: totalStores } },
1110
1114
  { storeId: { $in: uniqueclusterStores } },
1115
+ { 'edge.firstFile': true },
1116
+ { status: { $eq: 'active' } },
1111
1117
  ],
1112
1118
  },
1113
1119
  },
@@ -1126,6 +1132,8 @@ export const headerStoresV2 = async ( req, res ) => {
1126
1132
  $match: {
1127
1133
  $and: [
1128
1134
  { storeId: { $in: totalStores } },
1135
+ { 'edge.firstFile': true },
1136
+ { status: { $eq: 'active' } },
1129
1137
  ],
1130
1138
  },
1131
1139
  },
@@ -1360,6 +1368,7 @@ async function getAssignedAllStores( userClientId ) {
1360
1368
  $and: [
1361
1369
  { clientId: { $eq: userClientId } },
1362
1370
  { status: { $eq: 'active' } },
1371
+ { 'edge.firstFile': true },
1363
1372
  ],
1364
1373
  },
1365
1374
  },
@@ -1489,6 +1498,7 @@ async function getLocationStores( userClientId, cityList, req ) {
1489
1498
  if ( req.body.assignedStores&&req.body.assignedStores.length>0 ) {
1490
1499
  filter.push( { storeId: { $in: req.body.assignedStores } } );
1491
1500
  }
1501
+ filter.push( { 'edge.firstFile': true }, { status: { $eq: 'active' } } );
1492
1502
 
1493
1503
  let storeQuery = [
1494
1504
  {
@@ -588,10 +588,25 @@ export const summaryTableV3 = async ( req, res ) => {
588
588
  try {
589
589
  let reqestData = req.body;
590
590
  let getClientData = await getClientConfig( reqestData.clientId );
591
+ let featureConfigs = getClientData?.featureConfigs || {};
592
+ const engagersLabel = featureConfigs?.bouncedLimit?.value ?
593
+ `More than ${featureConfigs.bouncedLimit.value} mins` :
594
+ 'Engagers';
595
+ const bouncedLabel = featureConfigs?.bouncedLimit?.value ?
596
+ `Less than ${featureConfigs.bouncedLimit.value} mins Count` :
597
+ 'Bounced Count';
598
+ const conversionLabel = featureConfigs?.conversion?.value ?
599
+ `More than ${featureConfigs.conversion.value} mins Rate` :
600
+ 'Conversion Rate';
601
+ const missedlabel = featureConfigs?.bouncedLimit?.value && featureConfigs?.conversion?.value ?
602
+ `${featureConfigs.bouncedLimit.value} - ${featureConfigs.conversion.value} mins` :
603
+ 'MissedOpportunity';
591
604
  if ( !getClientData ) {
592
605
  return res.sendError( 'Invalid Client Id', 400 );
593
606
  }
594
607
  reqestData.featureConfigs = getClientData.featureConfigs;
608
+
609
+
595
610
  let LamdaURL = 'https://ewen2vlmxmhieea4elztlbjuey0ddqee.lambda-url.ap-south-1.on.aws/';
596
611
  let resultData;
597
612
  if ( reqestData.export ) {
@@ -619,7 +634,7 @@ export const summaryTableV3 = async ( req, res ) => {
619
634
  if ( resultData ) {
620
635
  if ( resultData.status_code == '200' ) {
621
636
  if ( reqestData.export ) {
622
- if ( resultData.summaryData.length>0 ) {
637
+ if ( resultData.summaryData.length > 0 ) {
623
638
  const exportdata = [];
624
639
  resultData.summaryData.forEach( ( element ) => {
625
640
  if ( reqestData.clientId === '193' ) {
@@ -632,10 +647,10 @@ export const summaryTableV3 = async ( req, res ) => {
632
647
  'Engagers': element.engagersCount,
633
648
  'MissedOpportunity': element.missedOpportunityCount,
634
649
  'Potential Buyers': element.potentialBuyersCount,
635
- 'Conversion Rate': element.conversionRate,
636
650
  'NOB Count': element.NOBCount,
637
651
  'Avg.Dwell Time': element.avgDwellTime,
638
652
  'Avg.Infra DownTime': element.avgInfraDowntime,
653
+ ...( element.passerBy_count !== undefined ? { 'Passer By': element.passerBy_count } : {} ),
639
654
  'Below12': element.below12,
640
655
  '13-19': element['13-19'],
641
656
  '20-30': element['20-30'],
@@ -646,6 +661,29 @@ export const summaryTableV3 = async ( req, res ) => {
646
661
  'Male': element.male,
647
662
  'Female': element.female,
648
663
  } );
664
+ } else if ( reqestData.clientId === '452' ) {
665
+ exportdata.push( {
666
+ 'Store Name': element.storeName,
667
+ 'Store ID': element.storeId,
668
+ ...( req.body.storeId.length ==1 ) ? { Date: element['date'] }:{},
669
+ 'Footfall': element.footfallCount,
670
+ ...( bouncedLabel ? { [bouncedLabel]: element.bouncedCount } : {} ),
671
+ ...( engagersLabel ? { [engagersLabel]: element.engagersCount } : {} ),
672
+ ...( missedlabel ? { [missedlabel]: element.missedOpportunityCount } : {} ),
673
+ ...( conversionLabel ? { [conversionLabel]: element.conversionRate } : {} ),
674
+ 'NOB Count': element.NOBCount,
675
+ 'Avg.Dwell Time': element.avgDwellTime,
676
+ 'Avg.Infra DownTime': element.avgInfraDowntime,
677
+ ...( element.passerBy_count !== undefined ? { 'Passer By': element.passerBy_count } : {} ),
678
+ 'Below12': element.below12,
679
+ '13-19': element['13-19'],
680
+ '20-30': element['20-30'],
681
+ '31-45': element['31-45'],
682
+ '46-59': element['46-59'],
683
+ '60 above': element['60 above'],
684
+ 'Male': element.male,
685
+ 'Female': element.female,
686
+ } );
649
687
  } else {
650
688
  exportdata.push( {
651
689
  'Store Name': element.storeName,
@@ -660,6 +698,7 @@ export const summaryTableV3 = async ( req, res ) => {
660
698
  'NOB Count': element.NOBCount,
661
699
  'Avg.Dwell Time': element.avgDwellTime,
662
700
  'Avg.Infra DownTime': element.avgInfraDowntime,
701
+ ...( element.passerBy_count !== undefined ? { 'Passer By': element.passerBy_count } : {} ),
663
702
  'Below12': element.below12,
664
703
  '13-19': element['13-19'],
665
704
  '20-30': element['20-30'],
@@ -2005,7 +2044,7 @@ async function getGroupStoresIds( userClientId, storeIds, getRole, getUserType,
2005
2044
 
2006
2045
  async function getClientConfig( clientId ) {
2007
2046
  try {
2008
- let getClientData = await clientService.findOne( { clientId: clientId }, { 'paymentInvoice.currencyType': 1, 'averageTransactionValue': 1, 'featureConfigs.billableCalculation': 1, 'featureConfigs.missedOpportunityCalculation': 1, 'featureConfigs.conversionCalculation': 1, 'featureConfigs.open': 1, 'featureConfigs.close': 1, 'isFootfallAuditStores': 1 } );
2047
+ let getClientData = await clientService.findOne( { clientId: clientId }, { 'paymentInvoice.currencyType': 1, 'averageTransactionValue': 1, 'featureConfigs.billableCalculation': 1, 'featureConfigs.missedOpportunityCalculation': 1, 'featureConfigs.conversionCalculation': 1, 'featureConfigs.open': 1, 'featureConfigs.close': 1, 'isFootfallAuditStores': 1, 'featureConfigs.bouncedLimit': 1, 'featureConfigs.conversion': 1 } );
2009
2048
  if ( !getClientData ) {
2010
2049
  return false;
2011
2050
  }
@@ -8,10 +8,15 @@ export const addBillsSchema = joi.object( {
8
8
  'string.empty': 'Please enter a valid Store ID',
9
9
  'any.required': 'Store ID is required',
10
10
  } ).allow( null ),
11
- nobDate: joi.string().required().messages( {
12
- 'string.empty': 'Please enter a valid NOB Date',
13
- 'any.required': 'NOB Date is required',
14
- } ).allow( null ),
11
+ nobDate: joi.string()
12
+ .pattern( /^\d{4}-\d{2}-\d{2}$/ ) // Ensures format YYYY-MM-DD
13
+ .required()
14
+ .messages( {
15
+ 'string.pattern.base': 'NOB Date must be in YYYY-MM-DD format',
16
+ 'string.empty': 'Please enter a valid NOB Date',
17
+ 'any.required': 'NOB Date is required',
18
+ } )
19
+ .allow( null ),
15
20
  nobCount: joi.number().required().messages( {
16
21
  'string.empty': 'Please enter a valid NOB Count',
17
22
  'any.required': 'NOB Count is required',
@@ -10,6 +10,7 @@ const baseSchema = {
10
10
  nob: joi.boolean().optional().allow( '' ),
11
11
  dateType: joi.string().optional().allow( '' ),
12
12
  normalize: joi.boolean().optional().allow( '' ),
13
+ conversiontype: joi.string().optional().allow( '' ),
13
14
  };
14
15
 
15
16
  // Schema for Card Funnel
@@ -37,6 +38,7 @@ export const validateRecapVideoSchema = joi.object( {
37
38
  recapVideoDate: joi.string().required(),
38
39
  valueType: joi.string().optional().allow( '' ),
39
40
  nob: joi.boolean().optional().allow( '' ),
41
+ conversiontype: joi.string().optional().allow( '' ),
40
42
  } );
41
43
 
42
44
  export const validateRecapVideoParams = {