tango-app-api-analysis-traffic 3.8.7-vms.2 → 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.2",
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 );