tango-app-api-report 3.5.2 → 3.5.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-report",
3
- "version": "3.5.2",
3
+ "version": "3.5.3",
4
4
  "description": "report",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -126,7 +126,7 @@ export async function isAuditCompleted( req, res, next ) {
126
126
  $match: {
127
127
  $and: [
128
128
  {
129
- fileDate: { $eq: inputData.fileDate },
129
+ fileDate: { $eq: inputData?.fileDate.split( '-' ).reverse().join( '-' ) },
130
130
  },
131
131
  {
132
132
  clientId: { $eq: inputData.clientId },
@@ -348,13 +348,68 @@ async function checkZoneQueueCount( queueName ) {
348
348
  export async function isFeatureRunning( req, res, next ) {
349
349
  try {
350
350
  const inputData = req.body;
351
+ if ( req?.report?.reportConfigs?.reportType === 'manual' ) {
352
+ const url = JSON.parse( process.env.URL );
353
+ const openSearch = JSON.parse( process.env.OPENSEARCH );
354
+ const FeatureURL = url.FeatureStatus;
355
+ const data = { 'client_id': inputData.clientId, 'store_date': inputData?.fileDate.split( '-' ).reverse().join( '-' ) };
356
+ const isFeature = await callLambdaWithData( data, FeatureURL );
357
+ const logInfo = {
358
+ userName: req.user.userName,
359
+ userId: req.user._id,
360
+ logType: 'reportLog',
361
+ logSubType: 'generateReportLog',
362
+ logData: {
363
+ fileDate: inputData?.fileDate.split( '-' ).reverse().join( '-' ),
364
+ reportName: req?.report?.reportConfigs?.reportName,
365
+ clientId: inputData?.clientId,
366
+ reportType: req?.report?.reportConfigs?.reportType,
367
+ message: 'get-feature-count-info',
368
+ isFeatureData: JSON.stringify( isFeature ),
369
+ infoType: 'info',
370
+ },
371
+ createdAt: Date.now(),
372
+ };
373
+ await insertOpenSearchData( openSearch?.auditLog, logInfo );
374
+ if ( isFeature?.status_code !== '200' ) {
375
+ return res.sendError(
376
+ 'This client is already being processed in the Queue. Please try again later.',
377
+ 400,
378
+ );
379
+ } else if ( isFeature?.data === false ) {
380
+ const logBooErr = {
381
+ userName: req.user.userName,
382
+ userId: req.user._id,
383
+ logType: 'reportLog',
384
+ logSubType: 'generateReportLog',
385
+ logData: {
386
+ fileDate: inputData?.fileDate.split( '-' ).reverse().join( '-' ),
387
+ reportName: req?.report?.reportConfigs?.reportName,
388
+ clientId: inputData?.clientId,
389
+ reportType: req?.report?.reportConfigs?.reportType,
390
+ message: 'get-feature-boolean-err',
391
+ featureData: JSON.stringify( isFeature ),
392
+ infoType: 'error',
393
+ },
394
+ createdAt: Date.now(),
395
+ };
396
+ await insertOpenSearchData( openSearch?.auditLog, logBooErr );
397
+ return res.sendError(
398
+ 'This client is already being processed in REID/Feature layer for the selected date. Please try again later.',
399
+ 400,
400
+ );
401
+ } else {
402
+ return next();
403
+ }
404
+ }
351
405
  if ( req?.report?.reportConfigs?.reportType !== 'manual' ) {
352
406
  const url = JSON.parse( process.env.URL );
353
407
  const openSearch = JSON.parse( process.env.OPENSEARCH );
354
408
  const REIDURL = url.REIDStatus;
355
409
  const FeatureURL = url.FeatureStatus;
410
+ const downTimeURL = url.ReportDowntimeCheck;
356
411
  const data = { 'client_id': inputData.clientId, 'store_date': inputData?.fileDate.split( '-' ).reverse().join( '-' ) };
357
-
412
+ const downTimeData = { 'clientId': inputData.clientId, 'date': inputData?.fileDate.split( '-' ).reverse().join( '-' ) };
358
413
  const isFeature = await callLambdaWithData( data, FeatureURL );
359
414
  const logInfo = {
360
415
  userName: req.user.userName,
@@ -391,7 +446,27 @@ export async function isFeatureRunning( req, res, next ) {
391
446
  createdAt: Date.now(),
392
447
  };
393
448
  await insertOpenSearchData( openSearch?.auditLog, logReid );
394
- if ( isFeature?.status_code !== '200' ||isREID?.status_code !== '200' ) {
449
+
450
+
451
+ const isDownTimeCheck = await callLambdaWithData( downTimeData, downTimeURL );
452
+ const logDownTimeCheck = {
453
+ userName: req.user.userName,
454
+ userId: req.user._id,
455
+ logType: 'reportLog',
456
+ logSubType: 'generateReportLog',
457
+ logData: {
458
+ fileDate: inputData?.fileDate.split( '-' ).reverse().join( '-' ),
459
+ reportName: req?.report?.reportConfigs?.reportName,
460
+ clientId: inputData?.clientId,
461
+ reportType: req?.report?.reportConfigs?.reportType,
462
+ message: 'get-down-time',
463
+ reidData: JSON.stringify( isREID ),
464
+ infoType: 'info',
465
+ },
466
+ createdAt: Date.now(),
467
+ };
468
+ await insertOpenSearchData( openSearch?.auditLog, logDownTimeCheck );
469
+ if ( isFeature?.status_code !== '200' ||isREID?.status_code !== '200' || isDownTimeCheck?.status_code !== '200' ) {
395
470
  const logErr = {
396
471
  userName: req.user.userName,
397
472
  userId: req.user._id,
@@ -402,10 +477,10 @@ export async function isFeatureRunning( req, res, next ) {
402
477
  reportName: req?.report?.reportConfigs?.reportName,
403
478
  clientId: inputData?.clientId,
404
479
  reportType: req?.report?.reportConfigs?.reportType,
405
- message: 'get-feature-reid-code-err',
406
-
480
+ message: isDownTimeCheck?.status_code !== '200'? 'get-down-time':'get-feature-reid-code-err',
407
481
  featureData: JSON.stringify( isFeature ),
408
482
  reidData: JSON.stringify( isREID ),
483
+ isDownTimeCheck: JSON.stringify( isDownTimeCheck ),
409
484
 
410
485
  infoType: 'error',
411
486
  },
@@ -416,7 +491,7 @@ export async function isFeatureRunning( req, res, next ) {
416
491
  'This client is already being processed in REID/Feature layer for the selected date. Please try again later.',
417
492
  400,
418
493
  );
419
- } else if ( isFeature?.data === false || isREID?.data === false ) {
494
+ } else if ( isFeature?.data === false || isREID?.data === false || isDownTimeCheck?.data === false ) {
420
495
  const logBooErr = {
421
496
  userName: req.user.userName,
422
497
  userId: req.user._id,
@@ -427,19 +502,19 @@ export async function isFeatureRunning( req, res, next ) {
427
502
  reportName: req?.report?.reportConfigs?.reportName,
428
503
  clientId: inputData?.clientId,
429
504
  reportType: req?.report?.reportConfigs?.reportType,
430
- message: 'get-feature-reid-boolean-err',
505
+ message: isDownTimeCheck?.data === false ? 'get-down-time' : 'get-feature-reid-boolean-err',
431
506
 
432
507
  featureData: JSON.stringify( isFeature ),
433
508
  reidData: JSON.stringify( isREID ),
434
-
509
+ isDownTimeCheck: JSON.stringify( isDownTimeCheck ),
435
510
  infoType: 'error',
436
511
  },
437
512
  createdAt: Date.now(),
438
513
  };
439
514
  await insertOpenSearchData( openSearch?.auditLog, logBooErr );
440
515
  return res.sendError(
441
- 'This client is already being processed in REID/Feature layer for the selected date. Please try again later.',
442
- 400,
516
+ isDownTimeCheck?.data === false? 'Downtime error, please looking the teams alert for further details':'This client is already being processed in REID/Feature layer for the selected date. Please try again later.',
517
+ 400,
443
518
  );
444
519
  } else {
445
520
  return next();