tango-app-api-trax 3.7.73 → 3.7.75
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 +2 -4
- package/src/controllers/internalTrax.controller.js +3 -157
- package/src/controllers/mobileTrax.controller.js +39 -379
- package/src/controllers/trax.controller.js +1 -80
- package/src/controllers/traxDashboard.controllers.js +3 -58
- package/src/hbs/login-otp.hbs +943 -943
- package/src/routes/internalTraxApi.router.js +0 -1
- package/src/routes/mobileTrax.routes.js +1 -3
- package/src/routes/trax.routes.js +1 -2
- package/src/controllers/handlebar-helper.js +0 -16
- package/src/hbs/flag.hbs +0 -249
- package/src/hbs/template.hbs +0 -337
|
@@ -26,7 +26,6 @@ import * as teamsServices from '../services/teams.service.js';
|
|
|
26
26
|
import * as runAIFeatureServices from '../services/runAIFeatures.services.js';
|
|
27
27
|
import * as runAIRequestServices from '../services/runAIRequest.services.js';
|
|
28
28
|
import * as processedTaskService from '../services/processedTaskList.service.js';
|
|
29
|
-
import ExcelJS from 'exceljs';
|
|
30
29
|
|
|
31
30
|
|
|
32
31
|
export const checklist = async ( req, res ) => {
|
|
@@ -184,7 +183,7 @@ export const create = async ( req, res ) => {
|
|
|
184
183
|
checkNumber = result.length > 0 ? result[0].maxCheckListNumber + 1 : 0;
|
|
185
184
|
|
|
186
185
|
let runAIQuestionCount = 0;
|
|
187
|
-
|
|
186
|
+
|
|
188
187
|
inputBody.sections.forEach( async ( element ) => {
|
|
189
188
|
if ( !element?.questions?.length && inputBody.submitType == 'configure' ) {
|
|
190
189
|
return res.sendError( { message: 'Question is Required' }, 400 );
|
|
@@ -192,9 +191,6 @@ export const create = async ( req, res ) => {
|
|
|
192
191
|
if ( element?.questions?.length ) {
|
|
193
192
|
questionCount = questionCount + element?.questions?.length;
|
|
194
193
|
}
|
|
195
|
-
element.questions.forEach( ( question ) => {
|
|
196
|
-
complianceCount += Math.max( ...question.answers.map( ( o ) => o?.complianceScore ?? Math.max( o?.matchedCount ?? 0, o?.notMatched ?? 0 ) ) );
|
|
197
|
-
} );
|
|
198
194
|
let runAiQuestions = element?.questions.filter( ( qn ) => qn.runAI );
|
|
199
195
|
runAIQuestionCount += runAiQuestions.length;
|
|
200
196
|
} );
|
|
@@ -210,7 +206,6 @@ export const create = async ( req, res ) => {
|
|
|
210
206
|
client_id: req.body?.clientId,
|
|
211
207
|
owner: req.user.userType == 'client' ? [ { name: req.user.userName, value: req.user.email } ] : [],
|
|
212
208
|
runAIQuestionCount: runAIQuestionCount,
|
|
213
|
-
complianceCount: complianceCount,
|
|
214
209
|
// configStartDate:new Date(),
|
|
215
210
|
// configEndDate:new Date(),
|
|
216
211
|
};
|
|
@@ -987,7 +982,6 @@ export const update = async ( req, res ) => {
|
|
|
987
982
|
|
|
988
983
|
let getExistQuestions = await questionService.findSort( { checkListId: req.params.checklistId, client_id: req.body.clientId }, {}, { sectionNumber: 1 } );
|
|
989
984
|
let runAIQuestionCount = 0;
|
|
990
|
-
let complianceCount = 0;
|
|
991
985
|
inputBody.sections.forEach( async ( element ) => {
|
|
992
986
|
if ( !element.questions.length && inputBody.submitType == 'configure' ) {
|
|
993
987
|
return res.sendError( { message: 'Question is Required' }, 400 );
|
|
@@ -996,9 +990,6 @@ export const update = async ( req, res ) => {
|
|
|
996
990
|
if ( element.questions.length ) {
|
|
997
991
|
questionCount = questionCount + element.questions.length;
|
|
998
992
|
}
|
|
999
|
-
element.questions.forEach( ( question ) => {
|
|
1000
|
-
complianceCount += Math.max( ...question.answers.map( ( o ) => o?.complianceScore ?? Math.max( o?.matchedCount ?? 0, o?.notMatched ?? 0 ) ) );
|
|
1001
|
-
} );
|
|
1002
993
|
let runAiQuestions = element?.questions.filter( ( qn ) => qn.runAI );
|
|
1003
994
|
runAIQuestionCount += runAiQuestions.length;
|
|
1004
995
|
} );
|
|
@@ -1009,7 +1000,6 @@ export const update = async ( req, res ) => {
|
|
|
1009
1000
|
checkListDescription: inputBody.checklistDescription,
|
|
1010
1001
|
questionCount: questionCount,
|
|
1011
1002
|
runAIQuestionCount: runAIQuestionCount,
|
|
1012
|
-
complianceCount: complianceCount,
|
|
1013
1003
|
};
|
|
1014
1004
|
|
|
1015
1005
|
await checklistService.updateOne( { _id: req.params.checklistId }, params );
|
|
@@ -3940,7 +3930,6 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3940
3930
|
element4.rawImageUpload = getCLconfig?.rawImageUpload || false;
|
|
3941
3931
|
element4.rawVideoUpload = getCLconfig?.rawVideoUpload || false;
|
|
3942
3932
|
element4.videoUploadTimeLimit = getCLconfig?.videoUploadTimeLimit || 0;
|
|
3943
|
-
element4.complianceCount = getCLconfig?.complianceCount || 0;
|
|
3944
3933
|
assignUserList.push( { ...element4 } );
|
|
3945
3934
|
}
|
|
3946
3935
|
} ) );
|
|
@@ -5086,71 +5075,3 @@ export async function updateOSProcessedData( req, res ) {
|
|
|
5086
5075
|
return res.sendError( error, 500 );
|
|
5087
5076
|
}
|
|
5088
5077
|
}
|
|
5089
|
-
|
|
5090
|
-
export async function downloadQuestionTemplate( req, res ) {
|
|
5091
|
-
try {
|
|
5092
|
-
let questionDetails = await questionService.find( { checkListId: req.body.checklistId } );
|
|
5093
|
-
let answerType = {
|
|
5094
|
-
'descriptive': 'Descriptive Answer',
|
|
5095
|
-
'yes/no': 'A/B Question',
|
|
5096
|
-
'multiplechoicesingle': 'Multiple Choice Single',
|
|
5097
|
-
'multiplechoicemultiple': 'Multiple Choice Multiple',
|
|
5098
|
-
'descriptiveImage': 'Capture Image with Description',
|
|
5099
|
-
'image': 'Capture Image as answer',
|
|
5100
|
-
'video': 'Capture video as answer',
|
|
5101
|
-
'multipleImage': 'Capture Multiple Image',
|
|
5102
|
-
'date': 'Date',
|
|
5103
|
-
'linearscale': 'Linear Scale',
|
|
5104
|
-
'image/video': 'Capture Image/Video as Answer',
|
|
5105
|
-
'time': 'Time',
|
|
5106
|
-
'dropdown': 'Dropdown',
|
|
5107
|
-
};
|
|
5108
|
-
const workbook = new ExcelJS.Workbook();
|
|
5109
|
-
const sheet = workbook.addWorksheet( 'Fixture Library' );
|
|
5110
|
-
|
|
5111
|
-
sheet.getRow( 1 ).values = [ 'Section Name', 'Question', 'Answer Type', 'Answer Options' ];
|
|
5112
|
-
|
|
5113
|
-
let rowStart = 2;
|
|
5114
|
-
|
|
5115
|
-
questionDetails.forEach( ( section ) => {
|
|
5116
|
-
section.question.forEach( ( qn ) => {
|
|
5117
|
-
sheet.getRow( rowStart ).values = [ section.section, qn.qname, answerType[`${qn.answerType}`], [ 'multiplechoicesingle', 'multiplechoicemultiple', 'dropdown' ].includes( qn.answerType ) ? qn.answers.map( ( ans ) => ans.answer )?.toString() : '' ];
|
|
5118
|
-
rowStart += 1;
|
|
5119
|
-
} );
|
|
5120
|
-
} );
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
const maxRows = 500000;
|
|
5124
|
-
|
|
5125
|
-
let dropDownRange = [ { key: `C2:C${maxRows}`, optionList: [ '"Descriptive Answer,A/B Question,Multiple Choice Single,Multiple Choice Multiple,Capture Image with Description,Capture Image as answer,Capture video as answer,Capture Multiple Image,Date,Linear Scale,Capture Image/Video as Answer,Time,Dropdown,"' ] } ];
|
|
5126
|
-
|
|
5127
|
-
dropDownRange.forEach( ( ele ) => {
|
|
5128
|
-
sheet.dataValidations.add( ele.key, {
|
|
5129
|
-
type: 'list',
|
|
5130
|
-
allowBlank: true,
|
|
5131
|
-
formulae: ele.optionList,
|
|
5132
|
-
showErrorMessage: true,
|
|
5133
|
-
errorTitle: 'Invalid Choice',
|
|
5134
|
-
error: 'Please select from the dropdown list.',
|
|
5135
|
-
} );
|
|
5136
|
-
} );
|
|
5137
|
-
|
|
5138
|
-
sheet.columns.forEach( ( column ) => {
|
|
5139
|
-
let maxLength = 10;
|
|
5140
|
-
column.eachCell( { includeEmpty: true }, ( cell ) => {
|
|
5141
|
-
const cellValue = cell.value ? cell.value.toString() : '';
|
|
5142
|
-
if ( cellValue.length > maxLength ) {
|
|
5143
|
-
maxLength = cellValue.length;
|
|
5144
|
-
}
|
|
5145
|
-
} );
|
|
5146
|
-
column.width = maxLength + 2;
|
|
5147
|
-
} );
|
|
5148
|
-
const buffer = await workbook.xlsx.writeBuffer();
|
|
5149
|
-
res.setHeader( 'Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' );
|
|
5150
|
-
res.setHeader( 'Content-Disposition', 'attachment; filename="Checklist Question.xlsx"' );
|
|
5151
|
-
return res.send( buffer );
|
|
5152
|
-
} catch ( e ) {
|
|
5153
|
-
logger.error( { functionName: 'downloadQuestionTemplate', error: e } );
|
|
5154
|
-
return res.sendError( e, 500 );
|
|
5155
|
-
}
|
|
5156
|
-
}
|
|
@@ -276,28 +276,6 @@ export const checklistPerformance = async ( req, res ) => {
|
|
|
276
276
|
toDate = new Date( toDate.getTime() - userTimezoneOffset );
|
|
277
277
|
toDate.setUTCHours( 23, 59, 59, 59 );
|
|
278
278
|
let result = {};
|
|
279
|
-
let checklistIdList = [];
|
|
280
|
-
|
|
281
|
-
let limit = parseInt( requestData?.limit ) || 10;
|
|
282
|
-
let skip = limit * ( requestData?.offset ) || 0;
|
|
283
|
-
|
|
284
|
-
const detectionPayload = {
|
|
285
|
-
'fromDate': requestData.fromDate,
|
|
286
|
-
'toDate': requestData.toDate,
|
|
287
|
-
'clientId': requestData.clientId,
|
|
288
|
-
'sortColumnName': requestData.sortColumnName,
|
|
289
|
-
'sortBy': requestData.sortBy,
|
|
290
|
-
'storeId': requestData.storeId,
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
let complianceURL = 'https://h5gwudrwylz65s4vb6h2evwxeq0kkjog.lambda-url.ap-south-1.on.aws/';
|
|
295
|
-
const complianceData = await LamdaServiceCall( complianceURL, detectionPayload );
|
|
296
|
-
if ( complianceData?.data?.length && requestData?.sortColumnName == 'questionCompliance' ) {
|
|
297
|
-
const end = skip + requestData?.limit;
|
|
298
|
-
checklistIdList = complianceData.data.slice( skip, end )?.map( ( ele ) => ele?.sourceCheckList_id );
|
|
299
|
-
}
|
|
300
|
-
|
|
301
279
|
|
|
302
280
|
// Get User Based Checklist //
|
|
303
281
|
// let loginUser = { clientId: requestData.clientId, role: req.user.role, userType: req.user.userType, userEmail: req.user.email };
|
|
@@ -314,10 +292,6 @@ export const checklistPerformance = async ( req, res ) => {
|
|
|
314
292
|
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: requestData.userEmailes } } ] },
|
|
315
293
|
);
|
|
316
294
|
|
|
317
|
-
if ( requestData?.sortColumnName == 'questionCompliance' ) {
|
|
318
|
-
findAndQuery.push( { sourceCheckList_id: { $in: checklistIdList } } );
|
|
319
|
-
}
|
|
320
|
-
|
|
321
295
|
findQuery.push( { $match: { $and: findAndQuery } } );
|
|
322
296
|
|
|
323
297
|
if ( requestData.searchValue && requestData.searchValue != '' ) {
|
|
@@ -435,6 +409,9 @@ export const checklistPerformance = async ( req, res ) => {
|
|
|
435
409
|
findQuery.push( { $sort: { ['submittedChecklist']: -1 } } );
|
|
436
410
|
}
|
|
437
411
|
|
|
412
|
+
let limit = parseInt( requestData?.limit ) || 10;
|
|
413
|
+
let skip = limit * ( requestData?.offset ) || 0;
|
|
414
|
+
|
|
438
415
|
findQuery.push( {
|
|
439
416
|
$facet: {
|
|
440
417
|
data: [
|
|
@@ -450,14 +427,6 @@ export const checklistPerformance = async ( req, res ) => {
|
|
|
450
427
|
return res.sendError( 'no data found', 204 );
|
|
451
428
|
}
|
|
452
429
|
|
|
453
|
-
getChecklistPerformanceData?.[0]?.data.forEach( ( ele ) => {
|
|
454
|
-
let findCompliance;
|
|
455
|
-
if ( complianceData?.data?.length ) {
|
|
456
|
-
findCompliance = complianceData?.data?.find( ( data ) => data.sourceCheckList_id == ele?.sourceCheckList_id );
|
|
457
|
-
}
|
|
458
|
-
ele['questionComplianceRate'] = findCompliance?.compliancePercentage ?? 0;
|
|
459
|
-
} );
|
|
460
|
-
|
|
461
430
|
if ( requestData.export ) {
|
|
462
431
|
const exportdata = [];
|
|
463
432
|
getChecklistPerformanceData[0].data.forEach( ( element ) => {
|
|
@@ -4334,27 +4303,3 @@ function escapeRegex( text ) {
|
|
|
4334
4303
|
// return [ ];
|
|
4335
4304
|
// }
|
|
4336
4305
|
// }
|
|
4337
|
-
|
|
4338
|
-
async function LamdaServiceCall( url, data ) {
|
|
4339
|
-
try {
|
|
4340
|
-
const requestOptions = {
|
|
4341
|
-
method: 'POST',
|
|
4342
|
-
headers: {
|
|
4343
|
-
'Content-Type': 'application/json',
|
|
4344
|
-
},
|
|
4345
|
-
body: JSON.stringify( data ),
|
|
4346
|
-
};
|
|
4347
|
-
console.log( data );
|
|
4348
|
-
const response = await fetch( url, requestOptions );
|
|
4349
|
-
if ( !response.ok ) {
|
|
4350
|
-
throw new Error( `Response status: ${response.status}` );
|
|
4351
|
-
return false;
|
|
4352
|
-
}
|
|
4353
|
-
const json = await response.json();
|
|
4354
|
-
return json;
|
|
4355
|
-
} catch ( error ) {
|
|
4356
|
-
console.log( error );
|
|
4357
|
-
logger.error( { error: error, message: data, function: 'LamdaServiceCall' } );
|
|
4358
|
-
return false;
|
|
4359
|
-
}
|
|
4360
|
-
}
|