tango-app-api-audit 3.5.32 → 3.5.34

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-audit",
3
- "version": "3.5.32",
3
+ "version": "3.5.34",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -26,7 +26,7 @@
26
26
  "mongodb": "^6.7.0",
27
27
  "nodemon": "^3.1.3",
28
28
  "swagger-ui-express": "^5.0.1",
29
- "tango-api-schema": "^2.3.21",
29
+ "tango-api-schema": "^2.3.28",
30
30
  "tango-app-api-middleware": "^3.4.4",
31
31
  "winston": "^3.13.0",
32
32
  "winston-daily-rotate-file": "^5.0.0"
@@ -759,82 +759,107 @@ export async function save( req, res ) {
759
759
  await updateOpenSearchData( openSearch.EyeTestOutput, output?._id, { doc: record } );
760
760
  await updateOpenSearchData( openSearch.EyeTestInput, inputData.id, { doc: inputrecord } );
761
761
 
762
- const getOne = await getOpenSearchData( openSearch.EyeTestInput, inputData.id );
763
- const inputUpdatedData = getOne?.body?.hits?.hits;
764
- const getEyetestConfig = await findOneEyeTestConfig( { clientId: req?.user.userType == 'tango'? inputData?.clientId : req.user.clientId, configureType: 'email' }, { condition: '$complianceThreshold.condition', value: '$complianceThreshold.value' } );
765
- if ( getEyetestConfig && inputData.auditStatus == 'Audited' && inputUpdatedData?.lenght > 0 ) {
762
+ const getOne = await getOpenSearchById( openSearch.EyeTestInput, inputData.id );
763
+ const inputUpdatedData = getOne?.body;
764
+
765
+ const getEyetestConfig = await findOneEyeTestConfig( { clientId: req?.user.userType == 'tango'? inputData?.clientId : req.user.clientId, configureType: 'email' }, { complianceThreshold: 1 } );
766
+
767
+ if ( getEyetestConfig && inputData.auditStatus == 'Audited' && inputUpdatedData ) {
766
768
  const trustScore = Math.round( 100-( ( inputData?.overRides / inputData?.steps?.length ) * 100 ) );
767
- const value = Number( getEyetestConfig?.value?.split( '%' )[0] );
768
- const condition = getEyetestConfig.condition;
769
- const id= `${inputData?.RMEmail}_${inputData?.cluster}_${inputUpdatedData?.[0]?._source?.optumId}_${inputData?.fileId}`;
769
+ const value = Number( getEyetestConfig?.complianceThreshold?.value?.split( '%' )[0] );
770
+ const condition = getEyetestConfig?.complianceThreshold?.condition;
771
+ const id= `${inputData?.RMEmail}_${inputData?.cluster}_${inputUpdatedData?._source?.optumId}_${inputData?.fileId}`;
770
772
  switch ( condition ) {
771
773
  case '>': if ( trustScore > value ) {
772
774
  const record1 = {
773
775
  RMEmail: inputData.RMEmail,
774
776
  cluster: inputData.cluster,
775
- optumId: inputUpdatedData?.[0]?._source?.optumId,
776
- storeName: inputUpdatedData?.[0]?._source?.storeName,
777
- complianceScore: inputUpdatedData?.[0]?._source?.complianceScore,
778
- trustScore: inputUpdatedData?.[0]?._source?.trustScore,
777
+ optumId: inputUpdatedData?._source?.optumId,
778
+ storeName: inputUpdatedData?._source?.storeName,
779
+ complianceScore: inputUpdatedData?._source?.complianceScore,
780
+ trustScore: inputUpdatedData?._source?.trustScore,
781
+ createdAt: new Date(),
782
+ updatedAt: new Date(),
783
+
779
784
  };
780
785
  await insertWithId( openSearch.eyeTestEmailAlert, id, record1 );
781
786
  }
787
+ break;
782
788
  case '<': if ( trustScore < value ) {
783
789
  const record2 = {
784
790
  RMEmail: inputData.RMEmail,
785
791
  cluster: inputData.cluster,
786
- optumId: inputUpdatedData?.[0]?._source?.optumId,
787
- storeName: inputUpdatedData?.[0]?._source?.storeName,
788
- complianceScore: inputUpdatedData?.[0]?._source?.complianceScore,
789
- trustScore: inputUpdatedData?.[0]?._source?.trustScore,
792
+ optumId: inputUpdatedData?._source?.optumId,
793
+ storeName: inputUpdatedData?._source?.storeName,
794
+ complianceScore: inputUpdatedData?._source?.complianceScore,
795
+ trustScore: inputUpdatedData?._source?.trustScore,
796
+ createdAt: new Date(),
797
+ updatedAt: new Date(),
798
+
790
799
  };
791
800
  await insertWithId( openSearch.eyeTestEmailAlert, id, record2 );
792
801
  };
802
+ break;
793
803
  case '>=': if ( trustScore >= value ) {
794
804
  const record3 = {
795
805
  RMEmail: inputData.RMEmail,
796
806
  cluster: inputData.cluster,
797
- optumId: inputUpdatedData?.[0]?._source?.optumId,
798
- storeName: inputUpdatedData?.[0]?._source?.storeName,
799
- complianceScore: inputUpdatedData?.[0]?._source?.complianceScore,
800
- trustScore: inputUpdatedData?.[0]?._source?.trustScore,
807
+ optumId: inputUpdatedData?._source?.optumId,
808
+ storeName: inputUpdatedData?._source?.storeName,
809
+ complianceScore: inputUpdatedData?._source?.complianceScore,
810
+ trustScore: inputUpdatedData?._source?.trustScore,
811
+ createdAt: new Date(),
812
+ updatedAt: new Date(),
813
+
801
814
  };
802
815
  await insertWithId( openSearch.eyeTestEmailAlert, id, record3 );
803
816
  }
817
+ break;
804
818
  case '<=': if ( trustScore <= value ) {
805
819
  const record4 = {
806
820
  RMEmail: inputData.RMEmail,
807
821
  cluster: inputData.cluster,
808
- optumId: inputUpdatedData?.[0]?._source?.optumId,
809
- storeName: inputUpdatedData?.[0]?._source?.storeName,
810
- complianceScore: inputUpdatedData?.[0]?._source?.complianceScore,
811
- trustScore: inputUpdatedData?.[0]?._source?.trustScore,
822
+ optumId: inputUpdatedData?._source?.optumId,
823
+ storeName: inputUpdatedData?._source?.storeName,
824
+ complianceScore: inputUpdatedData?._source?.complianceScore,
825
+ trustScore: inputUpdatedData?._source?.trustScore,
826
+ createdAt: new Date(),
827
+ updatedAt: new Date(),
828
+
812
829
  };
813
830
  await insertWithId( openSearch.eyeTestEmailAlert, id, record4 );
814
831
  }
832
+ break;
815
833
  case '=':
816
834
  case '==': if ( trustScore == value ) {
817
835
  const record5 = {
818
836
  RMEmail: inputData.RMEmail,
819
837
  cluster: inputData.cluster,
820
- optumId: inputUpdatedData?.[0]?._source?.optumId,
821
- storeName: inputUpdatedData?.[0]?._source?.storeName,
822
- complianceScore: inputUpdatedData?.[0]?._source?.complianceScore,
823
- trustScore: inputUpdatedData?.[0]?._source?.trustScore,
838
+ optumId: inputUpdatedData?._source?.optumId,
839
+ storeName: inputUpdatedData?._source?.storeName,
840
+ complianceScore: inputUpdatedData?._source?.complianceScore,
841
+ trustScore: inputUpdatedData?._source?.trustScore,
842
+ createdAt: new Date(),
843
+ updatedAt: new Date(),
844
+
824
845
  };
825
846
  await insertWithId( openSearch.eyeTestEmailAlert, id, record5 );
826
847
  }
848
+ break;
827
849
  case '===': if ( trustScore === value ) {
828
850
  const record6 = {
829
851
  RMEmail: inputData.RMEmail,
830
852
  cluster: inputData.cluster,
831
- optumId: inputUpdatedData?.[0]?._source?.optumId,
832
- storeName: inputUpdatedData?.[0]?._source?.storeName,
833
- complianceScore: inputUpdatedData?.[0]?._source?.complianceScore,
834
- trustScore: inputUpdatedData?.[0]?._source?.trustScore,
853
+ optumId: inputUpdatedData?._source?.optumId,
854
+ storeName: inputUpdatedData?._source?.storeName,
855
+ complianceScore: inputUpdatedData?._source?.complianceScore,
856
+ trustScore: inputUpdatedData?._source?.trustScore,
857
+ createdAt: new Date(),
858
+ updatedAt: new Date(),
835
859
  };
836
860
  await insertWithId( openSearch.eyeTestEmailAlert, id, record6 );
837
861
  }
862
+ break;
838
863
  default: throw new Error( `Unknown condition: ${condition}` );
839
864
  }
840
865
  }