tango-app-api-audit 1.0.12 → 1.0.13
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": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "audit & audit metrics apis",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"mongodb": "^6.7.0",
|
|
24
24
|
"nodemon": "^3.1.3",
|
|
25
25
|
"swagger-ui-express": "^5.0.1",
|
|
26
|
-
"tango-api-schema": "^2.0.
|
|
26
|
+
"tango-api-schema": "^2.0.122",
|
|
27
27
|
"tango-app-api-middleware": "^3.1.24",
|
|
28
28
|
"winston": "^3.13.0",
|
|
29
29
|
"winston-daily-rotate-file": "^5.0.0"
|
|
@@ -10,6 +10,7 @@ import { aggregateStoreAudit, createStoreAudit, updateOneStoreAudit } from '../s
|
|
|
10
10
|
import { aggregateAuditClientData } from '../service/auditClientData.service.js';
|
|
11
11
|
import _ from 'lodash';
|
|
12
12
|
import { createAuditLog, findOneAuditLog } from '../service/auditLog.service.js';
|
|
13
|
+
import { findOneStore } from '../service/store.service.js';
|
|
13
14
|
|
|
14
15
|
export async function getAuditFile( req, res ) {
|
|
15
16
|
try {
|
|
@@ -94,7 +95,7 @@ export async function getAuditFile( req, res ) {
|
|
|
94
95
|
storeId: userDetails[0].storeId,
|
|
95
96
|
totalCount: userDetails[0].beforeCount,
|
|
96
97
|
}, {}, { createdAt: -1 } );
|
|
97
|
-
if ( log
|
|
98
|
+
if ( !log ) {
|
|
98
99
|
await updateOneUserAudit( { _id: userDetails[0]._id }, { $set: { isDraft: false, auditStatus: 'skipped' } } );
|
|
99
100
|
logger.info( 'audit update in drafted', { _id: userDetails[0]._id, isDraft: false, auditStatus: 'skipped' } );
|
|
100
101
|
return res.sendError( 'User saved data has been deleted', 204 );
|
|
@@ -104,25 +105,25 @@ export async function getAuditFile( req, res ) {
|
|
|
104
105
|
store_id: userDetails[0].storeId,
|
|
105
106
|
file_date: userDetails[0].fileDate,
|
|
106
107
|
type: userDetails[0].auditType,
|
|
107
|
-
queueName: log
|
|
108
|
-
userId: log
|
|
108
|
+
queueName: log.queueName,
|
|
109
|
+
userId: log.userId,
|
|
109
110
|
};
|
|
110
111
|
const result = {
|
|
111
|
-
junk: log
|
|
112
|
-
junk_count: log
|
|
113
|
-
employee: log
|
|
114
|
-
employee_count: log
|
|
115
|
-
customer: log
|
|
116
|
-
customer_count: log
|
|
117
|
-
retag_image: log
|
|
118
|
-
retag_count: log
|
|
119
|
-
total_count: log
|
|
112
|
+
junk: log.junk,
|
|
113
|
+
junk_count: log.junkCount,
|
|
114
|
+
employee: log.employee,
|
|
115
|
+
employee_count: log.employeeCount,
|
|
116
|
+
customer: log.customer,
|
|
117
|
+
customer_count: log.customerCount,
|
|
118
|
+
retag_image: log.retagImage,
|
|
119
|
+
retag_count: log.retagCount,
|
|
120
|
+
total_count: log.totalCount,
|
|
120
121
|
};
|
|
121
122
|
|
|
122
|
-
const userdata = await findOneUser( { _id: log
|
|
123
|
+
const userdata = await findOneUser( { _id: log.userId } );
|
|
123
124
|
if ( !inputData.nextId || inputData.nextId === '' || inputData.nextId == null ) {
|
|
124
125
|
const logData = {
|
|
125
|
-
userId: log
|
|
126
|
+
userId: log.userId,
|
|
126
127
|
userName: userdata.name,
|
|
127
128
|
logType: 'audit',
|
|
128
129
|
logSubType: 'auditStart',
|
|
@@ -130,17 +131,28 @@ export async function getAuditFile( req, res ) {
|
|
|
130
131
|
file_date: userDetails[0].fileDate,
|
|
131
132
|
auditType: userDetails[0].auditType,
|
|
132
133
|
storeId: userDetails[0].storeId,
|
|
133
|
-
clientName: log
|
|
134
|
+
clientName: log.queueName,
|
|
134
135
|
auditId: userDetails[0]._id,
|
|
135
136
|
},
|
|
136
137
|
};
|
|
137
138
|
logger.info( { logData: logData } );
|
|
138
139
|
await insertOpenSearchData( openSearch.activityLog, logData );
|
|
139
|
-
// await savelogs( logData ); Note : insert to os
|
|
140
140
|
}
|
|
141
|
+
const storeQuery = {
|
|
142
|
+
storeId: userDetails[0].storeId,
|
|
143
|
+
};
|
|
144
|
+
const storeFields = {
|
|
145
|
+
storeId: 1,
|
|
146
|
+
storeName: 1,
|
|
147
|
+
address: '$storeProfile.address',
|
|
148
|
+
};
|
|
149
|
+
const storeDetails = await findOneStore( storeQuery, storeFields );
|
|
141
150
|
return res.sendSuccess( {
|
|
142
151
|
result: result,
|
|
143
|
-
|
|
152
|
+
storeId: storeDetails?.storeId,
|
|
153
|
+
storeName: storeDetails?.storeName,
|
|
154
|
+
address: storeDetails?.address || '',
|
|
155
|
+
count: log.totalCount,
|
|
144
156
|
file: file,
|
|
145
157
|
isDraft: userDetails[0].isDraft,
|
|
146
158
|
} );
|
|
@@ -221,14 +233,25 @@ export async function getAuditFile( req, res ) {
|
|
|
221
233
|
auditId: reauditInsert._id,
|
|
222
234
|
},
|
|
223
235
|
};
|
|
224
|
-
|
|
225
|
-
// await savelogs( logData ); need to change
|
|
236
|
+
await insertOpenSearchData( openSearch.activityLog, logData );
|
|
226
237
|
}
|
|
227
238
|
|
|
239
|
+
const storeQuery = {
|
|
240
|
+
storeId: msg.store_id,
|
|
241
|
+
};
|
|
242
|
+
const storeFields = {
|
|
243
|
+
storeId: 1,
|
|
244
|
+
storeName: 1,
|
|
245
|
+
address: '$storeProfile.address',
|
|
246
|
+
};
|
|
247
|
+
const storeInfo = await findOneStore( storeQuery, storeFields );
|
|
228
248
|
return res.sendSuccess(
|
|
229
249
|
{
|
|
230
250
|
result: reauditImg,
|
|
231
251
|
count: reauditImg.length,
|
|
252
|
+
storeId: storeInfo?.storeId,
|
|
253
|
+
storeName: storeInfo?.storeName,
|
|
254
|
+
address: storeInfo?.address || '',
|
|
232
255
|
file: {
|
|
233
256
|
store_id: msg.store_id,
|
|
234
257
|
file_date: msg.curr_date,
|
|
@@ -323,6 +346,14 @@ export async function getAuditFile( req, res ) {
|
|
|
323
346
|
return res.sendError( 'Bucket is Empty', 204 );
|
|
324
347
|
}
|
|
325
348
|
const userdata = await findOneUser( { _id: insertData.userId } );
|
|
349
|
+
const storeQuery = {
|
|
350
|
+
storeId: storeId,
|
|
351
|
+
};
|
|
352
|
+
const storeFields = {
|
|
353
|
+
storeName: 1,
|
|
354
|
+
address: '$storeProfile.address',
|
|
355
|
+
};
|
|
356
|
+
const storeInfo = await findOneStore( storeQuery, storeFields );
|
|
326
357
|
if ( inputData.nextId ) {
|
|
327
358
|
const logData = {
|
|
328
359
|
userId: insertData.userId,
|
|
@@ -337,13 +368,15 @@ export async function getAuditFile( req, res ) {
|
|
|
337
368
|
auditId: insertData._id,
|
|
338
369
|
},
|
|
339
370
|
};
|
|
340
|
-
|
|
341
|
-
// await savelogs( logData );
|
|
371
|
+
await insertOpenSearchData( openSearch.activityLog, logData );
|
|
342
372
|
}
|
|
343
|
-
|
|
373
|
+
logger.info( { storeInfo: storeInfo } );
|
|
344
374
|
return res.sendSuccess( {
|
|
345
375
|
result: files,
|
|
346
376
|
count: msg.total_count,
|
|
377
|
+
storeId: storeId,
|
|
378
|
+
storeName: storeInfo?.storeName,
|
|
379
|
+
address: storeInfo?.address,
|
|
347
380
|
file: {
|
|
348
381
|
queueName: inputData.queueName,
|
|
349
382
|
store_id: storeId,
|