tango-app-api-audit 3.4.0-alpha.8 → 3.4.0

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.
@@ -1,9 +1,9 @@
1
1
  import { Router } from 'express';
2
2
  import { isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
3
- import { getDetectionFileValid, getFileValid, userAuditHistoryValid, workSpaceValid, saveValid, clientMetricsValid, storeMetricsValid, userMetricsValid, pendingSummaryTableValid, overAllAuditSummaryValid, summarySplitValid, overviewTableValid } from '../dtos/traxAudit.dtos.js';
3
+ import { getDetectionFileValid, getFileValid, userAuditHistoryValid, workSpaceValid, saveValid, clientMetricsValid, storeMetricsValid, userMetricsValid, pendingSummaryTableValid, overAllAuditSummaryValid, summarySplitValid, overviewTableValid, getUpdatedFileValid } from '../dtos/traxAudit.dtos.js';
4
4
  import { isExistsQueue } from '../validation/audit.validation.js';
5
- import { clientMetrics, getAuditFile, getDetectionAuditFile, overAllAuditSummary, overviewTable, pendingSummaryTable, saveBinary, storeMetrics, summarySplit, userAuditHistory, userMetrics, workSpace } from '../controllers/traxAudit.controllers.js';
6
- import { validateBinaryAudit } from '../validation/traxAuditValidation.js';
5
+ import { clientMetrics, getAuditFile, getDetectionAuditFile, getUpdatedFile, overAllAuditSummary, overviewTable, pendingSummaryTable, saveBinary, storeMetrics, summarySplit, userAuditHistory, userMetrics, workSpace } from '../controllers/traxAudit.controllers.js';
6
+ import { isTraxAuditDocumentExist, validateBinaryAudit } from '../validation/traxAuditValidation.js';
7
7
 
8
8
  export const traxAuditRouter = Router();
9
9
 
@@ -18,6 +18,7 @@ traxAuditRouter.post( '/work-space', isAllowedSessionHandler, validate( workSpac
18
18
 
19
19
  // Y/n
20
20
  traxAuditRouter.get( '/get-file', isAllowedSessionHandler, validate( getFileValid ), isExistsQueue, getAuditFile );
21
+ traxAuditRouter.post( '/get-updated-file', isAllowedSessionHandler, validate( getUpdatedFileValid ), isTraxAuditDocumentExist, getUpdatedFile );
21
22
  traxAuditRouter.post( '/save-binary-audit', isAllowedSessionHandler, validate( saveValid ), validateBinaryAudit, saveBinary );
22
23
 
23
24
  // metrcis
@@ -1,11 +1,14 @@
1
- import { findOneBinaryAudit } from '../service/binaryAudit.service.js';
1
+ import { logger } from 'tango-app-api-middleware';
2
+ import { findOneBinaryAudit, updateOneBinaryAuditModel } from '../service/binaryAudit.service.js';
2
3
  import { findOneUserEmpDetection } from '../service/userEmpDetection.service.js';
3
-
4
+ import { findOneTraxAuditData } from '../service/traxAuditData.service.js';
4
5
 
5
6
  export async function validateUserEmpDetection( req, res, next ) {
6
7
  try {
7
8
  const inputData = req.body;
8
- const userAuditDetails =await findOneUserEmpDetection( { _id: inputData.auditId } );
9
+ const userAuditDetails = await findOneUserEmpDetection( {
10
+ _id: inputData.auditId,
11
+ } );
9
12
  if ( !userAuditDetails ) {
10
13
  return res.sendError( 'No Data Available' );
11
14
  } else if ( userAuditDetails && userAuditDetails.auditStatus == 'skipped' ) {
@@ -15,7 +18,11 @@ export async function validateUserEmpDetection( req, res, next ) {
15
18
  next();
16
19
  } catch ( error ) {
17
20
  const err = error.message || 'Internal Server Error';
18
- logger.error( { error: error, message: req.query, function: 'validateUserEmpDetection' } );
21
+ logger.error( {
22
+ error: error,
23
+ message: req.query,
24
+ function: 'validateUserEmpDetection',
25
+ } );
19
26
  return res.sendError( err, 500 );
20
27
  }
21
28
  }
@@ -23,17 +30,89 @@ export async function validateUserEmpDetection( req, res, next ) {
23
30
  export async function validateBinaryAudit( req, res, next ) {
24
31
  try {
25
32
  const inputData = req.body;
26
- const userAuditDetails =await findOneBinaryAudit( { _id: inputData.auditId } );
33
+ const userAuditDetails = await findOneBinaryAudit( {
34
+ _id: inputData.auditId,
35
+ } );
27
36
  if ( !userAuditDetails ) {
28
37
  return res.sendError( 'No Data Available' );
29
- } else if ( userAuditDetails && userAuditDetails.auditStatus == 'completed' ) {
30
- await updateOneBinaryAuditModel( { _id: inputData.auditId }, { auditType: 'ReAudit' } );
38
+ } else if (
39
+ userAuditDetails &&
40
+ userAuditDetails.auditStatus == 'completed'
41
+ ) {
42
+ await updateOneBinaryAuditModel(
43
+ { _id: inputData.auditId },
44
+ { auditType: 'ReAudit' },
45
+ );
31
46
  }
32
47
  req.userAudit = userAuditDetails;
33
48
  next();
34
49
  } catch ( error ) {
35
50
  const err = error.message || 'Internal Server Error';
36
- logger.error( { error: error, message: req.query, function: 'validateBinaryAudit' } );
51
+ logger.error( {
52
+ error: error,
53
+ message: req.query,
54
+ function: 'validateBinaryAudit',
55
+ } );
56
+ return res.sendError( err, 500 );
57
+ }
58
+ }
59
+
60
+ export async function isTraxAuditDocumentExist( req, res, next ) {
61
+ try {
62
+ const inputData = req.body;
63
+ let query = {};
64
+ switch ( inputData.moduleType ) {
65
+ case 'unattended-customer':
66
+ query ={
67
+ storeId: inputData.storeId,
68
+ fileDate: inputData.fileDate,
69
+ tempId: inputData.tempId,
70
+ moduleType: inputData.moduleType,
71
+ };
72
+ break;
73
+ case 'left-in-middle':
74
+ query ={
75
+ storeId: inputData.storeId,
76
+ fileDate: inputData.fileDate,
77
+ question: inputData.question,
78
+ moduleType: inputData.moduleType,
79
+ };
80
+ break;
81
+ case 'uniform-detection':
82
+ query ={
83
+ storeId: inputData.storeId,
84
+ fileDate: inputData.fileDate,
85
+ moduleType: inputData.moduleType,
86
+ };
87
+ break;
88
+ case 'mobile-detection':
89
+ query ={
90
+ storeId: inputData.storeId,
91
+ fileDate: inputData.fileDate,
92
+ moduleType: inputData.moduleType,
93
+ };
94
+ break;
95
+ case 'camera-angle-change':
96
+ query ={
97
+ storeId: inputData.storeId,
98
+ fileDate: inputData.fileDate,
99
+ streamName: inputData.streamName,
100
+ moduleType: inputData.moduleType,
101
+ };
102
+ break;
103
+ default:
104
+ return res.sendError( 'Please give valid modueType', 400 );
105
+ }
106
+ const auditInfo = await findOneTraxAuditData( query );
107
+ if ( auditInfo ) {
108
+ req.TraxData = auditInfo;
109
+ return next();
110
+ } else {
111
+ return res.sendError( 'No Inserted Record', 400 );
112
+ }
113
+ } catch ( error ) {
114
+ const err = error.message || 'Internal Server Error';
115
+ logger.error( { error: error, message: req.body, function: 'isTraxAuditDocumentExist' } );
37
116
  return res.sendError( err, 500 );
38
117
  }
39
118
  }