tango-app-api-task 3.2.1-beta-14 → 3.2.1-beta-15
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
|
@@ -8,6 +8,7 @@ import * as storeService from '../service/store.service.js';
|
|
|
8
8
|
import * as traxApprover from '../service/approver.service.js';
|
|
9
9
|
import * as processedChecklist from '../service/processedChecklist.service.js';
|
|
10
10
|
import * as checklistassignconfigModel from '../service/checklistAssign.service.js';
|
|
11
|
+
import * as clusterModel from '../service/cluster.service.js';
|
|
11
12
|
// import * as domainService from '../service/domain.service.js';
|
|
12
13
|
import mongoose from 'mongoose';
|
|
13
14
|
const ObjectId = mongoose.Types.ObjectId;
|
|
@@ -19,7 +20,7 @@ dayjs.extend( customParseFormat );
|
|
|
19
20
|
import * as taskProcessedConfigService from '../service/processedTaskConfig.service.js';
|
|
20
21
|
import * as taskProcessedService from '../service/processedTaskList.service.js';
|
|
21
22
|
import * as ApproverModel from '../service/approver.service.js';
|
|
22
|
-
import { createTeamsModel, findOneTeams, updateOneTeamModel } from '../service/teams.service.js';
|
|
23
|
+
import { createTeamsModel, findOneTeams, updateOneTeamModel, findteams } from '../service/teams.service.js';
|
|
23
24
|
import { sendPushNotification } from 'tango-app-api-middleware';
|
|
24
25
|
async function LamdaServiceCall( url, data ) {
|
|
25
26
|
try {
|
|
@@ -2089,8 +2090,6 @@ export const duplicateChecklist = async ( req, res ) => {
|
|
|
2089
2090
|
export async function teamMigrations( req, res ) {
|
|
2090
2091
|
try {
|
|
2091
2092
|
let input = [];
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
2093
|
for ( let user of input ) {
|
|
2095
2094
|
let userexits = await userService.findOne( { email: user.userEmail } );
|
|
2096
2095
|
if ( userexits ) {
|
|
@@ -2156,7 +2155,55 @@ export async function teamMigrations( req, res ) {
|
|
|
2156
2155
|
return res.sendError( error, 500 );
|
|
2157
2156
|
}
|
|
2158
2157
|
}
|
|
2159
|
-
|
|
2158
|
+
export async function clusterMigrations( req, res ) {
|
|
2159
|
+
try {
|
|
2160
|
+
let input = [
|
|
2161
|
+
];
|
|
2162
|
+
for ( let user of input ) {
|
|
2163
|
+
let userexits = await userService.findOne( { email: user.AOMsmailID } );
|
|
2164
|
+
if ( userexits ) {
|
|
2165
|
+
let findStore = await storeService.findOne( { storeName: user.FacilityCode } );
|
|
2166
|
+
if ( findStore ) {
|
|
2167
|
+
let clusterExists = await clusterModel.findOneCluster( { clusterName: user.AomName } );
|
|
2168
|
+
if ( clusterExists ) {
|
|
2169
|
+
let data = {
|
|
2170
|
+
storeId: findStore.storeId,
|
|
2171
|
+
store: findStore._id,
|
|
2172
|
+
};
|
|
2173
|
+
let updatecluster = await clusterModel.updateCluster( { clusterName: user.AomName }, { $push: { stores: data } } );
|
|
2174
|
+
console.log( updatecluster );
|
|
2175
|
+
} else {
|
|
2176
|
+
let payload = {
|
|
2177
|
+
'clusterName': user.AomName,
|
|
2178
|
+
'clientId': '11',
|
|
2179
|
+
'description': user.AomName,
|
|
2180
|
+
'stores': [
|
|
2181
|
+
{
|
|
2182
|
+
storeId: findStore.storeId,
|
|
2183
|
+
store: findStore._id,
|
|
2184
|
+
},
|
|
2185
|
+
],
|
|
2186
|
+
'status': 'active',
|
|
2187
|
+
'Teamlead': [
|
|
2188
|
+
{
|
|
2189
|
+
email: userexits.email,
|
|
2190
|
+
userId: userexits._id,
|
|
2191
|
+
},
|
|
2192
|
+
],
|
|
2193
|
+
'users': [],
|
|
2194
|
+
};
|
|
2195
|
+
let createcluster = await clusterModel.createclusterModel( payload );
|
|
2196
|
+
console.log( createcluster );
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
res.sendSuccess( 'completed' );
|
|
2202
|
+
} catch ( error ) {
|
|
2203
|
+
logger.error( 'duplicateTask =>', error );
|
|
2204
|
+
return res.sendError( error, 500 );
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2160
2207
|
export async function createAiChecklist( req, res ) {
|
|
2161
2208
|
try {
|
|
2162
2209
|
let inputBody = req.body;
|
|
@@ -2309,10 +2356,220 @@ export async function createAiChecklist( req, res ) {
|
|
|
2309
2356
|
return res.sendError( e, 500 );
|
|
2310
2357
|
}
|
|
2311
2358
|
}
|
|
2359
|
+
export async function createAiTaskNew( req, res ) {
|
|
2360
|
+
try {
|
|
2361
|
+
let inputBody = req.body;
|
|
2362
|
+
console.log( inputBody );
|
|
2363
|
+
inputBody.clientId = 11;
|
|
2364
|
+
inputBody.taskDescription = '';
|
|
2365
|
+
let userId;
|
|
2366
|
+
let storeDetails = await storeService.findOne( { storeName: inputBody.storeName, clientId: inputBody.clientId, status: 'active' }, { storeId: 1, storeName: 1, storeProfile: 1 } );
|
|
2367
|
+
if ( !storeDetails ) {
|
|
2368
|
+
return res.sendError( 'Store Not Found', 500 );
|
|
2369
|
+
}
|
|
2370
|
+
console.log( storeDetails );
|
|
2371
|
+
let url = JSON.parse( process.env.LAMBDAURL );
|
|
2372
|
+
let checklistId = url.dailystoreChecklistId;
|
|
2373
|
+
let finduser = await checklistassignconfigModel.findOne( { checkListId: new mongoose.Types.ObjectId( checklistId ), store_id: storeDetails.storeId } );
|
|
2374
|
+
console.log( finduser );
|
|
2375
|
+
if ( !finduser ) {
|
|
2376
|
+
return res.sendError( 'No user Found For this store', 500 );
|
|
2377
|
+
}
|
|
2378
|
+
userId = finduser.userId;
|
|
2379
|
+
inputBody.userName = finduser.userName;
|
|
2380
|
+
inputBody.userEmail = finduser.userEmail;
|
|
2381
|
+
|
|
2382
|
+
|
|
2383
|
+
let teamList = await findteams( { users: { $elemMatch: { email: finduser.userEmail } } } );
|
|
2384
|
+
console.log( teamList );
|
|
2385
|
+
inputBody.approver = '';
|
|
2386
|
+
for ( let team of teamList ) {
|
|
2387
|
+
for ( let user of team.Teamlead ) {
|
|
2388
|
+
inputBody.approver = user.email + ',' + inputBody.approver;
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
inputBody.approver = inputBody.approver.replace( /,$/, '' );
|
|
2392
|
+
console.log( inputBody?.approver );
|
|
2393
|
+
// return;
|
|
2394
|
+
|
|
2395
|
+
|
|
2396
|
+
// let title = `New Task Alert ${inputBody.taskName}-${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )}`;
|
|
2397
|
+
let time = inputBody?.scheduleEndTime || '11:59 PM';
|
|
2398
|
+
let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
|
|
2399
|
+
// let description = `A new task has been assigned to ${storeDetails.storeName}. Please complete it before the due date of ${date}.`;
|
|
2400
|
+
// if ( userDetails&&userDetails.fcmToken ) {
|
|
2401
|
+
// const fcmToken = userDetails.fcmToken;
|
|
2402
|
+
// await sendPushNotification( title, description, fcmToken );
|
|
2403
|
+
// }
|
|
2404
|
+
const inputDateTime = dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' );
|
|
2405
|
+
const currentTime = dayjs.utc();
|
|
2406
|
+
if ( inputDateTime.isBefore( currentTime ) ) {
|
|
2407
|
+
return res.sendError( 'The input date-time is before the current time.', 500 );
|
|
2408
|
+
}
|
|
2409
|
+
|
|
2410
|
+
let approverList = inputBody?.approver.split( ',' );
|
|
2411
|
+
console.log( approverList );
|
|
2412
|
+
|
|
2413
|
+
let userAdmin = await userService.find( { clientId: inputBody.clientId, email: { $in: approverList }, userType: 'client', isActive: true }, { name: '$userName', email: 1 } );
|
|
2414
|
+
console.log( userAdmin );
|
|
2415
|
+
if ( userAdmin && userAdmin.length === 0 ) {
|
|
2416
|
+
userAdmin = await userService.find( { clientId: inputBody.clientId, email: 'rohit.chawla@lenskart.com', userType: 'client', isActive: true }, { name: '$userName', email: 1 } );
|
|
2417
|
+
}
|
|
2418
|
+
|
|
2419
|
+
let creator = await userService.find( { clientId: inputBody.clientId, email: 'rohit.chawla@lenskart.com', userType: 'client', isActive: true } );
|
|
2420
|
+
if ( creator && creator.length === 0 ) {
|
|
2421
|
+
return res.sendError( 'Invalid Creator Details', 500 );
|
|
2422
|
+
}
|
|
2423
|
+
if ( req.files && req.files.referenceImage && req.files.referenceImage.length > 3 ) {
|
|
2424
|
+
return res.sendError( 'Maximum 3 referenceImage only allowed', 500 );
|
|
2425
|
+
}
|
|
2426
|
+
|
|
2427
|
+
let data = {
|
|
2428
|
+
checkListName: `${inputBody.taskName}-${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )}`,
|
|
2429
|
+
checkListDescription: inputBody.taskDescription,
|
|
2430
|
+
createdBy: creator[0]._id,
|
|
2431
|
+
createdByName: creator[0].userName,
|
|
2432
|
+
publish: true,
|
|
2433
|
+
questionCount: 1,
|
|
2434
|
+
storeCount: 1,
|
|
2435
|
+
scheduleDate: date,
|
|
2436
|
+
scheduleEndTime: time,
|
|
2437
|
+
scheduleEndTimeISO: dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' ).format(),
|
|
2438
|
+
priorityType: 'high',
|
|
2439
|
+
client_id: inputBody.clientId,
|
|
2440
|
+
checkListType: 'task',
|
|
2441
|
+
publishDate: new Date(),
|
|
2442
|
+
locationCount: 1,
|
|
2443
|
+
...( inputBody?.checkListId ) ? { referenceCheckListId: inputBody?.checkListId } : {},
|
|
2444
|
+
};
|
|
2445
|
+
|
|
2446
|
+
|
|
2447
|
+
data['approver'] = userAdmin;
|
|
2448
|
+
console.log( data );
|
|
2449
|
+
|
|
2450
|
+
let answer = await findAnswer( inputBody?.answerType );
|
|
2451
|
+
if ( answer.length == 0 ) {
|
|
2452
|
+
return res.sendError( 'please enter Valid AnswerType', 500 );
|
|
2453
|
+
}
|
|
2454
|
+
if ( inputBody?.answerType === 'multiplechoicesingle' || inputBody?.answerType === 'multiplechoicemultiple' ) {
|
|
2455
|
+
console.log( inputBody?.options );
|
|
2456
|
+
if ( inputBody?.options && inputBody?.options.length > 0 ) {
|
|
2457
|
+
let optionsResult = [];
|
|
2458
|
+
let optionList = inputBody?.options.split( ',' );
|
|
2459
|
+
for ( let option of optionList ) {
|
|
2460
|
+
let optiondata = {
|
|
2461
|
+
'answer': '',
|
|
2462
|
+
'sopFlag': false,
|
|
2463
|
+
'validation': false,
|
|
2464
|
+
'validationType': '',
|
|
2465
|
+
'referenceImage': [],
|
|
2466
|
+
'runAI': false,
|
|
2467
|
+
'allowUploadfromGallery': false,
|
|
2468
|
+
'descriptivetype': '',
|
|
2469
|
+
'showLinked': false,
|
|
2470
|
+
'linkedQuestion': 0,
|
|
2471
|
+
'nestedQuestion': [],
|
|
2472
|
+
};
|
|
2473
|
+
optiondata.answer = option;
|
|
2474
|
+
optionsResult.push( optiondata );
|
|
2475
|
+
}
|
|
2476
|
+
answer = optionsResult;
|
|
2477
|
+
} else {
|
|
2478
|
+
return res.sendError( 'please enter Valid Options', 500 );
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2481
|
+
|
|
2482
|
+
|
|
2483
|
+
let response = await taskService.create( data );
|
|
2484
|
+
if ( response?.approver.length ) {
|
|
2485
|
+
let inputData = [];
|
|
2486
|
+
response?.approver.forEach( ( ele ) => {
|
|
2487
|
+
console.log( data );
|
|
2488
|
+
inputData.push( {
|
|
2489
|
+
userEmail: ele.email,
|
|
2490
|
+
checkListId: response._id,
|
|
2491
|
+
type: 'task',
|
|
2492
|
+
client_id: inputBody.clientId,
|
|
2493
|
+
checkListName: data?.checkListName || '',
|
|
2494
|
+
} );
|
|
2495
|
+
} );
|
|
2496
|
+
console.log( inputData );
|
|
2497
|
+
await traxApprover.insertMany( inputData );
|
|
2498
|
+
}
|
|
2499
|
+
|
|
2500
|
+
if ( response?._id ) {
|
|
2501
|
+
let question = [
|
|
2502
|
+
{
|
|
2503
|
+
'qno': 1,
|
|
2504
|
+
'qname': inputBody.question,
|
|
2505
|
+
'answerType': inputBody?.answerType || 'yes/no',
|
|
2506
|
+
'runAI': false,
|
|
2507
|
+
'runAIDescription': '',
|
|
2508
|
+
'allowUploadfromGallery': false,
|
|
2509
|
+
'linkType': false,
|
|
2510
|
+
'questionReferenceImage': [],
|
|
2511
|
+
'answers': answer,
|
|
2512
|
+
'descriptivetype': 'text',
|
|
2513
|
+
},
|
|
2514
|
+
];
|
|
2515
|
+
|
|
2516
|
+
|
|
2517
|
+
if ( req.files && req.files.referenceImage && req.files.referenceImage.length ) {
|
|
2518
|
+
let images = [];
|
|
2519
|
+
console.log( req.files.referenceImage.length );
|
|
2520
|
+
|
|
2521
|
+
|
|
2522
|
+
for ( let image of req.files.referenceImage ) {
|
|
2523
|
+
let uplaodedImage = await uploadmultiImage( image );
|
|
2524
|
+
let imgUrl = decodeURIComponent( uplaodedImage.imgUrl.split( '?' )[0] );
|
|
2525
|
+
let url = imgUrl.split( '/' );
|
|
2526
|
+
if ( url.includes( 'https:' ) || url.includes( 'http:' ) ) {
|
|
2527
|
+
url.splice( 0, 3 );
|
|
2528
|
+
}
|
|
2529
|
+
images.push( url.join( '/' ) );
|
|
2530
|
+
}
|
|
2531
|
+
question[0].questionReferenceImage = images;
|
|
2532
|
+
}
|
|
2533
|
+
if ( inputBody?.answerType === 'image' || inputBody?.answerType === 'descriptiveImage' || inputBody?.answerType === 'multipleImage' ) {
|
|
2534
|
+
answer[0].referenceImage = question[0].questionReferenceImage;
|
|
2535
|
+
}
|
|
2536
|
+
|
|
2537
|
+
|
|
2538
|
+
question = {
|
|
2539
|
+
checkListId: response?._id,
|
|
2540
|
+
question: question,
|
|
2541
|
+
section: 'Section 1',
|
|
2542
|
+
checkList: data.checkListName,
|
|
2543
|
+
client_id: inputBody.clientId,
|
|
2544
|
+
};
|
|
2545
|
+
await taskQuestionService.create( question );
|
|
2546
|
+
|
|
2547
|
+
let userDetails = {
|
|
2548
|
+
userName: inputBody.userName,
|
|
2549
|
+
userEmail: inputBody.userEmail,
|
|
2550
|
+
store_id: storeDetails.storeId,
|
|
2551
|
+
storeName: storeDetails.storeName,
|
|
2552
|
+
city: storeDetails?.storeProfile?.city,
|
|
2553
|
+
checkFlag: true,
|
|
2554
|
+
checkListId: response?._id,
|
|
2555
|
+
checkListName: data.checkListName,
|
|
2556
|
+
client_id: inputBody.clientId,
|
|
2557
|
+
userId: userId,
|
|
2558
|
+
};
|
|
2559
|
+
console.log( userDetails );
|
|
2560
|
+
await taskAssignService.create( userDetails );
|
|
2561
|
+
await insertSingleProcessData( response?._id );
|
|
2562
|
+
return res.sendSuccess( 'Task created successfully' );
|
|
2563
|
+
}
|
|
2564
|
+
} catch ( e ) {
|
|
2565
|
+
logger.error( { function: 'createAiTaskNew', error: e } );
|
|
2566
|
+
return res.sendError( e, 500 );
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2312
2569
|
export async function createAiTask( req, res ) {
|
|
2313
2570
|
try {
|
|
2314
2571
|
let inputBody = req.body;
|
|
2315
|
-
inputBody.clientId= 11;
|
|
2572
|
+
inputBody.clientId = 11;
|
|
2316
2573
|
inputBody.taskDescription = '';
|
|
2317
2574
|
let userId;
|
|
2318
2575
|
let storeDetails = await storeService.findOne( { storeName: inputBody.storeName, clientId: inputBody.clientId, status: 'active' }, { storeId: 1, storeName: 1, storeProfile: 1 } );
|
|
@@ -2320,7 +2577,9 @@ export async function createAiTask( req, res ) {
|
|
|
2320
2577
|
return res.sendError( 'Store Not Found', 500 );
|
|
2321
2578
|
}
|
|
2322
2579
|
console.log( storeDetails );
|
|
2323
|
-
let
|
|
2580
|
+
let url = JSON.parse( process.env.LAMBDAURL );
|
|
2581
|
+
let checklistId = url.dailystoreChecklistId;
|
|
2582
|
+
let finduser = await checklistassignconfigModel.findOne( { checkListId: new mongoose.Types.ObjectId( checklistId ), store_id: storeDetails.storeId } );
|
|
2324
2583
|
console.log( finduser );
|
|
2325
2584
|
if ( !finduser ) {
|
|
2326
2585
|
return res.sendError( 'No user Found For this store', 500 );
|
|
@@ -2329,6 +2588,7 @@ export async function createAiTask( req, res ) {
|
|
|
2329
2588
|
inputBody.userName = finduser.userName;
|
|
2330
2589
|
inputBody.userEmail = finduser.userEmail;
|
|
2331
2590
|
|
|
2591
|
+
|
|
2332
2592
|
// let title = `New Task Alert ${inputBody.taskName}-${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )}`;
|
|
2333
2593
|
let time = inputBody?.scheduleEndTime || '11:59 PM';
|
|
2334
2594
|
let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
|
|
@@ -2348,15 +2608,15 @@ export async function createAiTask( req, res ) {
|
|
|
2348
2608
|
|
|
2349
2609
|
let userAdmin = await userService.find( { clientId: inputBody.clientId, email: { $in: approverList }, userType: 'client', isActive: true }, { name: '$userName', email: 1 } );
|
|
2350
2610
|
console.log( userAdmin );
|
|
2351
|
-
if ( userAdmin&&userAdmin.length===0 ) {
|
|
2611
|
+
if ( userAdmin && userAdmin.length === 0 ) {
|
|
2352
2612
|
return res.sendError( 'Invalid Approver Details', 500 );
|
|
2353
2613
|
}
|
|
2354
2614
|
|
|
2355
2615
|
let creator = await userService.find( { clientId: inputBody.clientId, email: { $in: inputBody.creator }, userType: 'client', isActive: true } );
|
|
2356
|
-
if ( creator&&creator.length===0 ) {
|
|
2616
|
+
if ( creator && creator.length === 0 ) {
|
|
2357
2617
|
return res.sendError( 'Invalid Creator Details', 500 );
|
|
2358
2618
|
}
|
|
2359
|
-
if ( req.files&&req.files.referenceImage&& req.files.referenceImage.length>3 ) {
|
|
2619
|
+
if ( req.files && req.files.referenceImage && req.files.referenceImage.length > 3 ) {
|
|
2360
2620
|
return res.sendError( 'Maximum 3 referenceImage only allowed', 500 );
|
|
2361
2621
|
}
|
|
2362
2622
|
|
|
@@ -2384,12 +2644,12 @@ export async function createAiTask( req, res ) {
|
|
|
2384
2644
|
console.log( data );
|
|
2385
2645
|
|
|
2386
2646
|
let answer = await findAnswer( inputBody?.answerType );
|
|
2387
|
-
if ( answer.length==0 ) {
|
|
2647
|
+
if ( answer.length == 0 ) {
|
|
2388
2648
|
return res.sendError( 'please enter Valid AnswerType', 500 );
|
|
2389
2649
|
}
|
|
2390
|
-
if ( inputBody?.answerType === 'multiplechoicesingle'||inputBody?.answerType === 'multiplechoicemultiple' ) {
|
|
2650
|
+
if ( inputBody?.answerType === 'multiplechoicesingle' || inputBody?.answerType === 'multiplechoicemultiple' ) {
|
|
2391
2651
|
console.log( inputBody?.options );
|
|
2392
|
-
if ( inputBody?.options&& inputBody?.options.length>0 ) {
|
|
2652
|
+
if ( inputBody?.options && inputBody?.options.length > 0 ) {
|
|
2393
2653
|
let optionsResult = [];
|
|
2394
2654
|
let optionList = inputBody?.options.split( ',' );
|
|
2395
2655
|
for ( let option of optionList ) {
|
|
@@ -2409,7 +2669,7 @@ export async function createAiTask( req, res ) {
|
|
|
2409
2669
|
optiondata.answer = option;
|
|
2410
2670
|
optionsResult.push( optiondata );
|
|
2411
2671
|
}
|
|
2412
|
-
answer =optionsResult;
|
|
2672
|
+
answer = optionsResult;
|
|
2413
2673
|
} else {
|
|
2414
2674
|
return res.sendError( 'please enter Valid Options', 500 );
|
|
2415
2675
|
}
|
|
@@ -2450,13 +2710,13 @@ export async function createAiTask( req, res ) {
|
|
|
2450
2710
|
];
|
|
2451
2711
|
|
|
2452
2712
|
|
|
2453
|
-
if ( req.files&& req.files.referenceImage&&req.files.referenceImage.length ) {
|
|
2713
|
+
if ( req.files && req.files.referenceImage && req.files.referenceImage.length ) {
|
|
2454
2714
|
let images = [];
|
|
2455
2715
|
console.log( req.files.referenceImage.length );
|
|
2456
2716
|
|
|
2457
2717
|
|
|
2458
2718
|
for ( let image of req.files.referenceImage ) {
|
|
2459
|
-
let uplaodedImage =await uploadmultiImage( image );
|
|
2719
|
+
let uplaodedImage = await uploadmultiImage( image );
|
|
2460
2720
|
let imgUrl = decodeURIComponent( uplaodedImage.imgUrl.split( '?' )[0] );
|
|
2461
2721
|
let url = imgUrl.split( '/' );
|
|
2462
2722
|
if ( url.includes( 'https:' ) || url.includes( 'http:' ) ) {
|
|
@@ -2466,7 +2726,7 @@ export async function createAiTask( req, res ) {
|
|
|
2466
2726
|
}
|
|
2467
2727
|
question[0].questionReferenceImage = images;
|
|
2468
2728
|
}
|
|
2469
|
-
if ( inputBody?.answerType === 'image'||inputBody?.answerType === 'descriptiveImage'||inputBody?.answerType === 'multipleImage' ) {
|
|
2729
|
+
if ( inputBody?.answerType === 'image' || inputBody?.answerType === 'descriptiveImage' || inputBody?.answerType === 'multipleImage' ) {
|
|
2470
2730
|
answer[0].referenceImage = question[0].questionReferenceImage;
|
|
2471
2731
|
}
|
|
2472
2732
|
|
|
@@ -2498,12 +2758,11 @@ export async function createAiTask( req, res ) {
|
|
|
2498
2758
|
return res.sendSuccess( 'Task created successfully' );
|
|
2499
2759
|
}
|
|
2500
2760
|
} catch ( e ) {
|
|
2501
|
-
logger.error( { function: createAiChecklist, error: e } );
|
|
2761
|
+
logger.error( { function: 'createAiChecklist', error: e } );
|
|
2502
2762
|
return res.sendError( e, 500 );
|
|
2503
2763
|
}
|
|
2504
2764
|
}
|
|
2505
2765
|
|
|
2506
|
-
|
|
2507
2766
|
async function findAnswer( type ) {
|
|
2508
2767
|
let answer = [];
|
|
2509
2768
|
|
package/src/dtos/task.dto.js
CHANGED
|
@@ -11,9 +11,21 @@ export const aitaskvalidationSchema = Joi.object().keys( {
|
|
|
11
11
|
options: Joi.string().optional(),
|
|
12
12
|
scheduleDate: Joi.string().optional(),
|
|
13
13
|
scheduleEndTime: Joi.string().optional(),
|
|
14
|
-
|
|
14
|
+
} );
|
|
15
|
+
export const aitaskvalidationSchemanew = Joi.object().keys( {
|
|
16
|
+
storeName: Joi.string().required(),
|
|
17
|
+
taskName: Joi.string().required(),
|
|
18
|
+
question: Joi.string().required(),
|
|
19
|
+
answerType: Joi.string().required(),
|
|
20
|
+
options: Joi.string().optional(),
|
|
21
|
+
scheduleDate: Joi.string().optional(),
|
|
22
|
+
scheduleEndTime: Joi.string().optional(),
|
|
23
|
+
referenceImage: Joi.string().optional(),
|
|
15
24
|
} );
|
|
16
25
|
|
|
17
26
|
export const aitaskvalidation = {
|
|
18
27
|
body: aitaskvalidationSchema,
|
|
19
28
|
};
|
|
29
|
+
export const aitaskvalidationNew = {
|
|
30
|
+
body: aitaskvalidationSchemanew,
|
|
31
|
+
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import * as taskController from '../controllers/task.controller.js';
|
|
3
3
|
import { isAllowedSessionHandler, validate, accessVerification, isAllowedClient, isAllowedInternalAPIHandler } from 'tango-app-api-middleware';
|
|
4
4
|
import express from 'express';
|
|
5
|
-
import { aitaskvalidation } from '../dtos/task.dto.js';
|
|
5
|
+
import { aitaskvalidation, aitaskvalidationNew } from '../dtos/task.dto.js';
|
|
6
6
|
export const taskRouter = express.Router();
|
|
7
7
|
|
|
8
8
|
taskRouter
|
|
@@ -26,8 +26,10 @@ taskRouter
|
|
|
26
26
|
.put( '/publish', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.updatePublish )
|
|
27
27
|
.get( '/duplicateTask/:checklistId', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.duplicateChecklist )
|
|
28
28
|
.get( '/teamMigrations', taskController.teamMigrations )
|
|
29
|
+
.get( '/clusterMigrations', taskController.clusterMigrations )
|
|
29
30
|
.post( '/createaiChecklist', isAllowedInternalAPIHandler, taskController.createAiChecklist )
|
|
30
31
|
.post( '/createaiTask', isAllowedInternalAPIHandler, validate( aitaskvalidation ), taskController.createAiTask )
|
|
32
|
+
.post( '/createAiTaskNew', isAllowedInternalAPIHandler, validate( aitaskvalidationNew ), taskController.createAiTaskNew )
|
|
31
33
|
.get( '/getcoustemer', taskController.customertrial );
|
|
32
34
|
|
|
33
35
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import clusterModel from 'tango-api-schema/schema/cluster.model.js';
|
|
2
|
+
|
|
3
|
+
export async function updateOneCluster( query, record ) {
|
|
4
|
+
return await clusterModel.updateOne( query, { $set: record } );
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export async function updateCluster( query, record ) {
|
|
8
|
+
return await clusterModel.updateMany( query, record );
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export async function aggregateCluster( query ) {
|
|
12
|
+
return await clusterModel.aggregate( query );
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export async function findOneCluster( query ={}, field={} ) {
|
|
16
|
+
return await clusterModel.findOne( query, field );
|
|
17
|
+
};
|
|
18
|
+
export async function deleteCluster( query ={} ) {
|
|
19
|
+
return await clusterModel.deleteOne( query );
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export async function createclusterModel( data ) {
|
|
23
|
+
return await clusterModel.create( data );
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export async function findcluster( query, project ) {
|
|
27
|
+
return await clusterModel.find( query, project );
|
|
28
|
+
};
|
|
29
|
+
export function countDocumentsClusters( query ) {
|
|
30
|
+
return clusterModel.countDocuments( query );
|
|
31
|
+
}
|
|
@@ -19,6 +19,8 @@ export async function findOneTeams( query ={}, field={} ) {
|
|
|
19
19
|
return await teamsModel.findOne( query, field );
|
|
20
20
|
};
|
|
21
21
|
export async function findteams( query ={}, field={} ) {
|
|
22
|
+
console.log( query );
|
|
23
|
+
|
|
22
24
|
return await teamsModel.find( query, field );
|
|
23
25
|
};
|
|
24
26
|
|