tango-app-api-analysis-traffic 3.8.7-vms.1 → 3.8.7-vms.3

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.8.7-vms.1",
3
+ "version": "3.8.7-vms.3",
4
4
  "description": "Traffic Analysis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -306,12 +306,19 @@ export async function storeProcessedData( req, res ) {
306
306
  },
307
307
  },
308
308
  size: 1,
309
- _source: [ 'status' ],
309
+ _source: [ 'status', 'mappingInfo' ],
310
310
  };
311
311
  try {
312
312
  const footfallDirRes = await getOpenSearchData( openSearch.footfallDirectory, footfallDirQuery );
313
313
  const hit = footfallDirRes?.body?.hits?.hits?.[0];
314
- ticketStatus = hit?._source?.status || null;
314
+ if ( hit?._source?.mappingInfo && Array.isArray( hit._source.mappingInfo ) ) {
315
+ for ( let i = 0; i < hit._source.mappingInfo.length; i++ ) {
316
+ if ( hit._source.mappingInfo[i].type === 'tagging' ) {
317
+ ticketStatus = hit._source.mappingInfo[i].status;
318
+ break;
319
+ }
320
+ }
321
+ }
315
322
  } catch ( err ) {
316
323
  logger.warn( { message: 'Could not get ticket status from footfallDirectory', error: err } );
317
324
  }
@@ -335,7 +342,27 @@ export async function storeProcessedData( req, res ) {
335
342
  downtime: processedData?.down_time || 0,
336
343
  ticketStatus,
337
344
  raisedStatusEnabled,
345
+
338
346
  } );
347
+
348
+ if ( raisedStatusEnabled === 'block' ) {
349
+ // Calculate the number of days from currentDate + 1 to the end of the month
350
+ // Assume currentDate is in format 'YYYY-MM-DD'
351
+ const currentDateObj = new Date( currentDate );
352
+ // Move to next day
353
+ const nextDay = new Date( currentDateObj );
354
+ nextDay.setDate( currentDateObj.getDate() + 1 );
355
+
356
+ // Get the last date of the current month
357
+ const endOfMonth = new Date( currentDateObj.getFullYear(), currentDateObj.getMonth() + 1, 0 );
358
+
359
+ // Calculate number of days (inclusive of end date, exclusive of nextDay)
360
+ let noOfBlockedDays = Math.floor( ( endOfMonth - nextDay ) / ( 1000 * 60 * 60 * 24 ) ) + 1;
361
+ if ( noOfBlockedDays < 0 ) noOfBlockedDays = 0;
362
+
363
+ // Add to response
364
+ responseArray[responseArray.length - 1].noOfBlockedDays = noOfBlockedDays;
365
+ }
339
366
  }
340
367
 
341
368
  return res.sendSuccess( responseArray );
@@ -379,7 +406,7 @@ export async function footFallImages( req, res ) {
379
406
  ],
380
407
  },
381
408
  },
382
- '_source': [ 'dateString', 'storeId', 'duplicateCount', 'footfallCount', 'employeeCount', 'houseKeepingCount', 'junkCount', 'status', 'ticketId', 'comments', 'userName', 'role', 'createdAt', 'email', 'houseKeepingACCount', 'duplicateACCount', 'employeeACCount', 'junkACCount', 'approverEmail', 'approverRole', 'approverUserName' ],
409
+ // '_source': [ 'dateString', 'storeId', 'duplicateCount', 'footfallCount', 'employeeCount', 'houseKeepingCount', 'junkCount', 'status', 'ticketId', 'comments', 'userName', 'role', 'createdAt', 'email', 'houseKeepingACCount', 'duplicateACCount', 'employeeACCount', 'junkACCount', 'approverEmail', 'approverRole', 'approverUserName' ],
383
410
 
384
411
  };
385
412
 
@@ -406,7 +433,7 @@ export async function footFallImages( req, res ) {
406
433
  if ( resultData ) {
407
434
  temp.length? temp[0].status = 'open': null;
408
435
  if ( resultData.status_code == '200' ) {
409
- return res.sendSuccess( { ...resultData, ticketStatus: temp?.length > 0? temp : null, config: req?.store?.revopTagging } );
436
+ return res.sendSuccess( { ...resultData, ticketStatus: temp?.length > 0? temp : null, config: req?.store?.footfallDirectoryConfigs } );
410
437
  } else {
411
438
  return res.sendError( 'No Content', 204 );
412
439
  }
@@ -66,6 +66,9 @@ export const tagTempIdSchema = joi.object( {
66
66
  revopsType: joi.string().required(),
67
67
  timeRange: joi.string().required(),
68
68
  isChecked: joi.boolean().required().allow( null ),
69
+ mode: joi.string().valid( 'web', 'mobile' ).required().messages( {
70
+ 'any.only': 'type must be one of [mobile,web]',
71
+ } ),
69
72
  duplicateImage: joi.array().items( joi.object(
70
73
  {
71
74
  tempId: joi.number().required(),
@@ -1,11 +1,25 @@
1
1
  import { getOpenSearchCount, logger } from 'tango-app-api-middleware';
2
2
  import { findOneStore } from '../services/stores.service.js';
3
3
  import { deleteByQuery } from 'tango-app-api-middleware/src/utils/openSearch.js';
4
+ import { findOne } from '../services/clients.services.js';
4
5
 
5
6
  export async function getTaggingConfig( req, res, next ) {
6
7
  try {
7
8
  const inputData= req.query;
8
- const getData = await findOneStore( { storeId: inputData.storeId }, { revopTagging: 1 } );
9
+ const clientId = inputData.storeId.split( '-' )[0];
10
+ const getData = await findOne( { clientId: clientId }, { footfallDirectoryConfigs: 1 } );
11
+
12
+ // Convert "taggingLimitation" array (if present) to "config" object with expected key-value pairs
13
+ let config = {};
14
+ if ( getData && Array.isArray( getData.taggingLimitation ) ) {
15
+ for ( const item of getData.taggingLimitation ) {
16
+ if ( item && item.type && typeof item.value !== 'undefined' && item.unit ) {
17
+ config[item.type] = `${item.value}${item.unit}`;
18
+ }
19
+ }
20
+ }
21
+ getData.config = config;
22
+
9
23
  req.store = getData;
10
24
  next();
11
25
  } catch ( error ) {