tango-app-api-audit 3.4.68-beta.21 → 3.4.68-beta.22

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/.eslintrc.cjs CHANGED
@@ -36,7 +36,7 @@ module.exports = {
36
36
  'no-unused-vars': 'error',
37
37
  'new-cap': [ 'error', { 'newIsCap': true, 'capIsNew': false } ],
38
38
  'prefer-const': 'off',
39
- // 'no-console': 'error',
39
+ 'no-console': 'error',
40
40
  },
41
41
  };
42
42
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-audit",
3
- "version": "3.4.68-beta.21",
3
+ "version": "3.4.68-beta.22",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -57,6 +57,8 @@ export async function getList( req, res ) {
57
57
  },
58
58
 
59
59
  } );
60
+ } else {
61
+ return res.sendError( 'No data found', 204 );
60
62
  }
61
63
  let search ={
62
64
  'must': filter,
@@ -213,7 +215,10 @@ export async function getList( req, res ) {
213
215
  const minutes1 =minutes> 1? `${minutes} mins` : `${minutes} min`;
214
216
  const seconds1 = seconds > 1? `${minutes} secs`: seconds == 1? `${minutes} sec` : '';
215
217
  const duration =`${minutes1} ${seconds1}`;
216
- const userName = await findOneUser( { _id: element?._source?.userId }, { _id: 0, userName: 1 } );
218
+ let userName = '';
219
+ if ( element?._source?.userId&&element?._source?.userId!='' ) {
220
+ userName = await findOneUser( { _id: element?._source?.userId }, { _id: 0, userName: 1 } );
221
+ }
217
222
  if ( element?._source?.type == 'physical' ) {
218
223
  exportData.push( {
219
224
  'Date': dayjs( element?._source?.date ).format( 'D MMM, YYYY' ),
@@ -254,7 +259,10 @@ export async function getList( req, res ) {
254
259
  return;
255
260
  } else {
256
261
  for ( const [ i, item ] of searchValue.entries() ) {
257
- const userName = await findOneUser( { _id: item?._source?.userId }, { _id: 0, userName: 1 } );
262
+ let userName='';
263
+ if ( item?._source?.userId&&item?._source?.userId!='' ) {
264
+ userName = await findOneUser( { _id: item?._source?.userId }, { _id: 0, userName: 1 } );
265
+ }
258
266
  const testDuration = searchValue[i]?._source?.testDuration;
259
267
  const minutes = Math.floor( testDuration / 60 );
260
268
  const seconds = testDuration % 60;
@@ -752,7 +760,9 @@ export async function cancel( req, res ) {
752
760
  logger.info( { getOutput: getOutput } );
753
761
  const output = getOutput?.body?.hits?.hits?.length > 0 ? getOutput?.body?.hits?.hits[0] : null;
754
762
  let checkReaudited = getOutput?.body?.hits?.hits?.length > 0 ? getOutputHistory?.body?.hits?.hits.filter( ( data ) => data._source.auditType==='Re-Audit'&&data._source.auditStatus==='Re-Audited' ).length:0;
763
+ let checkReauditedData = getOutput?.body?.hits?.hits?.length > 0 ? getOutputHistory?.body?.hits?.hits.filter( ( data ) => data._source.auditType==='Re-Audit'&&data._source.auditStatus==='Re-Audited' ):[];
755
764
  let checkaudited = getOutput?.body?.hits?.hits?.length > 0 ? getOutputHistory?.body?.hits?.hits.filter( ( data ) => data._source.auditType==='Audit'&&data._source.auditStatus==='Audited' ).length:0;
765
+ let checkauditedData = getOutput?.body?.hits?.hits?.length > 0 ? getOutputHistory?.body?.hits?.hits.filter( ( data ) => data._source.auditType==='Audit'&&data._source.auditStatus==='Audited' ):[];
756
766
 
757
767
  if ( !output ) {
758
768
  return res.sendError( 'No saved records found', 400 );
@@ -768,7 +778,7 @@ export async function cancel( req, res ) {
768
778
  auditStatus: checkReaudited>0?'Re-Audited':checkaudited>0?'Audited':'Yet-to-Audit',
769
779
  auditType: checkReaudited>0?'Re-Audit':'Audit',
770
780
  endTime: dayjs().tz( 'Asia/Kolkata' ),
771
-
781
+ userId: checkaudited>0?checkauditedData[0]?._source?.userId:checkReaudited>0?checkReauditedData[0]?._source?.userId:'',
772
782
  };
773
783
  await updateOpenSearchData( openSearch.EyeTestOutput, output?._id, { doc: record1 } );
774
784
  await updateOpenSearchData( openSearch.EyeTestInput, inputData.id, { doc: record2 } );