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

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/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
 
2
2
 
3
3
  import { analysisTrafficRouter } from './src/routes/traffic.routes.js';
4
+ import { revopRouter } from './src/routes/revop.routes.js';
4
5
  import { mobileTrafficAnalysisRouter } from './src/routes/mobileTraffic.routes.js';
5
6
  import { nobDocs } from './src/docs/nob.docs.js';
6
7
  import nobRouter from './src/routes/nob.routes.js';
7
8
 
8
- export { analysisTrafficRouter, mobileTrafficAnalysisRouter, nobDocs, nobRouter };
9
+ export { analysisTrafficRouter, mobileTrafficAnalysisRouter, nobDocs, nobRouter, revopRouter };
9
10
 
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",
4
4
  "description": "Traffic Analysis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -23,7 +23,7 @@
23
23
  "mongodb": "^6.8.0",
24
24
  "nodemon": "^3.1.4",
25
25
  "swagger-ui-express": "^5.0.1",
26
- "tango-api-schema": "^2.2.7",
26
+ "tango-api-schema": "^2.2.109",
27
27
  "tango-app-api-middleware": "^3.1.55",
28
28
  "winston": "^3.13.1",
29
29
  "winston-daily-rotate-file": "^5.0.0"
@@ -0,0 +1,30 @@
1
+ import { logger, insertOpenSearchData } from 'tango-app-api-middleware';
2
+ import { findOnerevopConfig } from '../services/revopConfig.service.js';
3
+
4
+ export async function getconfig( req, res ) {
5
+ try {
6
+ console.log( req.query );
7
+ let result = await findOnerevopConfig( { clientId: req.query.clientId } );
8
+ console.log( result );
9
+ if ( result===null ) {
10
+ return res.sendError( 'no data found', 204 );
11
+ }
12
+ return res.sendSuccess( result );
13
+ } catch ( error ) {
14
+ logger.error( { error: error, message: req.query, function: 'getconfig' } );
15
+ return res.sendError( { error: error }, 500 );
16
+ }
17
+ }
18
+
19
+ export async function revoptagging( req, res ) {
20
+ try {
21
+ const openSearch = JSON.parse( process.env.OPENSEARCH );
22
+ console.log( openSearch.revops );
23
+ let respo= await insertOpenSearchData( openSearch.revops, req.body );
24
+ console.log( respo );
25
+ return res.sendSuccess( 'Data has been inserted successfully' );
26
+ } catch ( error ) {
27
+ logger.error( { error: error, message: req.query, function: 'revoptagging' } );
28
+ return res.sendError( { error: error }, 500 );
29
+ }
30
+ }
@@ -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
  {
@@ -619,7 +619,7 @@ export const summaryTableV3 = async ( req, res ) => {
619
619
  if ( resultData ) {
620
620
  if ( resultData.status_code == '200' ) {
621
621
  if ( reqestData.export ) {
622
- if ( resultData.summaryData.length>0 ) {
622
+ if ( resultData.summaryData.length > 0 ) {
623
623
  const exportdata = [];
624
624
  resultData.summaryData.forEach( ( element ) => {
625
625
  if ( reqestData.clientId === '193' ) {
@@ -636,6 +636,7 @@ export const summaryTableV3 = async ( req, res ) => {
636
636
  'NOB Count': element.NOBCount,
637
637
  'Avg.Dwell Time': element.avgDwellTime,
638
638
  'Avg.Infra DownTime': element.avgInfraDowntime,
639
+ ...( element.passerBy_count !== undefined ? { 'Passer By': element.passerBy_count } : {} ),
639
640
  'Below12': element.below12,
640
641
  '13-19': element['13-19'],
641
642
  '20-30': element['20-30'],
@@ -660,6 +661,7 @@ export const summaryTableV3 = async ( req, res ) => {
660
661
  'NOB Count': element.NOBCount,
661
662
  'Avg.Dwell Time': element.avgDwellTime,
662
663
  'Avg.Infra DownTime': element.avgInfraDowntime,
664
+ ...( element.passerBy_count !== undefined ? { 'Passer By': element.passerBy_count } : {} ),
663
665
  'Below12': element.below12,
664
666
  '13-19': element['13-19'],
665
667
  '20-30': element['20-30'],
@@ -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 = {
@@ -0,0 +1,13 @@
1
+
2
+ import express from 'express';
3
+ import { getconfig, revoptagging } from '../controllers/revop.controller.js';
4
+ import { isAllowedSessionHandler, isAllowedClient } from 'tango-app-api-middleware';
5
+
6
+ export const revopRouter = express.Router();
7
+
8
+ revopRouter
9
+ .get( '/getconfig', isAllowedSessionHandler, isAllowedClient, getconfig )
10
+ .post( '/tagging', isAllowedSessionHandler, isAllowedClient, revoptagging ); ;
11
+
12
+
13
+ export default revopRouter;
@@ -0,0 +1,16 @@
1
+ import revopConfigModel from 'tango-api-schema/schema/revopConfig.model.js';
2
+
3
+
4
+ export async function createrevopConfig( field = {} ) {
5
+ return await revopConfigModel.create( field );
6
+ };
7
+ export async function findOnerevopConfig( query = {} ) {
8
+ return await revopConfigModel.findOne( query );
9
+ };
10
+
11
+ export async function updaterevopConfig( data={}, field = {} ) {
12
+ return await revopConfigModel.updateOne( data, { $set: field } );
13
+ };
14
+ export async function aggregaterevopconfig( data ) {
15
+ return await revopConfigModel.aggregate( data );
16
+ };