tango-app-api-audit 3.4.39 → 3.4.40
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/README.md +28 -28
- package/package.json +40 -40
- package/src/controllers/audit.controllers.js +1 -9
- package/src/controllers/traxAudit.controllers.js +216 -14
package/README.md
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
# README #
|
|
2
|
-
|
|
3
|
-
This README would normally document whatever steps are necessary to get your application up and running.
|
|
4
|
-
|
|
5
|
-
### What is this repository for? ###
|
|
6
|
-
|
|
7
|
-
* Quick summary
|
|
8
|
-
* Version
|
|
9
|
-
* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
|
|
10
|
-
|
|
11
|
-
### How do I get set up? ###
|
|
12
|
-
|
|
13
|
-
* Summary of set up
|
|
14
|
-
* Configuration
|
|
15
|
-
* Dependencies
|
|
16
|
-
* Database configuration
|
|
17
|
-
* How to run tests
|
|
18
|
-
* Deployment instructions
|
|
19
|
-
|
|
20
|
-
### Contribution guidelines ###
|
|
21
|
-
|
|
22
|
-
* Writing tests
|
|
23
|
-
* Code review
|
|
24
|
-
* Other guidelines
|
|
25
|
-
|
|
26
|
-
### Who do I talk to? ###
|
|
27
|
-
|
|
28
|
-
* Repo owner or admin
|
|
1
|
+
# README #
|
|
2
|
+
|
|
3
|
+
This README would normally document whatever steps are necessary to get your application up and running.
|
|
4
|
+
|
|
5
|
+
### What is this repository for? ###
|
|
6
|
+
|
|
7
|
+
* Quick summary
|
|
8
|
+
* Version
|
|
9
|
+
* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
|
|
10
|
+
|
|
11
|
+
### How do I get set up? ###
|
|
12
|
+
|
|
13
|
+
* Summary of set up
|
|
14
|
+
* Configuration
|
|
15
|
+
* Dependencies
|
|
16
|
+
* Database configuration
|
|
17
|
+
* How to run tests
|
|
18
|
+
* Deployment instructions
|
|
19
|
+
|
|
20
|
+
### Contribution guidelines ###
|
|
21
|
+
|
|
22
|
+
* Writing tests
|
|
23
|
+
* Code review
|
|
24
|
+
* Other guidelines
|
|
25
|
+
|
|
26
|
+
### Who do I talk to? ###
|
|
27
|
+
|
|
28
|
+
* Repo owner or admin
|
|
29
29
|
* Other community or team contact
|
package/package.json
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "tango-app-api-audit",
|
|
3
|
-
"version": "3.4.
|
|
4
|
-
"description": "audit & audit metrics apis",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"start": "nodemon --exec \"eslint --fix . && node index.js\""
|
|
9
|
-
},
|
|
10
|
-
"engines": {
|
|
11
|
-
"node": ">=18.10.0"
|
|
12
|
-
},
|
|
13
|
-
"author": "praveenraj",
|
|
14
|
-
"license": "ISC",
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"adm-zip": "^0.5.15",
|
|
17
|
-
"aws-sdk": "^2.1643.0",
|
|
18
|
-
"dayjs": "^1.11.11",
|
|
19
|
-
"dotenv": "^16.4.5",
|
|
20
|
-
"express": "^4.19.2",
|
|
21
|
-
"handlebars": "^4.7.8",
|
|
22
|
-
"joi-to-swagger": "^6.2.0",
|
|
23
|
-
"lodash": "^4.17.21",
|
|
24
|
-
"mongodb": "^6.7.0",
|
|
25
|
-
"nodemon": "^3.1.3",
|
|
26
|
-
"swagger-ui-express": "^5.0.1",
|
|
27
|
-
"tango-api-schema": "^2.2.19",
|
|
28
|
-
"tango-app-api-middleware": "^3.1.48",
|
|
29
|
-
"winston": "^3.13.0",
|
|
30
|
-
"winston-daily-rotate-file": "^5.0.0"
|
|
31
|
-
},
|
|
32
|
-
"devDependencies": {
|
|
33
|
-
"eslint": "^8.57.0",
|
|
34
|
-
"eslint-config-google": "^0.14.0",
|
|
35
|
-
"eslint-config-semistandard": "^17.0.0",
|
|
36
|
-
"eslint-config-standard": "^17.1.0",
|
|
37
|
-
"eslint-plugin-import": "^2.29.1",
|
|
38
|
-
"eslint-plugin-promise": "^6.2.0"
|
|
39
|
-
}
|
|
40
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "tango-app-api-audit",
|
|
3
|
+
"version": "3.4.40",
|
|
4
|
+
"description": "audit & audit metrics apis",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start": "nodemon --exec \"eslint --fix . && node index.js\""
|
|
9
|
+
},
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=18.10.0"
|
|
12
|
+
},
|
|
13
|
+
"author": "praveenraj",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"adm-zip": "^0.5.15",
|
|
17
|
+
"aws-sdk": "^2.1643.0",
|
|
18
|
+
"dayjs": "^1.11.11",
|
|
19
|
+
"dotenv": "^16.4.5",
|
|
20
|
+
"express": "^4.19.2",
|
|
21
|
+
"handlebars": "^4.7.8",
|
|
22
|
+
"joi-to-swagger": "^6.2.0",
|
|
23
|
+
"lodash": "^4.17.21",
|
|
24
|
+
"mongodb": "^6.7.0",
|
|
25
|
+
"nodemon": "^3.1.3",
|
|
26
|
+
"swagger-ui-express": "^5.0.1",
|
|
27
|
+
"tango-api-schema": "^2.2.19",
|
|
28
|
+
"tango-app-api-middleware": "^3.1.48",
|
|
29
|
+
"winston": "^3.13.0",
|
|
30
|
+
"winston-daily-rotate-file": "^5.0.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"eslint": "^8.57.0",
|
|
34
|
+
"eslint-config-google": "^0.14.0",
|
|
35
|
+
"eslint-config-semistandard": "^17.0.0",
|
|
36
|
+
"eslint-config-standard": "^17.1.0",
|
|
37
|
+
"eslint-plugin-import": "^2.29.1",
|
|
38
|
+
"eslint-plugin-promise": "^6.2.0"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -841,7 +841,6 @@ export async function workSpace( req, res ) {
|
|
|
841
841
|
clientId: { $last: '$clientId' },
|
|
842
842
|
clientName: { $last: '$clientName' },
|
|
843
843
|
installedStore: { $last: '$installedStore' },
|
|
844
|
-
// queueName: { $last: '$queueName' },
|
|
845
844
|
totalCount: { $sum: 1 },
|
|
846
845
|
},
|
|
847
846
|
},
|
|
@@ -976,7 +975,6 @@ export async function workSpace( req, res ) {
|
|
|
976
975
|
{
|
|
977
976
|
$match: {
|
|
978
977
|
$and: [
|
|
979
|
-
// { clientId: { $in: clientList } },
|
|
980
978
|
{ userId: { $eq: req.user._id } },
|
|
981
979
|
{ auditStatus: { $in: [ 'inprogress', 'drafted' ] } },
|
|
982
980
|
{ moduleType: { $eq: inputData.moduleType } },
|
|
@@ -1103,7 +1101,7 @@ export async function workSpace( req, res ) {
|
|
|
1103
1101
|
queueName: merge[i].queueName,
|
|
1104
1102
|
isDraft: merge[i]?.isDrafted || false,
|
|
1105
1103
|
isEnable:
|
|
1106
|
-
userDraftedCount.length > 0 && !merge[i].isDrafted && ( !merge[i]
|
|
1104
|
+
userDraftedCount.length > 0 &&( !merge[i].isDrafted && ( !merge[i].userInprogressCount || merge[i]?.userInprogressCount==0 ) )? 0:
|
|
1107
1105
|
Number( pending ) > 0 ||
|
|
1108
1106
|
merge[i].isDrafted ||
|
|
1109
1107
|
( merge[i].userAsignedCount && merge[i].userAsignedCount > 0 ) ||
|
|
@@ -1192,13 +1190,7 @@ export async function saveDraft( req, res ) {
|
|
|
1192
1190
|
};
|
|
1193
1191
|
|
|
1194
1192
|
if ( getUserAuditData?.startTime ) {
|
|
1195
|
-
// const isoDate = getUserAuditData.startTime;
|
|
1196
|
-
// const currentTime = dayjs();
|
|
1197
|
-
// const isoDateTime = dayjs( isoDate );
|
|
1198
|
-
// const timeDifferenceInMinutes = currentTime.diff( isoDateTime, 'seconds' );
|
|
1199
|
-
|
|
1200
1193
|
userRecord.timeSpent = inputData.timeSpent;
|
|
1201
|
-
|
|
1202
1194
|
storeRecord.timeSpent =inputData.timeSpent;
|
|
1203
1195
|
}
|
|
1204
1196
|
|
|
@@ -1278,6 +1278,43 @@ export async function userAuditHistory( req, res ) {
|
|
|
1278
1278
|
path: '$client', preserveNullAndEmptyArrays: true,
|
|
1279
1279
|
},
|
|
1280
1280
|
},
|
|
1281
|
+
{
|
|
1282
|
+
$lookup: {
|
|
1283
|
+
from: 'traxAuditData',
|
|
1284
|
+
let: {
|
|
1285
|
+
fileDate: '$fileDate', storeId: '$storeId', zoneName: '$zoneName',
|
|
1286
|
+
},
|
|
1287
|
+
pipeline: [
|
|
1288
|
+
{
|
|
1289
|
+
$match: {
|
|
1290
|
+
$expr: {
|
|
1291
|
+
$and: [
|
|
1292
|
+
{
|
|
1293
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
1294
|
+
},
|
|
1295
|
+
{
|
|
1296
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
1297
|
+
},
|
|
1298
|
+
{
|
|
1299
|
+
$eq: [ '$zoneName', '$$zoneName' ],
|
|
1300
|
+
},
|
|
1301
|
+
],
|
|
1302
|
+
},
|
|
1303
|
+
},
|
|
1304
|
+
},
|
|
1305
|
+
{
|
|
1306
|
+
$project: {
|
|
1307
|
+
message: '$sqs.Body',
|
|
1308
|
+
},
|
|
1309
|
+
},
|
|
1310
|
+
], as: 'sqs',
|
|
1311
|
+
},
|
|
1312
|
+
},
|
|
1313
|
+
{
|
|
1314
|
+
$unwind: {
|
|
1315
|
+
path: '$sqs', preserveNullAndEmptyArrays: true,
|
|
1316
|
+
},
|
|
1317
|
+
},
|
|
1281
1318
|
{
|
|
1282
1319
|
$project: {
|
|
1283
1320
|
storeId: 1,
|
|
@@ -1289,6 +1326,7 @@ export async function userAuditHistory( req, res ) {
|
|
|
1289
1326
|
questionType: 1,
|
|
1290
1327
|
answer: 1,
|
|
1291
1328
|
userComments: 1,
|
|
1329
|
+
question: '$sqs.message.question',
|
|
1292
1330
|
storeName: '$store.storeName',
|
|
1293
1331
|
clientId: 1,
|
|
1294
1332
|
clientName: '$client.clientName',
|
|
@@ -1370,6 +1408,7 @@ export async function userAuditHistory( req, res ) {
|
|
|
1370
1408
|
{ tempId: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1371
1409
|
{ question: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1372
1410
|
{ zoneName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1411
|
+
{ question: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1373
1412
|
{ userComments: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1374
1413
|
],
|
|
1375
1414
|
|
|
@@ -1440,7 +1479,7 @@ export async function userAuditHistory( req, res ) {
|
|
|
1440
1479
|
temp['Accuracy'] = element.accuracy || '';
|
|
1441
1480
|
break;
|
|
1442
1481
|
case 'hygiene':
|
|
1443
|
-
temp['Zone Name'] = element.
|
|
1482
|
+
temp['Zone Name'] = element.question;
|
|
1444
1483
|
temp['Before Count'] = element.beforeCount;
|
|
1445
1484
|
temp['After Count'] = element.afterCount;
|
|
1446
1485
|
temp['Accuracy'] = element.accuracy || '';
|
|
@@ -1877,6 +1916,43 @@ export async function storeMetrics( req, res ) {
|
|
|
1877
1916
|
preserveNullAndEmptyArrays: true,
|
|
1878
1917
|
},
|
|
1879
1918
|
},
|
|
1919
|
+
{
|
|
1920
|
+
$lookup: {
|
|
1921
|
+
from: 'traxAuditData',
|
|
1922
|
+
let: {
|
|
1923
|
+
fileDate: '$fileDate', storeId: '$storeId', zoneName: '$zoneName',
|
|
1924
|
+
},
|
|
1925
|
+
pipeline: [
|
|
1926
|
+
{
|
|
1927
|
+
$match: {
|
|
1928
|
+
$expr: {
|
|
1929
|
+
$and: [
|
|
1930
|
+
{
|
|
1931
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
1932
|
+
},
|
|
1933
|
+
{
|
|
1934
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
1935
|
+
},
|
|
1936
|
+
{
|
|
1937
|
+
$eq: [ '$zoneName', '$$zoneName' ],
|
|
1938
|
+
},
|
|
1939
|
+
],
|
|
1940
|
+
},
|
|
1941
|
+
},
|
|
1942
|
+
},
|
|
1943
|
+
{
|
|
1944
|
+
$project: {
|
|
1945
|
+
message: '$sqs.Body',
|
|
1946
|
+
},
|
|
1947
|
+
},
|
|
1948
|
+
], as: 'sqs',
|
|
1949
|
+
},
|
|
1950
|
+
},
|
|
1951
|
+
{
|
|
1952
|
+
$unwind: {
|
|
1953
|
+
path: '$sqs', preserveNullAndEmptyArrays: true,
|
|
1954
|
+
},
|
|
1955
|
+
},
|
|
1880
1956
|
{
|
|
1881
1957
|
$project: {
|
|
1882
1958
|
auditId: '$_id',
|
|
@@ -1896,6 +1972,7 @@ export async function storeMetrics( req, res ) {
|
|
|
1896
1972
|
userComments: 1,
|
|
1897
1973
|
question: 1,
|
|
1898
1974
|
questionType: 1,
|
|
1975
|
+
question: '$sqs.message.question',
|
|
1899
1976
|
answer: 1,
|
|
1900
1977
|
userId: {
|
|
1901
1978
|
$arrayElemAt: [ '$userId', { $subtract: [ { $size: '$userId' }, 1 ] } ], // need to check if no data
|
|
@@ -2229,6 +2306,7 @@ export async function storeMetrics( req, res ) {
|
|
|
2229
2306
|
{ answer: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2230
2307
|
{ auditStatus: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2231
2308
|
{ userComments: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2309
|
+
{ question: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2232
2310
|
],
|
|
2233
2311
|
},
|
|
2234
2312
|
} );
|
|
@@ -2341,7 +2419,7 @@ export async function storeMetrics( req, res ) {
|
|
|
2341
2419
|
temp['Accuracy'] = element.accuracy;
|
|
2342
2420
|
break;
|
|
2343
2421
|
case 'hygiene':
|
|
2344
|
-
temp['Zone Name'] = element.
|
|
2422
|
+
temp['Zone Name'] = element.question;
|
|
2345
2423
|
temp['Before Count'] = element.beforeCount;
|
|
2346
2424
|
temp['After Count'] = element.afterCount;
|
|
2347
2425
|
temp['Status'] = toCamelCase( element.status );
|
|
@@ -2709,6 +2787,44 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
2709
2787
|
},
|
|
2710
2788
|
|
|
2711
2789
|
},
|
|
2790
|
+
{
|
|
2791
|
+
$lookup: {
|
|
2792
|
+
from: 'traxAuditData',
|
|
2793
|
+
let: {
|
|
2794
|
+
fileDate: '$fileDate', storeId: '$storeId', zoneName: '$zoneName',
|
|
2795
|
+
},
|
|
2796
|
+
pipeline: [
|
|
2797
|
+
{
|
|
2798
|
+
$match: {
|
|
2799
|
+
$expr: {
|
|
2800
|
+
$and: [
|
|
2801
|
+
{
|
|
2802
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
2803
|
+
},
|
|
2804
|
+
{
|
|
2805
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
2806
|
+
},
|
|
2807
|
+
{
|
|
2808
|
+
$eq: [ '$zoneName', '$$zoneName' ],
|
|
2809
|
+
},
|
|
2810
|
+
],
|
|
2811
|
+
},
|
|
2812
|
+
},
|
|
2813
|
+
},
|
|
2814
|
+
{
|
|
2815
|
+
$project: {
|
|
2816
|
+
message: '$sqs.Body',
|
|
2817
|
+
},
|
|
2818
|
+
},
|
|
2819
|
+
], as: 'sqs',
|
|
2820
|
+
},
|
|
2821
|
+
},
|
|
2822
|
+
{
|
|
2823
|
+
$unwind: {
|
|
2824
|
+
path: '$sqs', preserveNullAndEmptyArrays: true,
|
|
2825
|
+
},
|
|
2826
|
+
},
|
|
2827
|
+
|
|
2712
2828
|
{
|
|
2713
2829
|
$project: {
|
|
2714
2830
|
_id: 0,
|
|
@@ -2720,6 +2836,7 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
2720
2836
|
questionType: 1,
|
|
2721
2837
|
answer: 1,
|
|
2722
2838
|
userComments: 1,
|
|
2839
|
+
question: '$sqs.message.question',
|
|
2723
2840
|
fileDate: 1,
|
|
2724
2841
|
moduleType: 1,
|
|
2725
2842
|
value: {
|
|
@@ -2801,6 +2918,7 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
2801
2918
|
{ userName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2802
2919
|
{ userEmail: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2803
2920
|
{ value: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2921
|
+
{ question: { $regex: inputData.searchData, $options: 'i' } },
|
|
2804
2922
|
],
|
|
2805
2923
|
|
|
2806
2924
|
},
|
|
@@ -2862,7 +2980,7 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
2862
2980
|
temp['Before Count'] = element.beforeCount;
|
|
2863
2981
|
break;
|
|
2864
2982
|
case 'hygiene':
|
|
2865
|
-
temp['Zone Name'] = element.
|
|
2983
|
+
temp['Zone Name'] = element.question;
|
|
2866
2984
|
temp['Before Count'] = element.beforeCount;
|
|
2867
2985
|
break;
|
|
2868
2986
|
}
|
|
@@ -3259,6 +3377,43 @@ export async function overviewTable( req, res ) {
|
|
|
3259
3377
|
},
|
|
3260
3378
|
|
|
3261
3379
|
},
|
|
3380
|
+
{
|
|
3381
|
+
$lookup: {
|
|
3382
|
+
from: 'traxAuditData',
|
|
3383
|
+
let: {
|
|
3384
|
+
fileDate: '$fileDate', storeId: '$storeId', zoneName: '$zoneName',
|
|
3385
|
+
},
|
|
3386
|
+
pipeline: [
|
|
3387
|
+
{
|
|
3388
|
+
$match: {
|
|
3389
|
+
$expr: {
|
|
3390
|
+
$and: [
|
|
3391
|
+
{
|
|
3392
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
3393
|
+
},
|
|
3394
|
+
{
|
|
3395
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
3396
|
+
},
|
|
3397
|
+
{
|
|
3398
|
+
$eq: [ '$zoneName', '$$zoneName' ],
|
|
3399
|
+
},
|
|
3400
|
+
],
|
|
3401
|
+
},
|
|
3402
|
+
},
|
|
3403
|
+
},
|
|
3404
|
+
{
|
|
3405
|
+
$project: {
|
|
3406
|
+
message: '$sqs.Body',
|
|
3407
|
+
},
|
|
3408
|
+
},
|
|
3409
|
+
], as: 'sqs',
|
|
3410
|
+
},
|
|
3411
|
+
},
|
|
3412
|
+
{
|
|
3413
|
+
$unwind: {
|
|
3414
|
+
path: '$sqs', preserveNullAndEmptyArrays: true,
|
|
3415
|
+
},
|
|
3416
|
+
},
|
|
3262
3417
|
{
|
|
3263
3418
|
$project: {
|
|
3264
3419
|
_id: 0,
|
|
@@ -3267,7 +3422,7 @@ export async function overviewTable( req, res ) {
|
|
|
3267
3422
|
zoneName: 1,
|
|
3268
3423
|
streamName: 1,
|
|
3269
3424
|
tempId: 1,
|
|
3270
|
-
question:
|
|
3425
|
+
question: '$sqs.message.question',
|
|
3271
3426
|
questionType: 1,
|
|
3272
3427
|
answer: 1,
|
|
3273
3428
|
userComments: 1,
|
|
@@ -3324,6 +3479,7 @@ export async function overviewTable( req, res ) {
|
|
|
3324
3479
|
{ question: { $regex: inputData.searchValue, $options: 'i' } },
|
|
3325
3480
|
{ answer: { $regex: inputData.searchValue, $options: 'i' } },
|
|
3326
3481
|
{ userComments: { $regex: inputData.searchValue, $options: 'i' } },
|
|
3482
|
+
{ question: { $regex: inputData.searchValue, $options: 'i' } },
|
|
3327
3483
|
],
|
|
3328
3484
|
|
|
3329
3485
|
},
|
|
@@ -3395,7 +3551,7 @@ export async function overviewTable( req, res ) {
|
|
|
3395
3551
|
temp['Status'] = toCamelCase( element.status );
|
|
3396
3552
|
break;
|
|
3397
3553
|
case 'hygiene':
|
|
3398
|
-
temp['Zone Name'] = element.
|
|
3554
|
+
temp['Zone Name'] = element.question;
|
|
3399
3555
|
temp['Before Count'] = element.beforeCount;
|
|
3400
3556
|
temp['After Count'] = element.afterCount;
|
|
3401
3557
|
temp['Audit Type'] = element.auditType;
|
|
@@ -3449,6 +3605,38 @@ export async function getDetectionAuditFile( req, res ) {
|
|
|
3449
3605
|
{
|
|
3450
3606
|
$limit: 1,
|
|
3451
3607
|
},
|
|
3608
|
+
{
|
|
3609
|
+
$lookup: {
|
|
3610
|
+
from: 'traxAuditData',
|
|
3611
|
+
let: {
|
|
3612
|
+
fileDate: '$fileDate', storeId: '$storeId', zoneName: '$zoneName',
|
|
3613
|
+
},
|
|
3614
|
+
pipeline: [
|
|
3615
|
+
{
|
|
3616
|
+
$match: {
|
|
3617
|
+
$expr: {
|
|
3618
|
+
$and: [
|
|
3619
|
+
{
|
|
3620
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
3621
|
+
},
|
|
3622
|
+
{
|
|
3623
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
3624
|
+
},
|
|
3625
|
+
{
|
|
3626
|
+
$eq: [ '$zoneName', '$$zoneName' ],
|
|
3627
|
+
},
|
|
3628
|
+
],
|
|
3629
|
+
},
|
|
3630
|
+
},
|
|
3631
|
+
},
|
|
3632
|
+
{
|
|
3633
|
+
$project: {
|
|
3634
|
+
message: '$sqs.Body',
|
|
3635
|
+
},
|
|
3636
|
+
},
|
|
3637
|
+
], as: 'sqs',
|
|
3638
|
+
},
|
|
3639
|
+
},
|
|
3452
3640
|
];
|
|
3453
3641
|
|
|
3454
3642
|
const userDetails = await aggregateUserEmpDetection( userQuery );
|
|
@@ -3498,6 +3686,7 @@ export async function getDetectionAuditFile( req, res ) {
|
|
|
3498
3686
|
auditId: userDetails[0]._id,
|
|
3499
3687
|
storeId: userDetails[0].storeId,
|
|
3500
3688
|
zoneName: userDetails[0].zoneName,
|
|
3689
|
+
question: userDetails[0]?.sqs[0]?.message?.question,
|
|
3501
3690
|
fileDate: userDetails[0].fileDate,
|
|
3502
3691
|
auditType: userDetails[0].auditType,
|
|
3503
3692
|
queueName: log.queueName,
|
|
@@ -3529,6 +3718,7 @@ export async function getDetectionAuditFile( req, res ) {
|
|
|
3529
3718
|
fileDate: userDetails[0].fileDate,
|
|
3530
3719
|
auditType: userDetails[0].auditType,
|
|
3531
3720
|
storeId: userDetails[0].storeId,
|
|
3721
|
+
question: userDetails[0]?.sqs[0]?.message?.question,
|
|
3532
3722
|
clientName: log.queueName,
|
|
3533
3723
|
auditId: userDetails[0]._id,
|
|
3534
3724
|
moduleType: userDetails[0].moduleType,
|
|
@@ -3568,6 +3758,7 @@ export async function getDetectionAuditFile( req, res ) {
|
|
|
3568
3758
|
fileCount: userDetails[0].beforeCount,
|
|
3569
3759
|
inputBucketName: userDetails[0].inputBucketName,
|
|
3570
3760
|
folderPath: userDetails[0].folderPath,
|
|
3761
|
+
question: userDetails[0]?.sqs[0]?.message?.question,
|
|
3571
3762
|
};
|
|
3572
3763
|
break;
|
|
3573
3764
|
}
|
|
@@ -3584,26 +3775,32 @@ export async function getDetectionAuditFile( req, res ) {
|
|
|
3584
3775
|
if ( inputData.nextId ) {
|
|
3585
3776
|
fetchData.ContinuationToken = decodeURIComponent( inputData.nextId );
|
|
3586
3777
|
}
|
|
3587
|
-
const list = await
|
|
3588
|
-
|
|
3589
|
-
|
|
3778
|
+
const list = inputData.moduleType == 'hygiene'? await checkFileExist( {
|
|
3779
|
+
Bucket: msg.inputBucketName,
|
|
3780
|
+
Key: msg.folderPath,
|
|
3781
|
+
} ) :
|
|
3782
|
+
await listFileByPath( fetchData );
|
|
3783
|
+
const folderPath = inputData.moduleType == 'hygiene'? list? [ {
|
|
3784
|
+
Key: msg.folderPath,
|
|
3785
|
+
} ] : [] : list.data;
|
|
3786
|
+
const nextQuery = inputData.moduleType == 'hygiene'? null : list?.pageToken;
|
|
3590
3787
|
const bucketCDN = url.traxAuditInput;
|
|
3591
3788
|
if ( folderPath?.length > 0 ) {
|
|
3592
3789
|
for ( let i = 0; i < folderPath.length; i++ ) {
|
|
3593
3790
|
const img = folderPath[i].Key.split( '/' );
|
|
3594
|
-
const image =
|
|
3791
|
+
const image = img[3].split( '.' );
|
|
3595
3792
|
const indexes = image[0].split( '_' );
|
|
3596
3793
|
const Key = folderPath[i].Key;
|
|
3597
|
-
const data = `${bucketCDN}${Key}
|
|
3794
|
+
const data = `${bucketCDN}${Key}`;
|
|
3598
3795
|
const mapimg = {
|
|
3599
3796
|
img_path: data,
|
|
3600
|
-
img_name: inputData.moduleType=='mobile-detection'?`${indexes[0]}-${indexes[3]}
|
|
3601
|
-
img_id:
|
|
3797
|
+
img_name: inputData.moduleType=='mobile-detection'?`${indexes[0]}-${indexes[3]}`:image[0],
|
|
3798
|
+
img_id: img[3],
|
|
3602
3799
|
};
|
|
3603
3800
|
files.push( {
|
|
3604
3801
|
img_path: data,
|
|
3605
3802
|
img_name: inputData.moduleType=='mobile-detection'?`${indexes[0]}-${indexes[3]}`:image[0],
|
|
3606
|
-
img_id:
|
|
3803
|
+
img_id: img[3],
|
|
3607
3804
|
selected: false,
|
|
3608
3805
|
dropped: false,
|
|
3609
3806
|
singleDetection: false,
|
|
@@ -3692,6 +3889,7 @@ export async function getDetectionAuditFile( req, res ) {
|
|
|
3692
3889
|
auditType: insertData.auditType,
|
|
3693
3890
|
storeId: storeId,
|
|
3694
3891
|
zoneName: insertData.zoneName,
|
|
3892
|
+
question: msg.question,
|
|
3695
3893
|
clientName: inputData.queueName,
|
|
3696
3894
|
auditId: insertData._id,
|
|
3697
3895
|
moduleType: inputData.moduleType,
|
|
@@ -3711,6 +3909,7 @@ export async function getDetectionAuditFile( req, res ) {
|
|
|
3711
3909
|
queueName: inputData.queueName,
|
|
3712
3910
|
storeId: storeId,
|
|
3713
3911
|
zoneName: insertData.zoneName,
|
|
3912
|
+
question: msg.question,
|
|
3714
3913
|
fileDate: fileDate,
|
|
3715
3914
|
auditType: msg.auditType || 'Audit',
|
|
3716
3915
|
auditId: insertData._id,
|
|
@@ -3920,12 +4119,14 @@ export async function save( req, res ) {
|
|
|
3920
4119
|
|
|
3921
4120
|
|
|
3922
4121
|
// trax output in open serach
|
|
4122
|
+
const folderPath = getFilePath?.sqs?.Body?.folderPath;
|
|
3923
4123
|
const output = {
|
|
3924
4124
|
clientId: inputData.clientId,
|
|
3925
4125
|
clientName: getClient?.clientName,
|
|
3926
4126
|
storeId: inputData.storeId,
|
|
3927
4127
|
storeName: getStore?.storeName,
|
|
3928
4128
|
zoneName: inputData?.zoneName,
|
|
4129
|
+
question: getFilePath?.sqs?.Body?.question,
|
|
3929
4130
|
spocName: getStore?.spocDetails? getStore?.spocDetails[0]?.name : '',
|
|
3930
4131
|
spocEmail: getStore?.spocDetails? getStore?.spocDetails[0]?.email:'',
|
|
3931
4132
|
spocContact: getStore?.spocDetails? getStore?.spocDetails[0].contact:'',
|
|
@@ -3935,7 +4136,7 @@ export async function save( req, res ) {
|
|
|
3935
4136
|
inputBucketName: getFilePath?.sqs?.Body?.inputBucketName,
|
|
3936
4137
|
tempId: tempId,
|
|
3937
4138
|
count: inputData.employeeCount,
|
|
3938
|
-
folderPath:
|
|
4139
|
+
folderPath: folderPath.split( '/' ).slice( 0, -1 ).join( '/' ) + '/',
|
|
3939
4140
|
createdAt: new Date(),
|
|
3940
4141
|
};
|
|
3941
4142
|
let filter= [
|
|
@@ -3985,6 +4186,7 @@ export async function save( req, res ) {
|
|
|
3985
4186
|
auditType: getUserAuditData?.auditType,
|
|
3986
4187
|
storeId: getUserAuditData?.storeId,
|
|
3987
4188
|
zoneName: inputData?.zoneName,
|
|
4189
|
+
question: getFilePath?.sqs?.Body?.question,
|
|
3988
4190
|
moduleType: getUserAuditData?.moduleType,
|
|
3989
4191
|
queueName: req.userAudit?.queueName,
|
|
3990
4192
|
clientId: req.userAudit?.clientId,
|