tango-app-api-analysis-zone 3.0.0-alpha.27 → 3.0.0-alpha.29

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-zone",
3
- "version": "3.0.0-alpha.27",
3
+ "version": "3.0.0-alpha.29",
4
4
  "description": "zone Analysis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -251,6 +251,26 @@ export const zoneHeatmapDatasV1 = async ( req, res ) => {
251
251
  }
252
252
  };
253
253
 
254
+ export const zoneSegmentationV1 = async ( req, res ) => {
255
+ try {
256
+ let reqestData = req.body;
257
+ let LamdaURL = 'https://7ijmuxyqsv7rdz6pkz6fhk6ka40cipbh.lambda-url.ap-south-1.on.aws/';
258
+ let resultData = await LamdaServiceCall( LamdaURL, reqestData );
259
+ if ( resultData ) {
260
+ if ( resultData.status_code == '200' ) {
261
+ return res.sendSuccess( resultData );
262
+ } else {
263
+ return res.sendError( 'No Content', 204 );
264
+ }
265
+ } else {
266
+ return res.sendError( 'No Content', 204 );
267
+ }
268
+ } catch ( error ) {
269
+ logger.error( { error: error, message: req.query, function: 'zoneSegmentationV1' } );
270
+ return res.sendError( { error: error }, 500 );
271
+ }
272
+ };
273
+
254
274
  export async function isAllowedClient( req, res, next ) {
255
275
  try {
256
276
  let reqestData = req.body;
@@ -180,6 +180,26 @@ export const zoneConcentrationSummaryV2 = async ( req, res ) => {
180
180
  export const overallStoreConcentrationDatesV2 = async ( req, res ) => {
181
181
  try {
182
182
  let reqestData = req.body;
183
+
184
+ const date1 = new Date( reqestData.fromDate );
185
+ const date2 = new Date( reqestData.toDate );
186
+ // Get the difference in milliseconds
187
+ const diffInMs = date2 - date1;
188
+ // Convert milliseconds to days
189
+ let diffInDays = parseInt( diffInMs / ( 1000 * 60 * 60 * 24 ) );
190
+ if ( diffInDays <= 7 ) {
191
+ if ( reqestData.dateType == 'weekly' ) {
192
+ // subtract 7 days to the date
193
+ date2.setDate( date2.getDate() - 7 );
194
+ reqestData.fromDate = date2.toISOString().slice( 0, 10 );
195
+ }
196
+ if ( reqestData.dateType == 'monthly' ) {
197
+ // subtract 31 days to the date
198
+ date2.setDate( date2.getDate() - 31 );
199
+ reqestData.fromDate = date2.toISOString().slice( 0, 10 );
200
+ }
201
+ }
202
+
183
203
  let LamdaURL = 'https://nmjcclomhgdecmoyned3sp6y6q0pemhg.lambda-url.ap-south-1.on.aws/';
184
204
  let resultData = await LamdaServiceCall( LamdaURL, reqestData );
185
205
  if ( resultData ) {
@@ -214,4 +214,11 @@ export const validateCustomerJourneyTableV2Params = {
214
214
  body: validatCustomerJourneyTableV2Schema,
215
215
  };
216
216
 
217
+ export const validateZoneSegmentationSchema = joi.object( {
218
+ ...baseSchema,
219
+ } );
220
+ export const validateZoneSegmentationParams = {
221
+ body: validateZoneSegmentationSchema,
222
+ };
223
+
217
224
 
@@ -23,6 +23,7 @@ import {
23
23
  zoneConcentrationSummaryTableV1,
24
24
  zoneHeatmapAvailableDatesV1,
25
25
  zoneHeatmapDatasV1,
26
+ zoneSegmentationV1,
26
27
  isAllowedClient,
27
28
  } from '../controllers/analysisZoneV1.controllers.js';
28
29
 
@@ -69,6 +70,11 @@ analysisZoneRouter
69
70
  userType: [ 'tango', 'client' ], access: [
70
71
  { featureName: 'analytics', name: 'tangoZone', permissions: [ 'isView' ] },
71
72
  ],
72
- } ), validate( validationDtos.validateZoneHeatmapDatasParams ), zoneHeatmapDatasV1 );
73
+ } ), validate( validationDtos.validateZoneHeatmapDatasParams ), zoneHeatmapDatasV1 )
74
+ .post( '/zoneSegmentation_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
75
+ userType: [ 'tango', 'client' ], access: [
76
+ { featureName: 'analytics', name: 'tangoZone', permissions: [ 'isView' ] },
77
+ ],
78
+ } ), validate( validationDtos.validateZoneSegmentationParams ), zoneSegmentationV1 );
73
79
 
74
80
  export default analysisZoneRouter;