tango-app-api-trax 3.4.1-beta-1 → 3.5.0-ai-2
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/index.js +2 -1
- package/package.json +3 -3
- package/src/controllers/activityLog.controller.js +294 -0
- package/src/controllers/download.controller.js +11 -9
- package/src/controllers/gallery.controller.js +213 -9
- package/src/controllers/internalTrax.controller.js +606 -13
- package/src/controllers/mobileTrax.controller.js +292 -10
- package/src/controllers/teaxFlag.controller.js +7 -3
- package/src/controllers/trax.controller.js +590 -136
- package/src/controllers/traxDashboard.controllers.js +18 -5
- package/src/dtos/downloadValidation.dtos.js +1 -0
- package/src/hbs/login-otp.hbs +943 -943
- package/src/routes/activityLog.router.js +18 -0
- package/src/routes/gallery.routes.js +2 -1
- package/src/routes/internalTraxApi.router.js +2 -1
- package/src/routes/mobileTrax.routes.js +1 -0
- package/src/services/camera.service.js +14 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logger, signedUrl, fileUpload, getOtp, sendEmailWithSES, getUuid } from 'tango-app-api-middleware';
|
|
1
|
+
import { logger, signedUrl, fileUpload, getOtp, sendEmailWithSES, getUuid, insertOpenSearchData } from 'tango-app-api-middleware';
|
|
2
2
|
import * as processedchecklist from '../services/processedchecklist.services.js';
|
|
3
3
|
import * as processedtask from '../services/processedTaskList.service.js';
|
|
4
4
|
import * as PCLconfig from '../services/processedchecklistconfig.services.js';
|
|
@@ -25,6 +25,7 @@ import handlebars from 'handlebars';
|
|
|
25
25
|
dayjs.extend( customParseFormat );
|
|
26
26
|
dayjs.extend( timeZone );
|
|
27
27
|
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore.js';
|
|
28
|
+
import * as cameraService from '../services/camera.service.js';
|
|
28
29
|
dayjs.extend( isSameOrBefore );
|
|
29
30
|
|
|
30
31
|
export async function storeList( req, res ) {
|
|
@@ -262,12 +263,33 @@ export async function startChecklist( req, res ) {
|
|
|
262
263
|
getchecklist[index].questionAnswers[secIndex].questions = questions;
|
|
263
264
|
}
|
|
264
265
|
}
|
|
266
|
+
let openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
267
|
+
// console.log( 'openSearch', openSearch );
|
|
268
|
+
let inserttraxlogs = {
|
|
269
|
+
client_id: req.user.clientId,
|
|
270
|
+
createAt: new Date(),
|
|
271
|
+
sourceCheckList_id: getBeforeChecklist[0]?.sourceCheckList_id || '',
|
|
272
|
+
checkListName: getBeforeChecklist[0]?.checkListName || '',
|
|
273
|
+
fromCheckListName: '',
|
|
274
|
+
type: 'checkList',
|
|
275
|
+
action: 'start',
|
|
276
|
+
storeName: getBeforeChecklist[0]?.storeName || '',
|
|
277
|
+
store_id: getBeforeChecklist[0]?.store_id || '',
|
|
278
|
+
createdByEmail: getBeforeChecklist[0]?.userEmail || '',
|
|
279
|
+
createdBy: getBeforeChecklist[0]?.userName || '',
|
|
280
|
+
coverage: getBeforeChecklist[0]?.coverage || '',
|
|
281
|
+
logDetails: {},
|
|
282
|
+
userType: req.user.userType,
|
|
283
|
+
};
|
|
284
|
+
// let insertOS = await insertOpenSearchData( 'test-traxlogs', inserttraxlogs );
|
|
285
|
+
console.log( 'inserttraxlogs =>', inserttraxlogs );
|
|
286
|
+
insertOpenSearchData( openSearch.traxActivityLog, inserttraxlogs );
|
|
265
287
|
return res.sendSuccess( getchecklist );
|
|
266
288
|
} else {
|
|
267
289
|
return res.sendError( 'something went wrong please try again', 500 );
|
|
268
290
|
}
|
|
269
291
|
} catch ( e ) {
|
|
270
|
-
console.log( 'e =>', e );
|
|
292
|
+
// console.log( 'e =>', e );
|
|
271
293
|
logger.error( { function: 'startChecklist', error: e, body: req.body } );
|
|
272
294
|
return res.sendError( e, 500 );
|
|
273
295
|
}
|
|
@@ -433,6 +455,27 @@ export async function startTask( req, res ) {
|
|
|
433
455
|
};
|
|
434
456
|
await checklistLogs.create( logData );
|
|
435
457
|
|
|
458
|
+
let openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
459
|
+
// console.log( 'openSearch', openSearch );
|
|
460
|
+
let inserttraxlogs = {
|
|
461
|
+
client_id: req.user.clientId,
|
|
462
|
+
createAt: new Date(),
|
|
463
|
+
sourceCheckList_id: task.sourceCheckList_id || '',
|
|
464
|
+
checkListName: task.checkListName || '',
|
|
465
|
+
fromCheckListName: '',
|
|
466
|
+
type: 'task',
|
|
467
|
+
action: 'start',
|
|
468
|
+
storeName: task.storeName || '',
|
|
469
|
+
store_id: task.store_id || '',
|
|
470
|
+
createdByEmail: task.userEmail || '',
|
|
471
|
+
createdBy: task.userName || '',
|
|
472
|
+
coverage: task.coverage || '',
|
|
473
|
+
logDetails: {},
|
|
474
|
+
userType: req.user.userType,
|
|
475
|
+
};
|
|
476
|
+
// let insertOS = await insertOpenSearchData( 'test-traxlogs', inserttraxlogs );
|
|
477
|
+
console.log( 'inserttraxlogs =>', inserttraxlogs );
|
|
478
|
+
insertOpenSearchData( openSearch.traxActivityLog, inserttraxlogs );
|
|
436
479
|
return res.sendSuccess( getUpdatedTask );
|
|
437
480
|
} catch ( error ) {
|
|
438
481
|
logger.error( { function: 'startTask', error, body: req.body } );
|
|
@@ -1754,7 +1797,9 @@ export async function submitChecklist( req, res ) {
|
|
|
1754
1797
|
let flagCount = QuestionFlag( req, res );
|
|
1755
1798
|
updateData.questionFlag = flagCount;
|
|
1756
1799
|
updateData.submitTime_string = currentDateTime.format( 'hh:mm A, DD MMM YYYY' );
|
|
1757
|
-
|
|
1800
|
+
if ( requestData.deviceDetails && requestData.deviceDetails != '' ) {
|
|
1801
|
+
updateData.deviceDetails =JSON.parse( requestData.deviceDetails );
|
|
1802
|
+
}
|
|
1758
1803
|
if ( requestData.submittype == 'draft' ) {
|
|
1759
1804
|
logger.info( `v5 => Checklist Save => store Name: ${getchecklist[0].storeName}, User Email: ${getchecklist[0].userEmail}, Checklist Name: ${getchecklist[0].checkListName}` );
|
|
1760
1805
|
updateData.questionAnswers = requestData.questionAnswers;
|
|
@@ -1806,7 +1851,7 @@ export async function submitChecklist( req, res ) {
|
|
|
1806
1851
|
userName: getchecklist[0].userName || '',
|
|
1807
1852
|
coverage: getchecklist[0].coverage || '',
|
|
1808
1853
|
};
|
|
1809
|
-
console.log( 'logInsertData=>', logInsertData );
|
|
1854
|
+
// console.log( 'logInsertData=>', logInsertData );
|
|
1810
1855
|
await checklistLogs.create( logInsertData );
|
|
1811
1856
|
// let time = dayjs().format( 'HH:mm:ss' );
|
|
1812
1857
|
// let [ hours, minutes ] = time.split( ':' ).map( Number );
|
|
@@ -1841,6 +1886,28 @@ export async function submitChecklist( req, res ) {
|
|
|
1841
1886
|
// await detectionService.create( detectionData );
|
|
1842
1887
|
if ( requestData.submittype == 'submit' ) {
|
|
1843
1888
|
updateOpenSearch( req.user, requestData );
|
|
1889
|
+
let openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
1890
|
+
// console.log( 'openSearch', openSearch );
|
|
1891
|
+
let inserttraxlogs = {
|
|
1892
|
+
client_id: req.user.clientId,
|
|
1893
|
+
createAt: new Date(),
|
|
1894
|
+
sourceCheckList_id: getchecklist[0].sourceCheckList_id,
|
|
1895
|
+
checkListName: getchecklist[0].checkListName,
|
|
1896
|
+
type: 'checkList',
|
|
1897
|
+
action: requestData?.submittype === 'draft' ? 'save' : 'submit',
|
|
1898
|
+
storeName: getchecklist[0].storeName,
|
|
1899
|
+
store_id: getchecklist[0].store_id,
|
|
1900
|
+
userName: getchecklist[0].userName,
|
|
1901
|
+
userEmail: getchecklist[0].userEmail,
|
|
1902
|
+
createdByEmail: getchecklist[0].userEmail,
|
|
1903
|
+
createdBy: getchecklist[0].userName,
|
|
1904
|
+
coverage: getchecklist[0].coverage,
|
|
1905
|
+
checkListType: getchecklist[0].checkListType,
|
|
1906
|
+
logDetails: {},
|
|
1907
|
+
userType: req.user.userType,
|
|
1908
|
+
};
|
|
1909
|
+
console.log( 'inserttraxlogs =>', inserttraxlogs );
|
|
1910
|
+
insertOpenSearchData( openSearch.traxActivityLog, inserttraxlogs );
|
|
1844
1911
|
}
|
|
1845
1912
|
|
|
1846
1913
|
return res.sendSuccess( 'Checklist Updated Successfully' );
|
|
@@ -1911,6 +1978,10 @@ export async function submitTask( req, res ) {
|
|
|
1911
1978
|
questionFlag: QuestionFlag( req, res ),
|
|
1912
1979
|
};
|
|
1913
1980
|
|
|
1981
|
+
if ( requestData.deviceDetails && requestData.deviceDetails != '' ) {
|
|
1982
|
+
updateData.deviceDetails =JSON.parse( requestData.deviceDetails );
|
|
1983
|
+
}
|
|
1984
|
+
|
|
1914
1985
|
if ( submittype === 'draft' ) {
|
|
1915
1986
|
logger.info(
|
|
1916
1987
|
`v5 => Checklist Save => store Name: ${storeName}, User Email: ${userEmail}, Checklist Name: ${checkListName}`,
|
|
@@ -2007,6 +2078,28 @@ export async function submitTask( req, res ) {
|
|
|
2007
2078
|
|
|
2008
2079
|
if ( submittype == 'submit' ) {
|
|
2009
2080
|
updateOpenSearchTask( user, requestData );
|
|
2081
|
+
let openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
2082
|
+
// console.log( 'openSearch', openSearch );
|
|
2083
|
+
let inserttraxlogs = {
|
|
2084
|
+
client_id: req.user.clientId,
|
|
2085
|
+
createAt: new Date(),
|
|
2086
|
+
sourceCheckList_id: checklist.sourceCheckList_id,
|
|
2087
|
+
checkListName: checklist.checkListName,
|
|
2088
|
+
type: 'task',
|
|
2089
|
+
action: requestData?.submittype === 'draft' ? 'save' : 'submit',
|
|
2090
|
+
storeName: checklist.storeName,
|
|
2091
|
+
store_id: checklist.store_id,
|
|
2092
|
+
userName: checklist.userName,
|
|
2093
|
+
userEmail: checklist.userEmail,
|
|
2094
|
+
createdByEmail: checklist.userEmail,
|
|
2095
|
+
createdBy: checklist.userName,
|
|
2096
|
+
coverage: checklist.coverage,
|
|
2097
|
+
checkListType: checklist.checkListType,
|
|
2098
|
+
logDetails: {},
|
|
2099
|
+
userType: req.user.userType,
|
|
2100
|
+
};
|
|
2101
|
+
console.log( 'inserttraxlogs =>', inserttraxlogs );
|
|
2102
|
+
insertOpenSearchData( openSearch.traxActivityLog, inserttraxlogs );
|
|
2010
2103
|
}
|
|
2011
2104
|
|
|
2012
2105
|
return res.sendSuccess( 'Task Updated Successfully' );
|
|
@@ -2018,6 +2111,193 @@ export async function submitTask( req, res ) {
|
|
|
2018
2111
|
return res.sendError( error.message || 'Internal Server Error', 500 );
|
|
2019
2112
|
}
|
|
2020
2113
|
}
|
|
2114
|
+
export async function submiteyeTestTask( req, res ) {
|
|
2115
|
+
try {
|
|
2116
|
+
const { body: requestData, user } = req;
|
|
2117
|
+
const { processedcheckListId, date, submittype, currentTime, questionAnswers, streamId, qrCode } = requestData;
|
|
2118
|
+
// console.log( requestData );
|
|
2119
|
+
if ( !streamId ) {
|
|
2120
|
+
return res.sendError( 'streamId is required', 400 );
|
|
2121
|
+
}
|
|
2122
|
+
if ( !qrCode||qrCode=='' ) {
|
|
2123
|
+
return res.sendError( 'qrCode is required', 400 );
|
|
2124
|
+
}
|
|
2125
|
+
let findoldQrExists = await cameraService.findOne( { qrCode: qrCode } );
|
|
2126
|
+
if ( findoldQrExists ) {
|
|
2127
|
+
return res.sendError( 'Qr code already Exists', 400 );
|
|
2128
|
+
}
|
|
2129
|
+
let findQrExists = await cameraService.findOne( { streamName: streamId, qrCode: qrCode } );
|
|
2130
|
+
// console.log( findQrExists );
|
|
2131
|
+
if ( findQrExists ) {
|
|
2132
|
+
return res.sendError( 'Qr code already Exists', 400 );
|
|
2133
|
+
}
|
|
2134
|
+
|
|
2135
|
+
await cameraService.updateOne( { streamName: streamId }, { qrCode: qrCode, isEyeTestStream: true } );
|
|
2136
|
+
return res.sendSuccess( 'Qr code added successfully' );
|
|
2137
|
+
|
|
2138
|
+
const findQuery = [
|
|
2139
|
+
{
|
|
2140
|
+
$match: {
|
|
2141
|
+
_id: new ObjectId( processedcheckListId ),
|
|
2142
|
+
userId: user._id,
|
|
2143
|
+
date_string: date,
|
|
2144
|
+
},
|
|
2145
|
+
},
|
|
2146
|
+
];
|
|
2147
|
+
|
|
2148
|
+
const [ checklist ] = await processedTask.aggregate( findQuery );
|
|
2149
|
+
|
|
2150
|
+
if ( !checklist ) {
|
|
2151
|
+
return res.sendError( 'Task edited. Please fill again', 422 );
|
|
2152
|
+
}
|
|
2153
|
+
|
|
2154
|
+
// eslint-disable-next-line camelcase
|
|
2155
|
+
const { checklistStatus, storeName, userEmail, checkListName, store_id } = checklist;
|
|
2156
|
+
|
|
2157
|
+
if ( checklistStatus === 'open' ) {
|
|
2158
|
+
return res.sendError( 'Checklist is in open status. Please start.', 400 );
|
|
2159
|
+
}
|
|
2160
|
+
|
|
2161
|
+
if ( checklistStatus === 'submit' ) {
|
|
2162
|
+
return res.sendError( 'Checklist already submitted', 400 );
|
|
2163
|
+
}
|
|
2164
|
+
|
|
2165
|
+
const storeTimeZone = await storeService.findOne( { storeName }, { 'storeProfile.timeZone': 1 } );
|
|
2166
|
+
const currentDateTime = storeTimeZone?.storeProfile?.timeZone ?
|
|
2167
|
+
dayjs().tz( storeTimeZone.storeProfile.timeZone ) :
|
|
2168
|
+
dayjs();
|
|
2169
|
+
|
|
2170
|
+
const updateQuery = {
|
|
2171
|
+
_id: new ObjectId( processedcheckListId ),
|
|
2172
|
+
userId: user._id,
|
|
2173
|
+
date_string: date,
|
|
2174
|
+
};
|
|
2175
|
+
|
|
2176
|
+
// questionAnswers.forEach( ( section ) => {
|
|
2177
|
+
// section.questions.forEach( ( question ) => {
|
|
2178
|
+
// if ( question.redo === true ) {
|
|
2179
|
+
// question.redo = false;
|
|
2180
|
+
// }
|
|
2181
|
+
// } );
|
|
2182
|
+
// } );
|
|
2183
|
+
|
|
2184
|
+
const updateData = {
|
|
2185
|
+
questionAnswers,
|
|
2186
|
+
updatedAt: dayjs.utc( currentDateTime.format( 'hh:mm:ss A, DD MMM YYYY' ), 'hh:mm:ss A, DD MMM YYYY' ).format(),
|
|
2187
|
+
questionFlag: QuestionFlag( req, res ),
|
|
2188
|
+
};
|
|
2189
|
+
|
|
2190
|
+
if ( requestData.deviceDetails && requestData.deviceDetails != '' ) {
|
|
2191
|
+
updateData.deviceDetails =JSON.parse( requestData.deviceDetails );
|
|
2192
|
+
}
|
|
2193
|
+
|
|
2194
|
+
if ( submittype === 'draft' ) {
|
|
2195
|
+
logger.info(
|
|
2196
|
+
`v5 => Checklist Save => store Name: ${storeName}, User Email: ${userEmail}, Checklist Name: ${checkListName}`,
|
|
2197
|
+
);
|
|
2198
|
+
updateData.submitTime_string = currentDateTime.format( 'hh:mm A, DD MMM YYYY' );
|
|
2199
|
+
} else if ( submittype === 'submit' ) {
|
|
2200
|
+
logger.info(
|
|
2201
|
+
`v5 => Checklist Submit => store Name: ${storeName}, User Email: ${userEmail}, Checklist Name: ${checkListName}`,
|
|
2202
|
+
);
|
|
2203
|
+
Object.assign( updateData, {
|
|
2204
|
+
submitTime: dayjs.utc( currentDateTime.format( 'hh:mm:ss A, DD MMM YYYY' ), 'hh:mm:ss A, DD MMM YYYY' ).format(),
|
|
2205
|
+
checklistStatus: 'submit',
|
|
2206
|
+
submitMobileTime: currentTime,
|
|
2207
|
+
submitTime_string: currentDateTime.format( 'hh:mm A, DD MMM YYYY' ),
|
|
2208
|
+
} );
|
|
2209
|
+
}
|
|
2210
|
+
|
|
2211
|
+
const updateResult = await processedTask.updateOne( updateQuery, updateData );
|
|
2212
|
+
|
|
2213
|
+
if ( updateResult.modifiedCount > 0 ) {
|
|
2214
|
+
if ( submittype === 'submit' ) {
|
|
2215
|
+
const query1 = [
|
|
2216
|
+
{
|
|
2217
|
+
$match: {
|
|
2218
|
+
userId: user._id,
|
|
2219
|
+
sourceCheckList_id: checklist.sourceCheckList_id,
|
|
2220
|
+
checklistStatus: { $in: [ 'open', 'inprogress' ] },
|
|
2221
|
+
},
|
|
2222
|
+
},
|
|
2223
|
+
{
|
|
2224
|
+
$project: {
|
|
2225
|
+
_id: 1,
|
|
2226
|
+
date_iso: 1,
|
|
2227
|
+
date_string: 1,
|
|
2228
|
+
},
|
|
2229
|
+
},
|
|
2230
|
+
];
|
|
2231
|
+
|
|
2232
|
+
const processedTasksToDelete = await processedTask.aggregate( query1 );
|
|
2233
|
+
|
|
2234
|
+
if ( processedTasksToDelete?.length ) {
|
|
2235
|
+
const deleteIds = processedTasksToDelete?.filter( ( val ) => val?.date_string !== date )?.map( ( val ) => val?._id );
|
|
2236
|
+
|
|
2237
|
+
if ( deleteIds?.length ) {
|
|
2238
|
+
await processedTask.deleteMany( { _id: { $in: deleteIds } } );
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2241
|
+
} else if ( submittype === 'draft' ) {
|
|
2242
|
+
const query2 = [
|
|
2243
|
+
{
|
|
2244
|
+
$match: {
|
|
2245
|
+
_id: checklist.sourceCheckList_id,
|
|
2246
|
+
},
|
|
2247
|
+
},
|
|
2248
|
+
];
|
|
2249
|
+
const [ taskConfig ] = await taskConfigService.aggregate( query2 );
|
|
2250
|
+
|
|
2251
|
+
if ( taskConfig.scheduleEndTimeISO ) {
|
|
2252
|
+
const endDate = dayjs( taskConfig.scheduleEndTimeISO ).utc();
|
|
2253
|
+
const startDate = dayjs().add( 1, 'day' );
|
|
2254
|
+
|
|
2255
|
+
let currentDate = startDate;
|
|
2256
|
+
|
|
2257
|
+
while ( currentDate.isSameOrBefore( endDate ) ) {
|
|
2258
|
+
const updateDate = currentDate.format( 'YYYY-MM-DD' );
|
|
2259
|
+
|
|
2260
|
+
const updateQuery = {
|
|
2261
|
+
sourceCheckList_id: taskConfig._id,
|
|
2262
|
+
date_string: updateDate,
|
|
2263
|
+
userId: user._id,
|
|
2264
|
+
};
|
|
2265
|
+
|
|
2266
|
+
if ( Object.values( updateQuery ).length === 3 ) {
|
|
2267
|
+
await processedTask.updateOne( updateQuery, { questionAnswers, checklistStatus: 'inprogress' } );
|
|
2268
|
+
}
|
|
2269
|
+
|
|
2270
|
+
currentDate = currentDate.add( 1, 'day' );
|
|
2271
|
+
}
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
const logInsertData = {
|
|
2275
|
+
// eslint-disable-next-line camelcase
|
|
2276
|
+
store_id,
|
|
2277
|
+
storeName,
|
|
2278
|
+
action: submittype === 'draft' ? 'saved' : 'submitted',
|
|
2279
|
+
checklistId: checklist.sourceCheckList_id,
|
|
2280
|
+
processedChecklistId: checklist._id,
|
|
2281
|
+
type: checklist.checkListType,
|
|
2282
|
+
checkListName,
|
|
2283
|
+
client_id: user.clientId,
|
|
2284
|
+
redoStatus: requestData?.redoStatus ? true : false,
|
|
2285
|
+
};
|
|
2286
|
+
await checklistLogs.create( logInsertData );
|
|
2287
|
+
|
|
2288
|
+
if ( submittype == 'submit' ) {
|
|
2289
|
+
updateOpenSearchTask( user, requestData );
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2292
|
+
return res.sendSuccess( 'Task Updated Successfully' );
|
|
2293
|
+
} else {
|
|
2294
|
+
return res.sendError( 'Something went wrong. Please try again', 500 );
|
|
2295
|
+
}
|
|
2296
|
+
} catch ( error ) {
|
|
2297
|
+
logger.error( { function: 'submiteyeTestTask', error, body: req.body } );
|
|
2298
|
+
return res.sendError( error.message || 'Internal Server Error', 500 );
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2021
2301
|
|
|
2022
2302
|
|
|
2023
2303
|
async function updateOpenSearch( user, data ) {
|
|
@@ -2289,7 +2569,7 @@ export async function dashboardv1( req, res ) {
|
|
|
2289
2569
|
|
|
2290
2570
|
return res.sendSuccess( totalResult );
|
|
2291
2571
|
} catch ( e ) {
|
|
2292
|
-
console.log( 'v1 =>', e );
|
|
2572
|
+
// console.log( 'v1 =>', e );
|
|
2293
2573
|
logger.error( { function: 'dashboardv1', error: e, body: req.body } );
|
|
2294
2574
|
return res.sendError( e, 500 );
|
|
2295
2575
|
}
|
|
@@ -2464,6 +2744,7 @@ export async function checklistv1( req, res ) {
|
|
|
2464
2744
|
client_id: { $ifNull: [ '$client_id', '' ] },
|
|
2465
2745
|
coverage: { $ifNull: [ '$coverage', '' ] },
|
|
2466
2746
|
taskType: { $ifNull: [ '$planoType', '' ] },
|
|
2747
|
+
streamId: { $ifNull: [ '$streamId', '' ] },
|
|
2467
2748
|
},
|
|
2468
2749
|
},
|
|
2469
2750
|
];
|
|
@@ -2472,8 +2753,8 @@ export async function checklistv1( req, res ) {
|
|
|
2472
2753
|
};
|
|
2473
2754
|
|
|
2474
2755
|
const [ checklistResult, taskResult ] = await Promise.allSettled( [
|
|
2475
|
-
processedchecklist.aggregate( buildPipeline( [ { checkListType: 'custom' } ], { isPlano: 1, planoId: 1, planoType: 1 } ) ),
|
|
2476
|
-
processedTask.aggregate( buildPipeline( [], { isPlano: 1, planoId: 1, planoType: 1 } ) ),
|
|
2756
|
+
processedchecklist.aggregate( buildPipeline( [ { checkListType: 'custom' } ], { isPlano: 1, planoId: 1, planoType: 1, floorId: 1 } ) ),
|
|
2757
|
+
processedTask.aggregate( buildPipeline( [], { isPlano: 1, planoId: 1, planoType: 1, floorId: 1 } ) ),
|
|
2477
2758
|
] );
|
|
2478
2759
|
|
|
2479
2760
|
const checklistData = checklistResult.status === 'fulfilled' ? checklistResult.value : [];
|
|
@@ -2559,6 +2840,8 @@ export async function questionList( req, res ) {
|
|
|
2559
2840
|
redoStatus: { $ifNull: [ '$redoStatus', false ] },
|
|
2560
2841
|
rawImageUpload: { $ifNull: [ '$rawImageUpload', false ] },
|
|
2561
2842
|
rawVideoUpload: { $ifNull: [ '$rawVideoUpload', false ] },
|
|
2843
|
+
taskType: { $ifNull: [ '$planoType', '' ] },
|
|
2844
|
+
streamId: { $ifNull: [ '$streamId', '' ] },
|
|
2562
2845
|
},
|
|
2563
2846
|
} );
|
|
2564
2847
|
|
|
@@ -3248,7 +3531,7 @@ export const sendSignInOtpEmail = async ( emailVars ) => {
|
|
|
3248
3531
|
const result = await sendEmailWithSES( emailVars.email, subject, html, attachments, ses.adminEmail );
|
|
3249
3532
|
return result;
|
|
3250
3533
|
} catch ( error ) {
|
|
3251
|
-
logger.error( { error: error, function: 'sendSignInOtpEmail', body:
|
|
3534
|
+
logger.error( { error: error, function: 'sendSignInOtpEmail', body: emailVars } );
|
|
3252
3535
|
return error;
|
|
3253
3536
|
}
|
|
3254
3537
|
};
|
|
@@ -3399,8 +3682,7 @@ export async function clientConfig( req, res ) {
|
|
|
3399
3682
|
try {
|
|
3400
3683
|
let requestData = req.body;
|
|
3401
3684
|
if ( requestData.clientId && requestData.clientId !='' ) {
|
|
3402
|
-
let getClientData = await clientService.findOne( { clientId: requestData.clientId }, { traxRAWImageUpload: 1, clientId: 1, clientName: 1, traxBlockMobileTimeUpdate: 1, traxSectionSave: 1 } );
|
|
3403
|
-
// console.log( ' getClientData=>', getClientData );
|
|
3685
|
+
let getClientData = await clientService.findOne( { clientId: requestData.clientId }, { traxRAWImageUpload: 1, clientId: 1, clientName: 1, traxBlockMobileTimeUpdate: 1, traxSectionSave: 1, isCrestPlanogram: 1, isTangoPlanogram: 1 } );
|
|
3404
3686
|
if ( getClientData ) {
|
|
3405
3687
|
return res.sendSuccess( getClientData );
|
|
3406
3688
|
} else {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { download, logger } from 'tango-app-api-middleware'; // getChecklistUsers
|
|
1
|
+
import { download, logger, convertSecondstoTimeFormat } from 'tango-app-api-middleware'; // getChecklistUsers
|
|
2
2
|
import { aggregate } from '../services/processedchecklist.services.js';
|
|
3
3
|
import dayjs from 'dayjs';
|
|
4
4
|
import * as processedchecklistService from '../services/processedchecklist.services.js';
|
|
@@ -2011,6 +2011,10 @@ export const flagChecklistCardsV1 = async ( req, res ) => {
|
|
|
2011
2011
|
let resultData = await LamdaServiceCall( LamdaURL, reqestData );
|
|
2012
2012
|
if ( resultData ) {
|
|
2013
2013
|
if ( resultData.status_code == '200' ) {
|
|
2014
|
+
if ( resultData.customerunattendedCards && resultData.customerunattendedCards.timeTakentoAssistsec && resultData.customerunattendedCards.timeTakentoAssistsec.secs ) {
|
|
2015
|
+
resultData.customerunattendedCards.timeTakentoAssist_string = await convertSecondstoTimeFormat( resultData.customerunattendedCards.timeTakentoAssistsec.secs );
|
|
2016
|
+
resultData.customerunattendedCards.timeSpentwithCustomer_string = await convertSecondstoTimeFormat( resultData.customerunattendedCards.timeSpentwithCustomersec.secs );
|
|
2017
|
+
}
|
|
2014
2018
|
return res.sendSuccess( resultData );
|
|
2015
2019
|
} else {
|
|
2016
2020
|
return res.sendError( 'No Content', 204 );
|
|
@@ -2493,7 +2497,7 @@ export const flagChecklistTableV1 = async ( req, res ) => {
|
|
|
2493
2497
|
if ( resultData ) {
|
|
2494
2498
|
if ( resultData.status_code == '200' ) {
|
|
2495
2499
|
const exportdata = [];
|
|
2496
|
-
console.log( resultData );
|
|
2500
|
+
// console.log( resultData );
|
|
2497
2501
|
if ( reqestData.ChecklistType==='scrum'||reqestData.ChecklistType==='cleaning' ) {
|
|
2498
2502
|
reqestData.ChecklistType = 'scrumdetection';
|
|
2499
2503
|
}
|
|
@@ -2515,7 +2519,7 @@ export const flagChecklistTableV1 = async ( req, res ) => {
|
|
|
2515
2519
|
return res.sendError( 'No Content', 204 );
|
|
2516
2520
|
}
|
|
2517
2521
|
}
|
|
2518
|
-
console.log( reqestData );
|
|
2522
|
+
// console.log( reqestData );
|
|
2519
2523
|
|
|
2520
2524
|
let LamdaURL = 'https://bnauly42yuztzrgtttodzt3bcm0oqrsi.lambda-url.ap-south-1.on.aws/';
|
|
2521
2525
|
let resultData = await LamdaServiceCall( LamdaURL, reqestData );
|