tango-app-api-audit 3.4.3-alpha.15 → 3.4.3-alpha.17
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
|
@@ -1218,6 +1218,7 @@ export async function getDraftedData( req, res ) {
|
|
|
1218
1218
|
userId: userId,
|
|
1219
1219
|
moduleType: inputData.moduleType,
|
|
1220
1220
|
zoneName: inputData.zoneName,
|
|
1221
|
+
auditId: inputData.auditId,
|
|
1221
1222
|
};
|
|
1222
1223
|
const result = await findOneAuditLog( query, {}, { createdAt: -1 }, 1 );
|
|
1223
1224
|
|
|
@@ -1659,21 +1660,22 @@ export async function userAuditHistory( req, res ) {
|
|
|
1659
1660
|
chunk.forEach( ( element ) => {
|
|
1660
1661
|
exportData.push( {
|
|
1661
1662
|
'File Date': element.fileDate,
|
|
1662
|
-
'Brand ID': element.clientId,
|
|
1663
1663
|
'Brand Name': element.clientName,
|
|
1664
|
-
'
|
|
1664
|
+
'Brand ID': element.clientId,
|
|
1665
1665
|
'Store Name': element.storeName,
|
|
1666
|
+
'Store ID': element.storeId,
|
|
1666
1667
|
'Zone Name': element.moduleType == 'zone' ? element.zoneName : '',
|
|
1667
1668
|
'Audit Type': element.auditType,
|
|
1668
1669
|
'Product Type': element.moduleType,
|
|
1669
1670
|
'Before Count': element.beforeCount,
|
|
1670
1671
|
'After Count': element.afterCount || '',
|
|
1671
1672
|
'Accuracy': element.accuracy || '',
|
|
1673
|
+
'Audited Date': dayjs( element.createdAt ).format( 'YYYY,MMM D' ),
|
|
1672
1674
|
'Start Time': element.startTime,
|
|
1673
1675
|
'End Time': element.endTime || '',
|
|
1674
1676
|
'Time Spent': element.timeSpent,
|
|
1675
|
-
'
|
|
1676
|
-
|
|
1677
|
+
'Status': element.auditStatus,
|
|
1678
|
+
|
|
1677
1679
|
|
|
1678
1680
|
} );
|
|
1679
1681
|
} );
|
|
@@ -3810,7 +3812,7 @@ export async function auditImages( req, res ) {
|
|
|
3810
3812
|
export async function getUserAuditCount( req, res ) {
|
|
3811
3813
|
try {
|
|
3812
3814
|
const userWallet = JSON.parse( process.env.USER_WALLET );
|
|
3813
|
-
const previousDate = dayjs( new Date() ).subtract(
|
|
3815
|
+
const previousDate = dayjs( new Date() ).subtract( 16, 'days' );
|
|
3814
3816
|
const fileDate = dayjs( previousDate ).format( 'DD-MM-YYYY' );
|
|
3815
3817
|
const configTimeSpentSec = userWallet.minTimeSpentSec; // 18000;
|
|
3816
3818
|
const beforeCountX = userWallet.beforeCountCreditPerc; // 0.0335;
|
|
@@ -4039,16 +4041,16 @@ export async function getUserAuditCount( req, res ) {
|
|
|
4039
4041
|
totalTimeSpent: {
|
|
4040
4042
|
$cond: [ { $eq: [ '$hours', 0 ] },
|
|
4041
4043
|
{ $concat: [
|
|
4042
|
-
{ $toString: '$minutes' }, '
|
|
4044
|
+
'00:', { $toString: '$minutes' }, ':00',
|
|
4043
4045
|
] },
|
|
4044
4046
|
{ $cond: [ { $eq: [ '$minutes', 0 ] },
|
|
4045
4047
|
{ $concat: [
|
|
4046
|
-
{ $toString: '$hours' }, '
|
|
4048
|
+
{ $toString: '$hours' }, ':00:00',
|
|
4047
4049
|
] },
|
|
4048
4050
|
{
|
|
4049
4051
|
$concat: [
|
|
4050
|
-
{ $toString: '$hours' }, '
|
|
4051
|
-
{ $toString: '$minutes' }, '
|
|
4052
|
+
{ $toString: '$hours' }, ':',
|
|
4053
|
+
{ $toString: '$minutes' }, ':00',
|
|
4052
4054
|
],
|
|
4053
4055
|
},
|
|
4054
4056
|
] },
|
|
@@ -4429,24 +4431,25 @@ export async function auditViewLogs( req, res ) {
|
|
|
4429
4431
|
try {
|
|
4430
4432
|
const inputData = req.query;
|
|
4431
4433
|
const parsedOpenSearch = JSON.parse( process.env.OPENSEARCH );
|
|
4432
|
-
|
|
4434
|
+
const logData =[];
|
|
4435
|
+
let logsQuery = {
|
|
4433
4436
|
'size': 100,
|
|
4434
4437
|
'query': {
|
|
4435
4438
|
'bool': {
|
|
4436
4439
|
'must': [
|
|
4437
4440
|
{
|
|
4438
4441
|
'term': {
|
|
4439
|
-
'
|
|
4442
|
+
'logData.fileDate.keyword': inputData.fileDate,
|
|
4440
4443
|
},
|
|
4441
4444
|
},
|
|
4442
4445
|
{
|
|
4443
4446
|
'term': {
|
|
4444
|
-
'
|
|
4447
|
+
'logData.storeId.keyword': inputData.storeId,
|
|
4445
4448
|
},
|
|
4446
4449
|
},
|
|
4447
4450
|
{
|
|
4448
4451
|
'term': {
|
|
4449
|
-
'
|
|
4452
|
+
'logData.moduleType.keyword': inputData.moduleType,
|
|
4450
4453
|
},
|
|
4451
4454
|
},
|
|
4452
4455
|
],
|
|
@@ -4454,10 +4457,17 @@ export async function auditViewLogs( req, res ) {
|
|
|
4454
4457
|
},
|
|
4455
4458
|
},
|
|
4456
4459
|
};
|
|
4457
|
-
const
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4460
|
+
const logs = await getOpenSearchData( parsedOpenSearch.auditLog, logsQuery );
|
|
4461
|
+
if ( logs.body.hits.hits.length > 0 ) {
|
|
4462
|
+
logData.push( logs.body.hits.hits[0]._source );
|
|
4463
|
+
return res.sendSuccess( logData );
|
|
4464
|
+
} else {
|
|
4465
|
+
return res.sendError( 'No Record Inserted', 500 );
|
|
4466
|
+
}
|
|
4467
|
+
} catch ( error ) {
|
|
4468
|
+
const err = error.message || 'Internal Server Error';
|
|
4469
|
+
logger.info( { error: error, message: req.body, function: 'auditViewLogs' } );
|
|
4470
|
+
return res.sendError( err, 500 );
|
|
4461
4471
|
}
|
|
4462
4472
|
}
|
|
4463
4473
|
|
|
@@ -1714,18 +1714,17 @@ export async function userAuditHistory( req, res ) {
|
|
|
1714
1714
|
const temp ={
|
|
1715
1715
|
|
|
1716
1716
|
'File Date': element.fileDate,
|
|
1717
|
-
'Brand ID': element.clientId,
|
|
1718
1717
|
'Brand Name': element.clientName,
|
|
1719
|
-
'
|
|
1718
|
+
'Brand ID': element.clientId,
|
|
1720
1719
|
'Store Name': element.storeName,
|
|
1720
|
+
'Store ID': element.storeId,
|
|
1721
1721
|
'Audit Type': element.auditType,
|
|
1722
1722
|
'Product Type': element.value,
|
|
1723
|
+
'Audited Date': dayjs( element.createdAt ).format( 'YYYY,MMM D' ),
|
|
1723
1724
|
'Start Time': element.startTime,
|
|
1724
1725
|
'End Time': element.endTime || '',
|
|
1725
1726
|
'Time Spent': element.timeSpent,
|
|
1726
1727
|
'Status': toCamelCase( element.auditStatus ),
|
|
1727
|
-
'Audited Date': dayjs( element.createdAt ).format( 'YYYY,MMM D' ),
|
|
1728
|
-
'Result': element.answer,
|
|
1729
1728
|
|
|
1730
1729
|
|
|
1731
1730
|
};
|
|
@@ -4212,6 +4211,7 @@ export async function getDraftedData( req, res ) {
|
|
|
4212
4211
|
storeId: inputData.storeId,
|
|
4213
4212
|
userId: userId,
|
|
4214
4213
|
moduleType: inputData.moduleType,
|
|
4214
|
+
auditId: inputData.auditId,
|
|
4215
4215
|
};
|
|
4216
4216
|
const result = await findOneAuditLog( query, {}, { createdAt: -1 }, 1 );
|
|
4217
4217
|
|
package/src/docs/audit.docs.js
CHANGED
|
@@ -184,6 +184,12 @@ export const auditDocs = {
|
|
|
184
184
|
scema: j2s( getDraftedDataSchema ).swagger,
|
|
185
185
|
require: true,
|
|
186
186
|
},
|
|
187
|
+
{
|
|
188
|
+
in: 'query',
|
|
189
|
+
name: 'auditId',
|
|
190
|
+
scema: j2s( getDraftedDataSchema ).swagger,
|
|
191
|
+
require: true,
|
|
192
|
+
},
|
|
187
193
|
{
|
|
188
194
|
in: 'query',
|
|
189
195
|
name: 'userId',
|
|
@@ -387,6 +387,12 @@ export const traxAuditDocs = {
|
|
|
387
387
|
scema: j2s( getDraftedDataSchema ).swagger,
|
|
388
388
|
require: true,
|
|
389
389
|
},
|
|
390
|
+
{
|
|
391
|
+
in: 'query',
|
|
392
|
+
name: 'auditId',
|
|
393
|
+
scema: j2s( getDraftedDataSchema ).swagger,
|
|
394
|
+
require: true,
|
|
395
|
+
},
|
|
390
396
|
{
|
|
391
397
|
in: 'query',
|
|
392
398
|
name: 'userId',
|
package/src/dtos/audit.dtos.js
CHANGED