tango-app-api-audit 3.3.0-alpha.8 → 3.3.0-alpha.9
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
|
@@ -54,7 +54,7 @@ import {
|
|
|
54
54
|
} from '../validation/audit.validation.js';
|
|
55
55
|
import mongoose from 'mongoose';
|
|
56
56
|
import {
|
|
57
|
-
|
|
57
|
+
aggregateAuditStoreData,
|
|
58
58
|
findOneStoreData,
|
|
59
59
|
} from '../service/auditStoreData.service.js';
|
|
60
60
|
|
|
@@ -1012,7 +1012,7 @@ export async function workSpace( req, res ) {
|
|
|
1012
1012
|
const userAsignAuditCount = await aggregateAssignAudit( userAsignAudit );
|
|
1013
1013
|
const completedStoresCount = await aggregateStoreAudit( completedStores );
|
|
1014
1014
|
const clientAssignedCount = await aggregateAssignAudit( clientAssign );
|
|
1015
|
-
const auditStoreData = await
|
|
1015
|
+
const auditStoreData = await aggregateAuditStoreData(
|
|
1016
1016
|
auditStoreDataQuery,
|
|
1017
1017
|
);
|
|
1018
1018
|
|
|
@@ -1161,7 +1161,7 @@ export async function saveDraft( req, res ) {
|
|
|
1161
1161
|
logType: 'audit',
|
|
1162
1162
|
logSubType: 'auditDraft',
|
|
1163
1163
|
logData: {
|
|
1164
|
-
fileDate:
|
|
1164
|
+
fileDate: inputData.fileDate,
|
|
1165
1165
|
auditType: inputData.auditType,
|
|
1166
1166
|
storeId: inputData.storeId,
|
|
1167
1167
|
clientName: inputData.queueName,
|
|
@@ -1857,7 +1857,7 @@ export async function clientMetrics( req, res ) {
|
|
|
1857
1857
|
);
|
|
1858
1858
|
}
|
|
1859
1859
|
|
|
1860
|
-
const count = await
|
|
1860
|
+
const count = await aggregateAuditStoreData( query );
|
|
1861
1861
|
if ( count.length == 0 ) {
|
|
1862
1862
|
return res.sendError( 'No Data Found', 204 );
|
|
1863
1863
|
}
|
|
@@ -1889,7 +1889,7 @@ export async function clientMetrics( req, res ) {
|
|
|
1889
1889
|
}
|
|
1890
1890
|
|
|
1891
1891
|
logger.info( { query: query } );
|
|
1892
|
-
const result = await
|
|
1892
|
+
const result = await aggregateAuditStoreData( query );
|
|
1893
1893
|
if ( result.length == 0 ) {
|
|
1894
1894
|
return res.sendError( 'No Data Found', 204 );
|
|
1895
1895
|
}
|
|
@@ -2644,7 +2644,7 @@ export async function overAllAuditSummary( req, res ) {
|
|
|
2644
2644
|
},
|
|
2645
2645
|
},
|
|
2646
2646
|
];
|
|
2647
|
-
const auditClientData = await
|
|
2647
|
+
const auditClientData = await aggregateAuditStoreData( auditClientDataQuery );
|
|
2648
2648
|
if ( auditClientData.length >0 ) {
|
|
2649
2649
|
temp.auditStores = auditClientData[0].totalFilesCount;
|
|
2650
2650
|
}
|
|
@@ -2875,6 +2875,7 @@ export async function overViewCard( req, res ) {
|
|
|
2875
2875
|
ReAuditFileCount: 0,
|
|
2876
2876
|
inprogressCount: 0,
|
|
2877
2877
|
completedCount: 0,
|
|
2878
|
+
pendingCount: 0,
|
|
2878
2879
|
};
|
|
2879
2880
|
|
|
2880
2881
|
const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
|
|
@@ -2935,6 +2936,7 @@ export async function overViewCard( req, res ) {
|
|
|
2935
2936
|
ReAuditFileCount: 1,
|
|
2936
2937
|
inprogressCount: 1,
|
|
2937
2938
|
completedCount: 1,
|
|
2939
|
+
notAssigned: { $subtract: [ '$totalCount', { $add: [ '$inprogressCount', '$completedCount' ] } ] },
|
|
2938
2940
|
},
|
|
2939
2941
|
},
|
|
2940
2942
|
];
|
|
@@ -2952,14 +2954,13 @@ export async function summarySplit( req, res ) {
|
|
|
2952
2954
|
try {
|
|
2953
2955
|
const inputData = req.body;
|
|
2954
2956
|
const temp = {
|
|
2955
|
-
|
|
2957
|
+
total: 0,
|
|
2956
2958
|
auditInprogress: 0,
|
|
2957
2959
|
reAuditInprogress: 0,
|
|
2958
2960
|
draft: 0,
|
|
2959
2961
|
assigned: 0,
|
|
2960
2962
|
auditCompleted: 0,
|
|
2961
2963
|
reAuditCompleted: 0,
|
|
2962
|
-
completedCount: 0,
|
|
2963
2964
|
};
|
|
2964
2965
|
|
|
2965
2966
|
const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
|
|
@@ -2970,6 +2971,9 @@ export async function summarySplit( req, res ) {
|
|
|
2970
2971
|
if ( inputData.clientId.length > 0 ) {
|
|
2971
2972
|
filters.push( { clientId: { $in: inputData.clientId } } );
|
|
2972
2973
|
}
|
|
2974
|
+
if ( inputData?.moduleType?.length > 0 ) {
|
|
2975
|
+
filters.push( { moduleType: { $in: inputData.moduleType } } );
|
|
2976
|
+
}
|
|
2973
2977
|
const query =[
|
|
2974
2978
|
{
|
|
2975
2979
|
$match: {
|
|
@@ -2999,11 +3003,7 @@ export async function summarySplit( req, res ) {
|
|
|
2999
3003
|
{ $ne: [ '$status', 'assigned' ] }, 1, 0,
|
|
3000
3004
|
],
|
|
3001
3005
|
},
|
|
3002
|
-
|
|
3003
|
-
$cond: [
|
|
3004
|
-
{ $eq: [ '$status', 'completed' ] }, 1, 0,
|
|
3005
|
-
],
|
|
3006
|
-
},
|
|
3006
|
+
|
|
3007
3007
|
reAuditCompleted: {
|
|
3008
3008
|
$cond: [
|
|
3009
3009
|
{ $and: [ { $eq: [ '$auditType', 'ReAudit' ] }, { $eq: [ '$status', 'completed' ] } ] }, 1, 0,
|
|
@@ -3019,15 +3019,12 @@ export async function summarySplit( req, res ) {
|
|
|
3019
3019
|
{
|
|
3020
3020
|
$group: {
|
|
3021
3021
|
_id: { fileDate: '$fileDate', clientId: '$clientId' },
|
|
3022
|
-
totalInprogress: { $sum: 1 },
|
|
3023
3022
|
auditInprogress: { $sum: '$auditInprogress' },
|
|
3024
3023
|
reAuditInprogress: { $sum: '$reAuditInprogress' },
|
|
3025
3024
|
draft: { $sum: '$draft' },
|
|
3026
3025
|
assigned: { $sum: 'assigned' },
|
|
3027
|
-
completedCount: { $sum: '$completedCount' },
|
|
3028
3026
|
reAuditCompleted: { $sum: '$reAuditCompleted' },
|
|
3029
3027
|
auditCompleted: { $sum: '$auditCompleted' },
|
|
3030
|
-
completedCount: { $sum: '$completedCount' },
|
|
3031
3028
|
|
|
3032
3029
|
},
|
|
3033
3030
|
},
|
|
@@ -3039,14 +3036,36 @@ export async function summarySplit( req, res ) {
|
|
|
3039
3036
|
reAuditInprogress: 1,
|
|
3040
3037
|
draft: 1,
|
|
3041
3038
|
assigned: 1,
|
|
3042
|
-
completedCount: 1,
|
|
3043
3039
|
reAuditCompleted: 1,
|
|
3044
3040
|
auditCompleted: 1,
|
|
3041
|
+
totalCount: { $ifNull: [ 0, 0 ] },
|
|
3042
|
+
|
|
3043
|
+
},
|
|
3044
|
+
},
|
|
3045
|
+
];
|
|
3046
|
+
const totalQuery = [
|
|
3047
|
+
{
|
|
3048
|
+
$match: {
|
|
3049
|
+
$and: filters,
|
|
3050
|
+
},
|
|
3045
3051
|
|
|
3052
|
+
},
|
|
3053
|
+
{
|
|
3054
|
+
$group: {
|
|
3055
|
+
_id: null,
|
|
3056
|
+
total: { $sum: 1 },
|
|
3057
|
+
},
|
|
3058
|
+
},
|
|
3059
|
+
{
|
|
3060
|
+
$project: {
|
|
3061
|
+
_id: 0,
|
|
3062
|
+
total: 1,
|
|
3046
3063
|
},
|
|
3047
3064
|
},
|
|
3048
3065
|
];
|
|
3049
3066
|
const result = await aggregateStoreAudit( query );
|
|
3067
|
+
const totalCount = await aggregateAuditStoreData( totalQuery );
|
|
3068
|
+
result[0].totalCount = totalCount[0]?.total? totalCount[0].total : delete result[0].totalCount;
|
|
3050
3069
|
logger.info( { result: result } );
|
|
3051
3070
|
return res.sendSuccess( { result: result.length> 0? result[0]: temp } );
|
|
3052
3071
|
} catch ( error ) {
|
package/src/dtos/audit.dtos.js
CHANGED
|
@@ -28,10 +28,9 @@ auditRouter.post( '/metrics/overview-table', isAllowedSessionHandler, validate(
|
|
|
28
28
|
auditRouter.post( '/metrics/overall-audit-summary', isAllowedSessionHandler, validate( overAllAuditSummaryValid ), overAllAuditSummary );
|
|
29
29
|
auditRouter.post( '/metrics/re-trigger', isAllowedSessionHandler, validate( reTriggerValid ), isAuditDocumentExist, isAuditInputFolderExist, reTrigger );
|
|
30
30
|
auditRouter.get( '/audit-images', isAllowedSessionHandler, validate( auditImageValid ), isAuditInputFolderExist, auditImages );
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// hold
|
|
31
|
+
// summary
|
|
34
32
|
auditRouter.post( '/metrics/overview-card', isAllowedSessionHandler, validate( overViewCardValid ), overViewCard );
|
|
35
33
|
auditRouter.post( '/metrics/summary-split-up', isAllowedSessionHandler, validate( summarySplitValid ), summarySplit );
|
|
36
34
|
|
|
35
|
+
|
|
37
36
|
export default auditRouter;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import auditStoreDataModel from 'tango-api-schema/schema/auditStoreData.model.js';
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
export function
|
|
4
|
+
export function aggregateAuditStoreData( query ) {
|
|
5
5
|
return auditStoreDataModel.aggregate( query, { collation: { locale: 'en', strength: 2 } } );
|
|
6
6
|
}
|
|
7
7
|
|