tango-app-api-audit 3.6.43 → 3.6.44
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
|
@@ -25,17 +25,32 @@ export async function getList( req, res ) {
|
|
|
25
25
|
|
|
26
26
|
const sortBy = inputData?.sortBy ? [ 'coveredStepsAI', 'trustScore', 'date' ].includes( inputData.sortBy ) ? inputData.sortBy :`${inputData.sortBy}.keyword` : 'storeName.keyword';
|
|
27
27
|
const order = inputData?.sortOrder || -1;
|
|
28
|
-
let filter
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
'
|
|
28
|
+
let filter;
|
|
29
|
+
if ( dateType === 'auditedDate' ) {
|
|
30
|
+
filter= [
|
|
31
|
+
{
|
|
32
|
+
'range': {
|
|
33
|
+
'updatedAt': {
|
|
34
|
+
'gte': new Date( inputData.fromDate ),
|
|
35
|
+
'lte': new Date( inputData.toDate ),
|
|
36
|
+
},
|
|
34
37
|
},
|
|
35
38
|
},
|
|
36
|
-
},
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
];
|
|
41
|
+
} else {
|
|
42
|
+
filter= [
|
|
43
|
+
{
|
|
44
|
+
'range': {
|
|
45
|
+
'date': {
|
|
46
|
+
'gte': new Date( inputData.fromDate ),
|
|
47
|
+
'lte': new Date( inputData.toDate ),
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
];
|
|
53
|
+
}
|
|
39
54
|
|
|
40
55
|
|
|
41
56
|
if ( inputData.demographics && inputData.demographics.length > 0 ) {
|
|
@@ -298,49 +313,7 @@ export async function getList( req, res ) {
|
|
|
298
313
|
}
|
|
299
314
|
}
|
|
300
315
|
|
|
301
|
-
|
|
302
|
-
// try {
|
|
303
|
-
// const pageSize = 1000; // safer chunk size
|
|
304
|
-
// let allHits = [];
|
|
305
|
-
// let searchAfter = null;
|
|
306
|
-
// let hasMore = true;
|
|
307
|
-
// let i =0;
|
|
308
|
-
|
|
309
|
-
// while ( hasMore ) {
|
|
310
|
-
// const body={
|
|
311
|
-
// size: pageSize,
|
|
312
|
-
// query: {
|
|
313
|
-
// bool: data,
|
|
314
|
-
// },
|
|
315
|
-
// sort: [
|
|
316
|
-
// { 'storeName.keyword': 'desc' },
|
|
317
|
-
// { '_id': 'asc' }, // Required for stable search_after
|
|
318
|
-
// ],
|
|
319
|
-
// };
|
|
320
|
-
|
|
321
|
-
// if ( searchAfter ) {
|
|
322
|
-
// body.search_after = searchAfter;
|
|
323
|
-
// }
|
|
324
|
-
|
|
325
|
-
// const response = await getOpenSearchData( index, body );
|
|
326
|
-
// const hits = response.body.hits.hits;
|
|
327
|
-
// i = i+hits.length;
|
|
328
|
-
// logger.info( { index: i, length: hits.length, msg: '........index' } );
|
|
329
|
-
// allHits.push( ...hits );
|
|
330
|
-
// if ( allHits.length >= 50000 ) {
|
|
331
|
-
// hasMore = false;
|
|
332
|
-
// } else {
|
|
333
|
-
// searchAfter = hits[hits.length - 1].sort;
|
|
334
|
-
// }
|
|
335
|
-
// }
|
|
336
|
-
|
|
337
|
-
// logger.info( `Fetched ${allHits.length} documents` );
|
|
338
|
-
// return allHits;
|
|
339
|
-
// } catch ( error ) {
|
|
340
|
-
// const err = error.message || 'Internal Server Error';
|
|
341
|
-
// return res.sendError( err, 500 );
|
|
342
|
-
// };
|
|
343
|
-
// };
|
|
316
|
+
|
|
344
317
|
export async function fetchDeepPage( index, data, limit, offset, sortBy, order, searchAfter1 ) {
|
|
345
318
|
try {
|
|
346
319
|
logger.info( { index: index, data: data, limit: limit, offset: offset } );
|
|
@@ -365,27 +338,6 @@ export async function fetchDeepPage( index, data, limit, offset, sortBy, order,
|
|
|
365
338
|
);
|
|
366
339
|
|
|
367
340
|
const hits = response?.body?.hits?.hits;
|
|
368
|
-
// while ( currentCount < offset + limit ) {
|
|
369
|
-
// const response = await getOpenSearchData(
|
|
370
|
-
// index,
|
|
371
|
-
// body,
|
|
372
|
-
// );
|
|
373
|
-
|
|
374
|
-
// const hits = response?.body?.hits?.hits;
|
|
375
|
-
// logger.info( { response: response } );
|
|
376
|
-
// if ( !hits.length || offset + limit <= i ) break;
|
|
377
|
-
// i = i+hits.length;
|
|
378
|
-
// logger.info( { hits: hits, function: '.........hits' } );
|
|
379
|
-
// currentCount += hits.length;
|
|
380
|
-
// searchAfter = hits[hits.length - 1].sort;
|
|
381
|
-
// logger.info( { searchAfter: searchAfter } );
|
|
382
|
-
// // Only keep the target range
|
|
383
|
-
// const startIndex = Math.max( 0, hits.length - ( currentCount - offset ) );
|
|
384
|
-
// const sliced = hits.slice( startIndex, startIndex + limit );
|
|
385
|
-
// if ( currentCount >= offset ) {
|
|
386
|
-
// finalResults.push( ...sliced );
|
|
387
|
-
// }
|
|
388
|
-
// }
|
|
389
341
|
return hits;
|
|
390
342
|
} catch ( error ) {
|
|
391
343
|
const err = error.message || 'Internal Server Error';
|
|
@@ -1460,21 +1412,36 @@ export async function summaryList( req, res ) {
|
|
|
1460
1412
|
const limit = inputData.limit || 10;
|
|
1461
1413
|
const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
|
|
1462
1414
|
|
|
1463
|
-
const sortBy = inputData?.sortBy ? [ 'coveredStepsAI', 'trustScore', 'date', 'ComplianceScore', 'auditedSteps' ].includes( inputData.sortBy ) ? inputData.sortBy :`${inputData.sortBy}.keyword` : 'storeName.keyword';
|
|
1415
|
+
const sortBy = inputData?.sortBy ? inputData?.sortBy === 'auditedDate'? 'updatedAt': [ 'coveredStepsAI', 'trustScore', 'date', 'ComplianceScore', 'auditedSteps' ].includes( inputData.sortBy ) ? inputData.sortBy :`${inputData.sortBy}.keyword` : 'storeName.keyword';
|
|
1464
1416
|
const order = inputData?.sortOrder || -1;
|
|
1465
1417
|
|
|
1466
1418
|
// declare filter and assign range values from inputData
|
|
1467
|
-
let filter
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
'
|
|
1419
|
+
let filter;
|
|
1420
|
+
if ( inputData?.dateType === 'auditedDate' ) {
|
|
1421
|
+
filter= [
|
|
1422
|
+
{
|
|
1423
|
+
'range': {
|
|
1424
|
+
'updatedAt': {
|
|
1425
|
+
'gte': new Date( inputData.fromDate ),
|
|
1426
|
+
'lte': new Date( inputData.toDate ),
|
|
1427
|
+
},
|
|
1473
1428
|
},
|
|
1474
1429
|
},
|
|
1475
|
-
},
|
|
1476
1430
|
|
|
1477
|
-
|
|
1431
|
+
];
|
|
1432
|
+
} else {
|
|
1433
|
+
filter= [
|
|
1434
|
+
{
|
|
1435
|
+
'range': {
|
|
1436
|
+
'date': {
|
|
1437
|
+
'gte': new Date( inputData.fromDate ),
|
|
1438
|
+
'lte': new Date( inputData.toDate ),
|
|
1439
|
+
},
|
|
1440
|
+
},
|
|
1441
|
+
},
|
|
1442
|
+
|
|
1443
|
+
];
|
|
1444
|
+
}
|
|
1478
1445
|
|
|
1479
1446
|
// filter by Audit Status if key has minimum one element
|
|
1480
1447
|
if ( inputData?.auditStatus && inputData?.auditStatus?.length > 0 ) {
|
|
@@ -3,6 +3,7 @@ import dayjs from 'dayjs';
|
|
|
3
3
|
|
|
4
4
|
export const getListSchema = joi.object(
|
|
5
5
|
{
|
|
6
|
+
dateType: joi.string().optional().valid( 'fileDate', 'auditedDate' ),
|
|
6
7
|
fromDate: joi.string().required().messages( {
|
|
7
8
|
'any.required': 'From Date is required',
|
|
8
9
|
'string.empty': 'From Date cannot be empty',
|
|
@@ -101,6 +102,7 @@ export const userAuditedDataValid = {
|
|
|
101
102
|
};
|
|
102
103
|
|
|
103
104
|
export const summaryListSchema = joi.object( {
|
|
105
|
+
dateType: joi.string().optional().valid( 'fileDate', 'auditedDate' ),
|
|
104
106
|
keyType: joi.string()
|
|
105
107
|
.valid( 'rm', 'cluster', 'store' )
|
|
106
108
|
.required()
|