tango-app-api-trax 3.2.1-beta-8 → 3.3.1-beta-1

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-trax",
3
- "version": "3.2.1-beta-8",
3
+ "version": "3.3.1-beta-1",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -2480,11 +2480,7 @@ export async function questionList( req, res ) {
2480
2480
  if ( question.answerType == 'multiplechoicemultiple' ) {
2481
2481
  let checkvalidation = null;
2482
2482
  if ( answer.validationAnswer && answer.validationAnswer !='' ) {
2483
- if ( answer.validationType != 'Descriptive Answer' ) {
2484
- checkvalidation = await signedUrl( { file_path: decodeURIComponent( answer.validationAnswer ), Bucket: bucket.sop } );
2485
- } else {
2486
- checkvalidation = answer.validationAnswer;
2487
- }
2483
+ checkvalidation = await signedUrl( { file_path: decodeURIComponent( answer.validationAnswer ), Bucket: bucket.sop } );
2488
2484
  }
2489
2485
  Multianswer.push( { 'answer': answer.answer, 'no': ansIndex, 'validationAnswer': checkvalidation } );
2490
2486
  getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].index = ansIndex;
@@ -21,6 +21,8 @@ import utc from 'dayjs/plugin/utc.js';
21
21
  import isEqual from 'lodash/isEqual.js';
22
22
  dayjs.extend( utc );
23
23
  dayjs.extend( customParseFormat );
24
+ import * as clusterServices from '../services/cluster.service.js';
25
+ import * as teamsServices from '../services/teams.service.js';
24
26
 
25
27
 
26
28
  export const checklist = async ( req, res ) => {
@@ -2547,3 +2549,55 @@ export const preDefinedChecklist = async ( req, res ) => {
2547
2549
  }
2548
2550
  };
2549
2551
 
2552
+ export const selectAssign = async ( req, res ) => {
2553
+ try {
2554
+ let requestData = req.body;
2555
+ let resuldData;
2556
+ if ( requestData.coverage == 'store' ) {
2557
+ // //Select Store and cluster
2558
+ let storeQuery = [
2559
+ { $match: { clientId: requestData.clientId } },
2560
+ { $project: { 'storeName': 1, 'storeId': 1, 'type': 'store' } },
2561
+ ];
2562
+ let clusterQuery = [
2563
+ { $match: { clientId: requestData.clientId } },
2564
+ { $project: { 'clusterName': 1, 'type': 'cluster' } },
2565
+ ];
2566
+
2567
+ const [ getStores, getClusters ] = await Promise.all( [
2568
+ storeService.aggregate( storeQuery ),
2569
+ clusterServices.aggregateCluster( clusterQuery ),
2570
+ ] );
2571
+ // console.log( 'getStores =>', getStores );
2572
+ // console.log( 'getClusters =>', getClusters );
2573
+ resuldData = [ ...getStores, ...getClusters ];
2574
+ console.log( 'resuldData =>', resuldData );
2575
+ } else if ( requestData.coverage == 'user' ) {
2576
+ // //Select User and Teams
2577
+ let userQuery = [
2578
+ { $match: { clientId: requestData.clientId } },
2579
+ { $project: { 'userEmail': 1, 'userName': 1, 'type': 'user' } },
2580
+ ];
2581
+ // let getUsers = await userService.aggregate( userQuery );
2582
+ // console.log( 'getUsers =>', getUsers );
2583
+ let teamQuery = [
2584
+ { $match: { clientId: requestData.clientId } },
2585
+ { $project: { 'teamName': 1, 'type': 'team' } },
2586
+ ];
2587
+ // let getTeams = await teamsServices.aggregateTeams( teamQuery );
2588
+ // console.log( 'getTeams =>', getTeams );
2589
+ const [ getUsers, getTeams ] = await Promise.all( [
2590
+ userService.aggregate( userQuery ),
2591
+ teamsServices.aggregateTeams( teamQuery ),
2592
+ ] );
2593
+ resuldData = [ ...getUsers, ...getTeams ];
2594
+ console.log( 'resuldData =>', resuldData );
2595
+ }
2596
+ return res.sendSuccess( { 'totalCount': resuldData.length, 'data': resuldData } );
2597
+ } catch ( e ) {
2598
+ console.log( 'e =>', e );
2599
+ logger.error( 'selectAssign =>', e );
2600
+ return res.sendError( e, 500 );
2601
+ }
2602
+ };
2603
+
@@ -144,4 +144,13 @@ export const startValidation = {
144
144
  body: startSchema,
145
145
  };
146
146
 
147
+ export const selectAssignSchema = joi.object( {
148
+ clientId: joi.string().required(),
149
+ coverage: joi.string().required(),
150
+ } );
151
+
152
+ export const selectAssign = {
153
+ body: selectAssignSchema,
154
+ };
155
+
147
156