tango-app-api-audit 3.4.3-alpha.14 → 3.4.3-alpha.15
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.4.3-alpha.
|
|
3
|
+
"version": "3.4.3-alpha.15",
|
|
4
4
|
"description": "audit & audit metrics apis",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"mongodb": "^6.7.0",
|
|
25
25
|
"nodemon": "^3.1.3",
|
|
26
26
|
"swagger-ui-express": "^5.0.1",
|
|
27
|
-
"tango-api-schema": "^2.1.
|
|
27
|
+
"tango-api-schema": "^2.1.28",
|
|
28
28
|
"tango-app-api-middleware": "^3.1.33",
|
|
29
29
|
"winston": "^3.13.0",
|
|
30
30
|
"winston-daily-rotate-file": "^5.0.0"
|
|
@@ -2,7 +2,7 @@ import { checkFileExist, chunkArray, download, getDate, getDateWithCustomizeTime
|
|
|
2
2
|
import { aggregateBinaryAudit, createBinaryAudit, updateOneBinaryAuditModel } from '../service/binaryAudit.service.js';
|
|
3
3
|
import { countDocumentsStore, findOneStore } from '../service/store.service.js';
|
|
4
4
|
import { findOneUser } from '../service/user.service.js';
|
|
5
|
-
import { aggregateUserEmpDetection, createUserEmpDetection, updateOneUserEmpDetection } from '../service/userEmpDetection.service.js';
|
|
5
|
+
import { aggregateUserEmpDetection, countDocumentsUserEmpDetection, createUserEmpDetection, updateOneUserEmpDetection } from '../service/userEmpDetection.service.js';
|
|
6
6
|
import { aggregateTraxAuditData, findOneTraxAuditData } from '../service/traxAuditData.service.js';
|
|
7
7
|
import { aggregateClient, findOneClient } from '../service/client.service.js';
|
|
8
8
|
import dayjs from 'dayjs';
|
|
@@ -4233,13 +4233,29 @@ export async function getDraftedData( req, res ) {
|
|
|
4233
4233
|
export async function save( req, res ) {
|
|
4234
4234
|
try {
|
|
4235
4235
|
const inputData = req.body;
|
|
4236
|
+
const isoDate = req.userAudit?.startTime;
|
|
4237
|
+
const currentTime = dayjs();
|
|
4238
|
+
const isoDateTime = dayjs( isoDate );
|
|
4239
|
+
const timeDifferenceInMinutes = currentTime.diff( isoDateTime, 'seconds' );
|
|
4236
4240
|
const getUserAuditData = await findOneUserEmpDetection( { _id: inputData.auditId } );
|
|
4237
4241
|
inputData.clientId = getUserAuditData.clientId;
|
|
4238
4242
|
const query ={ storeId: inputData.storeId, moduleType: inputData.moduleType, fileDate: inputData.fileDate };
|
|
4239
4243
|
const data = await updateOneEmpDetectionOutput( query, { $set: inputData }, { upsert: true } );
|
|
4240
4244
|
if ( data ) {
|
|
4241
|
-
|
|
4242
|
-
|
|
4245
|
+
const userUpdated ={
|
|
4246
|
+
auditStatus: 'completed',
|
|
4247
|
+
afterCount: inputData.employeeCount,
|
|
4248
|
+
endTime: Date.now(),
|
|
4249
|
+
isDraft: false,
|
|
4250
|
+
timeSpent: timeDifferenceInMinutes,
|
|
4251
|
+
};
|
|
4252
|
+
const storeUpdated ={
|
|
4253
|
+
status: 'completed',
|
|
4254
|
+
afterCount: inputData.employeeCount,
|
|
4255
|
+
timeSpent: timeDifferenceInMinutes,
|
|
4256
|
+
};
|
|
4257
|
+
await updateOneUserEmpDetection( { _id: inputData.auditId }, userUpdated );
|
|
4258
|
+
await updateOneStoreEmpDetection( query, storeUpdated );
|
|
4243
4259
|
return res.sendSuccess( { result: 'Updated Successfully' } );
|
|
4244
4260
|
} else {
|
|
4245
4261
|
return res.sendError( 'something went wrong', 403 );
|
|
@@ -4266,6 +4282,9 @@ export async function reTrigger( req, res ) {
|
|
|
4266
4282
|
if ( !getQueueName || queueName == '' ) {
|
|
4267
4283
|
return res.sendError( 'queueName does not create', 400 );
|
|
4268
4284
|
}
|
|
4285
|
+
const getRecord = await countDocumentsUserEmpDetection( { storeId: message.storeId,
|
|
4286
|
+
fileDate: message.fileDate,
|
|
4287
|
+
moduleType: message.moduleType, auditStatus: 'completed' } );
|
|
4269
4288
|
const msg = {
|
|
4270
4289
|
storeId: message.storeId,
|
|
4271
4290
|
fileDate: message.fileDate,
|
|
@@ -4275,6 +4294,7 @@ export async function reTrigger( req, res ) {
|
|
|
4275
4294
|
question: message.question,
|
|
4276
4295
|
folderPath: message.folderPath,
|
|
4277
4296
|
fileCount: message.fileCount,
|
|
4297
|
+
auditType: getRecord > 0? 'ReAudit':'Audit',
|
|
4278
4298
|
};
|
|
4279
4299
|
const sqsProduceQueue = {
|
|
4280
4300
|
QueueUrl: `${sqs.url}${queueName}`,
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import userEmpDetectionModel from 'tango-api-schema/schema/userEmpDetection.model.js';
|
|
2
|
-
import { logger } from 'tango-app-api-middleware';
|
|
3
2
|
|
|
4
3
|
|
|
5
4
|
export function aggregateUserEmpDetection( query ) {
|
|
6
|
-
logger.info( { seelevt: 'yryruteretwyyyyyyyyyyyyyyyyyyyyyyyyyyyyewe' } );
|
|
7
5
|
return userEmpDetectionModel.aggregate( query, { collation: { locale: 'en', strength: 2 } } );
|
|
8
6
|
}
|
|
9
7
|
|
|
@@ -15,6 +13,10 @@ export function findOneUserEmpDetection( query, fields ) {
|
|
|
15
13
|
return userEmpDetectionModel.findOne( query, fields );
|
|
16
14
|
}
|
|
17
15
|
|
|
16
|
+
export function countDocumentsUserEmpDetection( query, fields ) {
|
|
17
|
+
return userEmpDetectionModel.countDocuments( query, fields );
|
|
18
|
+
}
|
|
19
|
+
|
|
18
20
|
export function updateOneUserEmpDetection( query, record ) {
|
|
19
21
|
return userEmpDetectionModel.updateOne( query, { $set: record } );
|
|
20
22
|
}
|