tango-app-api-task 3.2.1-beta-27 → 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-task",
3
- "version": "3.2.1-beta-27",
3
+ "version": "3.3.1-beta-1",
4
4
  "description": "Task",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -24,8 +24,8 @@
24
24
  "mongodb": "^6.10.0",
25
25
  "nodemon": "^3.1.7",
26
26
  "npm": "^10.9.2",
27
- "tango-api-schema": "^2.2.52",
28
- "tango-app-api-middleware": "^3.1.58",
27
+ "tango-api-schema": "^2.2.44",
28
+ "tango-app-api-middleware": "^3.1.55",
29
29
  "winston": "^3.17.0",
30
30
  "winston-daily-rotate-file": "^5.0.0"
31
31
  },
@@ -8,9 +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 clusterServices from '../service/cluster.service.js';
12
- import * as teamsServices from '../service/teams.service.js';
13
- // import * as clusterModel from '../service/cluster.service.js';
11
+ import * as clusterModel from '../service/cluster.service.js';
14
12
  // import * as domainService from '../service/domain.service.js';
15
13
  import mongoose from 'mongoose';
16
14
  const ObjectId = mongoose.Types.ObjectId;
@@ -127,6 +125,38 @@ export async function createUpdateTask( req, res ) {
127
125
  } );
128
126
  } );
129
127
 
128
+ for ( let [ index, question ] of section.questions.entries() ) {
129
+ await processNested( index, question );
130
+ }
131
+
132
+ async function processNested( qIdx, question, nestedIndex = -1 ) {
133
+ if ( question?.answers?.length ) {
134
+ for ( let [ index, answer ] of question?.answers?.entries() ) {
135
+ if ( !section.questions[qIdx].answers[index]?.nestedQuestion && nestedIndex == -1 ) {
136
+ section.questions[qIdx].answers[index].nestedQuestion = [];
137
+ }
138
+ if ( answer.showLinked ) {
139
+ if ( nestedIndex != -1 ) {
140
+ section.questions[qIdx].answers[nestedIndex].nestedQuestion.push( answer.linkedQuestion );
141
+ } else {
142
+ section.questions[qIdx].answers[index].nestedQuestion.push( answer.linkedQuestion );
143
+ }
144
+ let nestedLinkedQuestion = section.questions.find( ( item ) => item.qno == answer.linkedQuestion );
145
+ if ( nestedLinkedQuestion ) {
146
+ let findNestedAnswers = nestedLinkedQuestion.answers.find( ( item ) => item.showLinked );
147
+ if ( findNestedAnswers ) {
148
+ if ( nestedIndex != -1 ) {
149
+ await processNested( qIdx, nestedLinkedQuestion, nestedIndex );
150
+ } else {
151
+ await processNested( qIdx, nestedLinkedQuestion, index );
152
+ }
153
+ }
154
+ }
155
+ }
156
+ }
157
+ }
158
+ }
159
+
130
160
  sectionList.push( {
131
161
  section: section?.name || 'Section 1',
132
162
  createdBy: req.user._id,
@@ -264,9 +294,9 @@ export async function taskDetails( req, res ) {
264
294
  }
265
295
  if ( storechecklistdetails ) {
266
296
  result.checkListDetails = { ...storechecklistdetails._doc };
267
- let assignedusers = await taskAssignService.find( { checkListId: storechecklistdetails._id }, { assignId: 1 } );
268
- assignedusers = assignedusers?.map( ( item ) => item.assignId );
269
- result.checkListDetails = { ...result.checkListDetails, ...{ sections: sectionList }, ...{ assignedusers: assignedusers } };
297
+ let removedUsers = await taskAssignService.find( { checkFlag: false, checkListId: storechecklistdetails._id }, { _id: 1 } );
298
+ removedUsers = removedUsers?.map( ( item ) => item._id );
299
+ result.checkListDetails = { ...result.checkListDetails, ...{ sections: sectionList }, ...{ removedUsers: removedUsers } };
270
300
  }
271
301
  return res.sendSuccess( result );
272
302
  } catch ( e ) {
@@ -565,8 +595,11 @@ export async function userDetails( req, res ) {
565
595
  if ( !req.query.taskId ) {
566
596
  return res.sendError( { message: 'Task Id is required' }, 400 );
567
597
  }
598
+ let limit = parseInt( req.query.limit ) || 5;
599
+ let page = parseInt( req.query.offset ) || 0;
600
+ let skip = limit * page;
568
601
 
569
- let query = [ { $match: { checkListId: new ObjectId( req.query.taskId ), ...( req.query.coverage ) ? { coverage: req.query.coverage } : {}, isdeleted: false } } ];
602
+ let query = [ { $match: { checkListId: new ObjectId( req.query.taskId ) } } ];
570
603
  if ( req.query?.search?.trim() && req.query?.search?.trim() != '' ) {
571
604
  let searchValue = req.query.search;
572
605
  searchValue = searchValue.split( ',' ).map( ( item ) => item.trim().toLowerCase() );
@@ -578,6 +611,17 @@ export async function userDetails( req, res ) {
578
611
  }
579
612
  }
580
613
 
614
+ query.push( {
615
+ $facet: {
616
+ data: [
617
+ { $skip: skip }, { $limit: limit },
618
+ ],
619
+ count: [
620
+ { $count: 'total' },
621
+ ],
622
+ },
623
+ } );
624
+
581
625
  let taskDetails = await taskAssignService.aggregate( query );
582
626
 
583
627
  if ( !taskDetails[0].data.length ) {
@@ -585,70 +629,19 @@ export async function userDetails( req, res ) {
585
629
  }
586
630
 
587
631
  let userDetails = [];
588
- let storeList = [];
589
- let userList = [];
590
- await Promise.all( taskDetails.map( async ( ele ) => {
591
- if ( ele?.store_id || ele?.clusterName ) {
592
- storeList.push( ele.assignId );
593
- } else {
594
- userList.push( ele.assignId );
595
- }
596
-
597
- if ( ele?.clusterName ) {
598
- let clusterDetails = await clusterServices.findOneCluster( { _id: ele.assignId }, { stores: 1 } );
599
- if ( clusterDetails ) {
600
- let storeDetails = await storeService.find( { _id: { $in: clusterDetails.stores.map( ( item ) => item.store ) }, status: 'active' } );
601
- storeDetails.forEach( ( item ) => {
602
- userDetails.push( {
603
- id: ele._id,
604
- userName: item.spocDetails?.[0]?.name,
605
- userEmail: item.spocDetails?.[0]?.email,
606
- store_id: item?.storeId,
607
- storeName: item?.storeName,
608
- userPhone: item.spocDetails?.[0]?.phone,
609
- city: ele?.city,
610
- checkFlag: ele.checkFlag,
611
- clusterName: ele?.clusterName || '',
612
- teamName: ele?.teamName || '',
613
- } );
614
- } );
615
- }
616
- } else if ( ele?.teamName ) {
617
- let teamDetails = await teamsServices.findOneTeams( { _id: ele.assignId }, { users: 1, teamName: 1 } );
618
- if ( teamDetails ) {
619
- let teamUserDetails = await userService.find( { _id: { $in: teamDetails.users.map( ( item ) => item.userId ) } } );
620
- teamUserDetails.forEach( ( item ) => {
621
- userDetails.push( {
622
- id: ele._id,
623
- userName: item.userName,
624
- userEmail: item.email,
625
- store_id: ele?.storeId,
626
- storeName: ele?.storeName,
627
- userPhone: item?.mobileNumber,
628
- city: ele?.city,
629
- checkFlag: ele.checkFlag,
630
- clusterName: ele?.clusterName || '',
631
- teamName: ele?.teamName || '',
632
- } );
633
- } );
634
- }
635
- } else {
636
- userDetails.push( {
637
- id: ele._id,
638
- userName: ele.userName,
639
- userEmail: ele.userEmail,
640
- store_id: ele?.store_id,
641
- storeName: ele?.storeName,
642
- userPhone: ele.userPhone,
643
- city: ele.city,
644
- checkFlag: ele.checkFlag,
645
- clusterName: ele?.clusterName || '',
646
- teamName: ele?.teamName || '',
647
- } );
648
- }
649
- } ) );
650
-
651
- return res.sendSuccess( { count: userDetails.length, storeList, userList, users: limitedData } );
632
+ taskDetails[0].data.forEach( ( item ) => {
633
+ userDetails.push( {
634
+ id: item._id,
635
+ userName: item.userName,
636
+ userEmail: item.userEmail,
637
+ store_id: item.store_id,
638
+ storeName: item.storeName,
639
+ userPhone: item.userPhone,
640
+ city: item.city,
641
+ checkFlag: item.checkFlag,
642
+ } );
643
+ } );
644
+ return res.sendSuccess( { users: userDetails, count: taskDetails[0].count[0].total } );
652
645
  } catch ( e ) {
653
646
  logger.error( { functionName: 'userDetails', error: e, message: req.body } );
654
647
  return res.sendError( e, 500 );
@@ -658,22 +651,20 @@ export async function userDetails( req, res ) {
658
651
  export async function taskConfig( req, res ) {
659
652
  try {
660
653
  let inputBody = req.body;
654
+ let storeCount = 0;
655
+ let locationCount = 0;
661
656
  let checklistDetails;
662
657
  inputBody.client_id = inputBody.clientId;
663
658
  if ( !inputBody._id ) {
664
659
  return res.sendError( { message: 'Task Id is Required' }, 400 );
665
660
  }
666
661
 
667
- if ( !inputBody.assignedUsers.length && inputBody.submitType == 'publish' ) {
668
- return res.sendError( 'Please Assigned a user', 400 );
662
+ if ( inputBody.submitType == 'publish' ) {
663
+ let checkUserAssigned = await taskAssignService.findOne( { checkListId: inputBody._id, checkFlag: true } );
664
+ if ( !checkUserAssigned ) {
665
+ return res.sendError( { message: 'Please assign a user' }, 400 );
666
+ }
669
667
  }
670
-
671
- // if ( inputBody.submitType == 'publish' ) {
672
- // let checkUserAssigned = await taskAssignService.findOne( { checkListId: inputBody._id, checkFlag: true } );
673
- // if ( !checkUserAssigned ) {
674
- // return res.sendError( { message: 'Please assign a user' }, 400 );
675
- // }
676
- // }
677
668
  if ( !inputBody?.approver.length && inputBody.submitType == 'publish' ) {
678
669
  return res.sendError( { message: 'Please assign approver' }, 400 );
679
670
  }
@@ -691,7 +682,7 @@ export async function taskConfig( req, res ) {
691
682
  };
692
683
  await checklistLogs.create( logInsertData );
693
684
 
694
- checklistDetails = await taskService.findOne( { _id: inputBody._id, isdeleted: false, client_id: inputBody.clientId } );
685
+ checklistDetails = await taskService.findOne( { _id: inputBody._id, isdeleted: false } );
695
686
 
696
687
  if ( !checklistDetails ) {
697
688
  return res.sendError( 'No data found', 204 );
@@ -729,21 +720,39 @@ export async function taskConfig( req, res ) {
729
720
  await traxApprover.insertMany( data );
730
721
  }
731
722
  }
732
- if ( inputBody.assignedUsers.length ) {
733
- await taskAssignService.deleteMany( { checkListId: inputBody._id } );
734
- await Promise.all( inputBody.assignedUsers.map( async ( user ) => {
735
- let data = {
736
- ...user,
737
- clientId: req.body.clientId,
738
- checkListName: checklistDetails.checkListName,
739
- checklistId: checklistDetails._id,
740
- coverage: inputBody.coverage,
741
- insert: true,
742
- };
743
- await assignUsers( data );
744
- } ) );
723
+ await taskAssignService.updateMany( { checkListId: inputBody._id }, { checkFlag: true } );
724
+ if ( inputBody.removedUsers.length ) {
725
+ await taskAssignService.updateMany( { _id: { $in: inputBody.removedUsers } }, { checkFlag: false } );
745
726
  }
746
727
  let storeConfigDetails = await taskAssignService.find( { checkListId: inputBody._id, checkFlag: true }, { _id: 0, store_id: 1, userEmail: 1, storeName: 1 } );
728
+ let storeList = storeConfigDetails.map( ( store ) => store.store_id );
729
+
730
+ storeCount = storeList.length;
731
+ if ( storeList.length ) {
732
+ let query = [
733
+ {
734
+ $match: {
735
+ client_id: inputBody.client_id,
736
+ id: { $in: storeList },
737
+ city: { $exists: true },
738
+ },
739
+ },
740
+ {
741
+ $group: {
742
+ _id: '$city',
743
+ },
744
+ },
745
+ {
746
+ $project: {
747
+ _id: 0,
748
+ city: '$_id',
749
+ },
750
+ },
751
+ ];
752
+ let storeDetails = await storeService.aggregate( query );
753
+ locationCount = storeDetails.length;
754
+ }
755
+ await taskService.updateOne( { _id: inputBody._id }, { storeCount, locationCount } );
747
756
  if ( inputBody.submitType == 'publish' ) {
748
757
  let taskName = checklistDetails.checkListName;
749
758
  let dueDate = dayjs( configDetails.scheduleEndTimeISO ).format( 'YYYY-MM-DD hh:mm A' );
@@ -901,6 +910,7 @@ export async function insertSingleProcessData( checklistId ) {
901
910
  await taskProcessedConfigService.updateOne( { _id: checklistDetails._id }, insertDataPerDay );
902
911
  updatedchecklist = checklistDetails;
903
912
  }
913
+
904
914
  if ( updatedchecklist ) {
905
915
  await insertPCBulkV3( getCLconfig, checklistId, updatedchecklist, dateVal, startTimeIso, endTimeIso, insertdata );
906
916
  }
@@ -928,80 +938,7 @@ async function insertPCBulkV3( getCLconfig, checklistId, updatedchecklist, date,
928
938
 
929
939
  if ( allQuestion ) {
930
940
  let userIdList = [];
931
- let assignList = [];
932
- let assignUserList = [];
933
- if ( getCLconfig.coverage == 'store' ) {
934
- let clusterList = allQuestion.filter( ( ele ) => ele?.clusterName ).map( ( item ) => item.assignId );
935
- if ( clusterList.length ) {
936
- let clusterDetails = await clusterServices.findcluster( { _id: { $in: clusterList } } );
937
- if ( clusterDetails.length ) {
938
- let idList = clusterDetails.flatMap( ( item ) => item.stores.map( ( ele ) => ele.store ) );
939
- let getStoreDetails = await storeService.find( { _id: { $in: idList }, status: 'active' } );
940
- if ( getStoreDetails.length ) {
941
- assignList = await Promise.all( getStoreDetails.map( async ( store ) => {
942
- let userDetails = await userService.findOne( { email: store?.spocDetails?.[0]?.email, clientId: store.clientId } );
943
- if ( !userDetails ) {
944
- let data = {
945
- clientId: store.clientId,
946
- userName: store.spocDetails?.[0]?.name,
947
- mobileNumber: store.spocDetails?.[0]?.phone || '',
948
- email: store.spocDetails[0].email,
949
- };
950
- userDetails = await createUser( data );
951
- }
952
- let data = {
953
- store_id: store?.storeId,
954
- storeName: store?.storeName,
955
- userId: userDetails._id,
956
- userName: userDetails.userName,
957
- userEmail: userDetails.email,
958
- userPhone: userDetails?.mobileNumber,
959
- city: store?.storeProfile?.city,
960
- country: store?.storeProfile?.country,
961
- checkFlag: true,
962
- checkListId: getCLconfig._id,
963
- checkListName: getCLconfig.checkListName,
964
- client_id: getCLconfig.client_id,
965
- };
966
- return data;
967
- } ) );
968
- }
969
- }
970
- }
971
- allQuestion = allQuestion.filter( ( ele ) => !clusterList.includes( ele.assignId ) );
972
- }
973
- if ( getCLconfig.coverage == 'user' ) {
974
- let teamsList = allQuestion.filter( ( ele ) => ele?.teamName ).map( ( item ) => item.assignId );
975
- if ( teamsList.length ) {
976
- let teamDetails = await teamsServices.findteams( { _id: { $in: teamsList } } );
977
- if ( teamDetails.length ) {
978
- let idList = teamDetails.flatMap( ( item ) => item.users.map( ( ele ) => ele.userId ) );
979
- let getUserDetails = await userService.find( { _id: { $in: idList } } );
980
- if ( getUserDetails.length ) {
981
- assignList = getUserDetails.map( ( user ) => {
982
- let data = {
983
- store_id: '',
984
- storeName: '',
985
- userId: user._id,
986
- userName: user.userName,
987
- userEmail: user.email,
988
- userPhone: user?.mobileNumber,
989
- city: '',
990
- country: '',
991
- checkFlag: true,
992
- checkListId: getCLconfig._id,
993
- checkListName: getCLconfig.checkListName,
994
- client_id: getCLconfig.client_id,
995
- };
996
- return data;
997
- } );
998
- }
999
- }
1000
- }
1001
- allQuestion = allQuestion.filter( ( ele ) => !teamsList.includes( ele.assignId ) );
1002
- }
1003
- allQuestion = [ ...allQuestion, ...assignList ];
1004
- await Promise.all( allQuestion.map( async ( element4 ) => {
941
+ for ( let element4 of allQuestion ) {
1005
942
  let query;
1006
943
  query = {
1007
944
  date_string: dayjs( date ).format( 'YYYY-MM-DD' ),
@@ -1017,39 +954,38 @@ async function insertPCBulkV3( getCLconfig, checklistId, updatedchecklist, date,
1017
954
  let getsubmitDetails = await taskProcessedService.find( query );
1018
955
  if ( getsubmitDetails.length ) {
1019
956
  userIdList.push( element4._id );
1020
- } else {
1021
- delete element4._id;
1022
- delete element4.checkFlag;
1023
- delete element4.isdeleted;
1024
- delete element4.createdAt;
1025
- delete element4.updatedAt;
1026
- element4.checkListId = updatedchecklist._id;
1027
- element4.checkListName = getCLconfig.checkListName;
1028
- element4.checkListDescription = getCLconfig.checkListDescription;
1029
- element4.date_iso = new Date( dayjs( date, 'YYYY-MM-DD' ).format( 'YYYY-MM-DD' ) );
1030
- element4.date_string = dayjs( date ).format( 'YYYY-MM-DD' );
1031
- element4.allowedOverTime = false;
1032
- element4.allowedStoreLocation = getCLconfig.allowedStoreLocation;
1033
- element4.scheduleStartTime = '12:00 AM';
1034
- element4.scheduleStartTime_iso = startTimeIso.format();
1035
- element4.scheduleEndTime = getCLconfig.scheduleEndTime;
1036
- element4.scheduleEndTime_iso = endTimeIso.format();
1037
- element4.createdBy = new ObjectId( getCLconfig.createdBy );
1038
- element4.createdByName = getCLconfig.createdByName;
1039
- element4.sourceCheckList_id = getCLconfig._id;
1040
- element4.checkListType = getCLconfig.checkListType;
1041
- element4.storeCount = getCLconfig.storeCount;
1042
- element4.questionCount = getCLconfig.questionCount;
1043
- element4.publishDate = getCLconfig.publishDate;
1044
- element4.locationCount = getCLconfig.locationCount;
1045
- element4.scheduleRepeatedType = 'daily';
1046
- element4.approvalEnable = getCLconfig.approver.length ? true : false;
1047
- element4.priorityType = getCLconfig.priorityType;
1048
- element4.remainder = getCLconfig?.remainder || [];
1049
- element4.restrictAttendance = getCLconfig?.restrictAttendance;
1050
- assignUserList.push( element4 );
1051
- }
1052
- } ) );
957
+ continue;
958
+ }
959
+ delete element4._id;
960
+ delete element4.checkFlag;
961
+ delete element4.isdeleted;
962
+ delete element4.createdAt;
963
+ delete element4.updatedAt;
964
+ element4.checkListId = updatedchecklist._id;
965
+ element4.checkListName = getCLconfig.checkListName;
966
+ element4.checkListDescription = getCLconfig.checkListDescription;
967
+ element4.date_iso = new Date( dayjs( date, 'YYYY-MM-DD' ).format( 'YYYY-MM-DD' ) );
968
+ element4.date_string = dayjs( date ).format( 'YYYY-MM-DD' );
969
+ element4.allowedOverTime = false;
970
+ element4.allowedStoreLocation = getCLconfig.allowedStoreLocation;
971
+ element4.scheduleStartTime = '12:00 AM';
972
+ element4.scheduleStartTime_iso = startTimeIso.format();
973
+ element4.scheduleEndTime = getCLconfig.scheduleEndTime;
974
+ element4.scheduleEndTime_iso = endTimeIso.format();
975
+ element4.createdBy = new ObjectId( getCLconfig.createdBy );
976
+ element4.createdByName = getCLconfig.createdByName;
977
+ element4.sourceCheckList_id = getCLconfig._id;
978
+ element4.checkListType = getCLconfig.checkListType;
979
+ element4.storeCount = getCLconfig.storeCount;
980
+ element4.questionCount = getCLconfig.questionCount;
981
+ element4.publishDate = getCLconfig.publishDate;
982
+ element4.locationCount = getCLconfig.locationCount;
983
+ element4.scheduleRepeatedType = 'daily';
984
+ element4.approvalEnable = getCLconfig.approver.length ? true : false;
985
+ element4.priorityType = getCLconfig.priorityType;
986
+ element4.remainder = getCLconfig?.remainder || [];
987
+ element4.restrictAttendance = getCLconfig?.restrictAttendance;
988
+ }
1053
989
  if ( userIdList.length ) {
1054
990
  allQuestion = allQuestion.filter( ( item ) => typeof item._id == 'undefined' );
1055
991
  }
@@ -1143,7 +1079,6 @@ export async function uploadImage( req, res ) {
1143
1079
 
1144
1080
  async function createUser( data ) {
1145
1081
  try {
1146
- console.log( 'createUser ====>', data );
1147
1082
  let params = {
1148
1083
  userName: data.userName,
1149
1084
  email: data.email,
@@ -1226,8 +1161,7 @@ async function createUser( data ) {
1226
1161
  ],
1227
1162
  };
1228
1163
  let response = await userService.create( params );
1229
- // console.log( 'createUser ====>', response );
1230
- return response;
1164
+ return response._id;
1231
1165
  } catch ( e ) {
1232
1166
  logger.error( 'createUser =>', e );
1233
1167
  return false;
@@ -1427,17 +1361,16 @@ export async function createChecklistTask( req, res ) {
1427
1361
  client_id: inputBody.clientId,
1428
1362
  };
1429
1363
  await taskQuestionService.create( question );
1430
- let storeDetails;
1431
- if ( inputBody?.storeName ) {
1432
- storeDetails = await storeService.findOne( { storeName: inputBody.storeName, status: 'active' }, { storeId: 1, storeProfile: 1 } );
1364
+ let storeDetails = await storeService.findOne( { storeName: inputBody.storeName, status: 'active' }, { storeId: 1, storeProfile: 1 } );
1365
+ if ( !storeDetails ) {
1366
+ return res.sendError( 'No data found', 204 );
1433
1367
  }
1434
-
1435
1368
  let userDetails = {
1436
1369
  userName: inputBody.userName,
1437
1370
  userEmail: inputBody.userEmail,
1438
- store_id: storeDetails?.storeId?storeDetails.storeId:'',
1439
- storeName: inputBody?.storeName?inputBody?.storeName:'',
1440
- city: storeDetails?.storeProfile?.city?storeDetails?.storeProfile?.city:'',
1371
+ store_id: storeDetails.storeId,
1372
+ storeName: inputBody.storeName,
1373
+ city: storeDetails?.storeProfile?.city,
1441
1374
  checkFlag: true,
1442
1375
  checkListId: response?._id,
1443
1376
  checkListName: data.checkListName,
@@ -1456,9 +1389,8 @@ export async function createChecklistTask( req, res ) {
1456
1389
  if ( sectionIndex == -1 ) {
1457
1390
  return res.sendError( 'section is not found', 400 );
1458
1391
  }
1459
- let findQuestion = question[sectionIndex].questions.findIndex( ( ele ) => ele?.parentQuestion ? ele.qno == req.body.qno && ele.parentQuestion == req.body.parentQuestion : ele.qno == req.body.qno );
1392
+ let data = { ...question[sectionIndex].questions[req.body.qno - 1], taskId: response?._id, task: true };
1460
1393
 
1461
- let data = { ...question[sectionIndex].questions[findQuestion], taskId: response?._id, task: true };
1462
1394
  question[sectionIndex].questions[req.body.qno - 1] = data;
1463
1395
  taskDetails.questionAnswers = question;
1464
1396
  let updateData = {
@@ -1471,7 +1403,6 @@ export async function createChecklistTask( req, res ) {
1471
1403
  _id: inputBody.processedChecklistId,
1472
1404
  section_id: inputBody.sectionId,
1473
1405
  qno: inputBody.qno,
1474
- parentQuestion: inputBody.parentQuestion,
1475
1406
  },
1476
1407
  'upsert': {
1477
1408
  taskId: String( response?._id ),
@@ -1531,7 +1462,6 @@ export async function approveTask( req, res ) {
1531
1462
  sourceCheckList_id: req.body.sourceCheckList_id,
1532
1463
  fromDate: req.body.fromDate,
1533
1464
  toDate: req.body.toDate,
1534
- filtertype: req.body.filtertype,
1535
1465
  store_id: inputstores,
1536
1466
  },
1537
1467
  'upsert': {
@@ -1609,7 +1539,6 @@ export async function redoTask( req, res ) {
1609
1539
  };
1610
1540
 
1611
1541
  let response = await taskProcessedService.updateOne( { _id: req.body.payload._id }, updateData );
1612
- console.log( response );
1613
1542
  if ( response.modifiedCount || response.matchedCount ) {
1614
1543
  let storeTimeZone = await storeService.findOne( { storeName: taskDetails.storeName }, { 'storeProfile.timeZone': 1 } );
1615
1544
  let currentDateTime;
@@ -1626,8 +1555,8 @@ export async function redoTask( req, res ) {
1626
1555
  sectionName: question[sectionIndex].sectionName,
1627
1556
  questionName: question[sectionIndex].questions[req.body.payload.qno - 1].qname,
1628
1557
  action: 'redo',
1629
- store_id: taskDetails?.store_id?taskDetails?.store_id:'',
1630
- storeName: taskDetails.storeName?taskDetails.storeName:'',
1558
+ store_id: taskDetails.store_id,
1559
+ storeName: taskDetails.storeName,
1631
1560
  client_id: taskDetails.client_id,
1632
1561
  processedChecklistId: taskDetails._id,
1633
1562
  type: taskDetails.checkListType,
@@ -1649,7 +1578,6 @@ export async function redoTask( req, res ) {
1649
1578
  };
1650
1579
  let url = JSON.parse( process.env.LAMBDAURL );
1651
1580
  let searchResponse = await fetch( url.redoTask, requestOptions );
1652
- console.log( searchResponse.ok );
1653
1581
  if ( searchResponse.ok ) {
1654
1582
  return res.sendSuccess( 'Question redo successfully' );
1655
1583
  } else {
@@ -1746,7 +1674,6 @@ export const taskDropdown = async ( req, res ) => {
1746
1674
  scheduleRepeatedType: 1,
1747
1675
  scheduleStartTime: 1,
1748
1676
  scheduleEndTime: 1,
1749
- coverage: 1,
1750
1677
  },
1751
1678
  } );
1752
1679
 
@@ -1761,7 +1688,6 @@ export const taskDropdown = async ( req, res ) => {
1761
1688
  scheduleRepeatedType: { $last: '$scheduleRepeatedType' },
1762
1689
  scheduleStartTime: { $last: '$scheduleStartTime' },
1763
1690
  scheduleEndTime: { $last: '$scheduleEndTime' },
1764
- coverage: { $last: '$coverage' },
1765
1691
  },
1766
1692
  } );
1767
1693
 
@@ -1800,7 +1726,6 @@ export const taskDropdown = async ( req, res ) => {
1800
1726
  scheduleRepeatedType: 1,
1801
1727
  scheduleStartTime: 1,
1802
1728
  scheduleEndTime: 1,
1803
- coverage: 1,
1804
1729
  checkListDescription: '$checklistconfigs.checkListDescription',
1805
1730
  publish: '$checklistconfigs.publish',
1806
1731
  },
@@ -2236,13 +2161,13 @@ export async function clusterMigrations( req, res ) {
2236
2161
  if ( userexits ) {
2237
2162
  let findStore = await storeService.findOne( { storeName: user.FacilityCode } );
2238
2163
  if ( findStore ) {
2239
- let clusterExists = await clusterServices.findOneCluster( { clusterName: user.AomName } );
2164
+ let clusterExists = await clusterModel.findOneCluster( { clusterName: user.AomName } );
2240
2165
  if ( clusterExists ) {
2241
2166
  let data = {
2242
2167
  storeId: findStore.storeId,
2243
2168
  store: findStore._id,
2244
2169
  };
2245
- let updatecluster = await clusterServices.updateCluster( { clusterName: user.AomName }, { $push: { stores: data } } );
2170
+ let updatecluster = await clusterModel.updateCluster( { clusterName: user.AomName }, { $push: { stores: data } } );
2246
2171
  console.log( updatecluster );
2247
2172
  } else {
2248
2173
  let payload = {
@@ -2264,7 +2189,7 @@ export async function clusterMigrations( req, res ) {
2264
2189
  ],
2265
2190
  'users': [],
2266
2191
  };
2267
- let createcluster = await clusterServices.createclusterModel( payload );
2192
+ let createcluster = await clusterModel.createclusterModel( payload );
2268
2193
  console.log( createcluster );
2269
2194
  }
2270
2195
  }
@@ -2464,16 +2389,14 @@ export async function StoreHygienetask( req, res ) {
2464
2389
  inputBody.approver = inputBody.approver.replace( /,$/, '' );
2465
2390
 
2466
2391
 
2467
- let title = `New Task Alert ${inputBody.taskName}-${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )}`;
2392
+ // let title = `New Task Alert ${inputBody.taskName}-${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )}`;
2468
2393
  let time = inputBody?.scheduleEndTime || '11:59 PM';
2469
2394
  let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
2470
- let description = `A new task has been assigned to ${storeDetails.storeName}. Please complete it before the due date of ${date}.`;
2471
- let userDetails = await userService.findOne( { _id: new mongoose.Types.ObjectId( finduser.userId ) } );
2472
- console.log( userDetails.fcmToken );
2473
- if ( userDetails&&userDetails.fcmToken ) {
2474
- const fcmToken = userDetails.fcmToken;
2475
- await sendPushNotification( title, description, fcmToken );
2476
- }
2395
+ // let description = `A new task has been assigned to ${storeDetails.storeName}. Please complete it before the due date of ${date}.`;
2396
+ // if ( userDetails&&userDetails.fcmToken ) {
2397
+ // const fcmToken = userDetails.fcmToken;
2398
+ // await sendPushNotification( title, description, fcmToken );
2399
+ // }
2477
2400
  const inputDateTime = dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' );
2478
2401
  const currentTime = dayjs.utc();
2479
2402
  if ( inputDateTime.isBefore( currentTime ) ) {
@@ -2652,7 +2575,6 @@ export async function StoreHygienetask( req, res ) {
2652
2575
  export async function eyeTesttask( req, res ) {
2653
2576
  try {
2654
2577
  let inputBody = req.body;
2655
- console.log( inputBody );
2656
2578
  inputBody.clientId = 11;
2657
2579
  inputBody.taskDescription = '';
2658
2580
  let userId;
@@ -2663,9 +2585,7 @@ export async function eyeTesttask( req, res ) {
2663
2585
 
2664
2586
  let url = JSON.parse( process.env.LAMBDAURL );
2665
2587
  let checklistId = url.dailystoreChecklistId;
2666
- console.log( checklistId );
2667
2588
  let finduser = await checklistassignconfigModel.findOne( { checkListId: new mongoose.Types.ObjectId( checklistId ), store_id: storeDetails.storeId } );
2668
- console.log( finduser );
2669
2589
 
2670
2590
  if ( !finduser ) {
2671
2591
  return res.sendError( 'No user Found For this store', 500 );
@@ -2687,16 +2607,14 @@ export async function eyeTesttask( req, res ) {
2687
2607
  inputBody.approver = inputBody.approver.replace( /,$/, '' );
2688
2608
 
2689
2609
 
2690
- let title = `New Task Alert ${inputBody.taskName}-${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )}`;
2610
+ // let title = `New Task Alert ${inputBody.taskName}-${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )}`;
2691
2611
  let time = inputBody?.scheduleEndTime || '11:59 PM';
2692
2612
  let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
2693
- let description = `A new task has been assigned to ${storeDetails.storeName}. Please complete it before the due date of ${date}.`;
2694
- let userDetails = await userService.findOne( { _id: new mongoose.Types.ObjectId( finduser.userId ) } );
2695
- console.log( userDetails.fcmToken );
2696
- if ( userDetails&&userDetails.fcmToken ) {
2697
- const fcmToken = userDetails.fcmToken;
2698
- await sendPushNotification( title, description, fcmToken );
2699
- }
2613
+ // let description = `A new task has been assigned to ${storeDetails.storeName}. Please complete it before the due date of ${date}.`;
2614
+ // if ( userDetails&&userDetails.fcmToken ) {
2615
+ // const fcmToken = userDetails.fcmToken;
2616
+ // await sendPushNotification( title, description, fcmToken );
2617
+ // }
2700
2618
  const inputDateTime = dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' );
2701
2619
  const currentTime = dayjs.utc();
2702
2620
  if ( inputDateTime.isBefore( currentTime ) ) {
@@ -2824,10 +2742,8 @@ export async function eyeTesttask( req, res ) {
2824
2742
  }
2825
2743
  question[0].questionReferenceImage = images;
2826
2744
  } else {
2827
- console.log( req.file );
2828
2745
  let images = [];
2829
2746
  let uplaodedImage = await uploadmultiImage( req.files.referenceImage );
2830
- console.log( uplaodedImage );
2831
2747
  let imgUrl = decodeURIComponent( uplaodedImage.imgUrl.split( '?' )[0] );
2832
2748
  let url = imgUrl.split( '/' );
2833
2749
  if ( url.includes( 'https:' ) || url.includes( 'http:' ) ) {
@@ -3341,337 +3257,6 @@ export async function uploadmultiImage( images ) {
3341
3257
  }
3342
3258
  };
3343
3259
 
3344
- export async function taskAssign( req, res ) {
3345
- try {
3346
- if ( !req.body.taskId ) {
3347
- return res.sendError( 'Checklist id is required', 400 );
3348
- }
3349
- if ( !req.body.coverage ) {
3350
- return res.sendError( 'Coverage is required', 400 );
3351
- }
3352
- if ( !req.body.idList ) {
3353
- return res.sendError( 'Id is required', 400 );
3354
- }
3355
-
3356
- let taskDetails = await taskService.findOne( { _id: req.body.taskId } );
3357
- if ( !taskDetails ) {
3358
- return res.sendError( 'No data found', 204 );
3359
- }
3360
- let assignList = [];
3361
-
3362
- // for ( let data of req.body.idList ) {
3363
- // let assignedData = {
3364
- // ...data,
3365
- // clientId: req.body.clientId,
3366
- // checkListName: taskDetails.checkListName,
3367
- // checklistId: taskDetails._id,
3368
- // coverage: req.body.coverage,
3369
- // insert: false,
3370
- // };
3371
- // // console.log( assignedData, 'daterthj' );
3372
- // let uploadData = await assignUsers( assignedData );
3373
- // if ( uploadData ) {
3374
- // if ( Array.isArray( uploadData ) ) {
3375
- // assignList.push( ...uploadData );
3376
- // } else {
3377
- // assignList.push( uploadData );
3378
- // }
3379
- // }
3380
- // }
3381
-
3382
- await Promise.all( req.body.idList.map( async ( data ) => {
3383
- let assignedData = {
3384
- ...data,
3385
- clientId: req.body.clientId,
3386
- checkListName: taskDetails.checkListName,
3387
- checklistId: taskDetails._id,
3388
- coverage: req.body.coverage,
3389
- insert: false,
3390
- };
3391
- // console.log( assignedData, 'daterthj' );
3392
- let uploadData = await assignUsers( assignedData );
3393
- if ( uploadData ) {
3394
- if ( Array.isArray( uploadData ) ) {
3395
- assignList.push( ...uploadData );
3396
- } else {
3397
- assignList.push( uploadData );
3398
- }
3399
- }
3400
- } ) );
3401
-
3402
-
3403
- return res.sendSuccess( { count: assignList.length, assignList } );
3404
- } catch ( e ) {
3405
- logger.error( { functionName: 'checklistAssign', error: e } );
3406
- return res.sendError( e, 500 );
3407
- }
3408
- }
3409
-
3410
- async function assignUsers( data ) {
3411
- console.log( data );
3412
- let assignedData;
3413
- if ( data.coverage == 'store' ) {
3414
- if ( data?.type == 'cluster' ) {
3415
- let query = [
3416
- {
3417
- $addFields: {
3418
- cluster: { $toLower: '$clusterName' },
3419
- },
3420
- },
3421
- {
3422
- $match: {
3423
- clientId: data.clientId,
3424
- ...( !data?.clusterName ) ? { _id: new mongoose.Types.ObjectId( data.id ) } : { cluster: data.clusterName.toLowerCase() },
3425
- },
3426
- },
3427
- {
3428
- $project: {
3429
- stores: 1,
3430
- clusterName: 1,
3431
- },
3432
- },
3433
- ];
3434
- let clusterDetails = await clusterServices.aggregateCluster( query );
3435
- if ( clusterDetails.length ) {
3436
- if ( data.insert ) {
3437
- assignedData = {
3438
- checkFlag: true,
3439
- checkListId: data.checklistId,
3440
- checkListName: data.checkListName,
3441
- client_id: data?.clientId,
3442
- clusterName: clusterDetails?.[0]?.clusterName,
3443
- assignId: data?.id || clusterDetails?.[0]?._id,
3444
- coverage: 'store',
3445
- };
3446
- } else {
3447
- let clusterList = clusterDetails[0].stores.map( ( ele ) => ele.store );
3448
- let storeDetails = await storeService.find( { _id: { $in: clusterList }, status: 'active' } );
3449
- assignedData = await Promise.all( storeDetails.map( async ( store ) => {
3450
- let userDetails = await userService.findOne( { email: store.spocDetails?.[0]?.email, clientId: data.clientId } );
3451
- if ( !userDetails && store?.spocDetails?.length ) {
3452
- let userData = {
3453
- userName: store.spocDetails?.[0]?.name,
3454
- email: store.spocDetails[0]?.email,
3455
- mobileNumber: store.spocDetails?.[0]?.phone,
3456
- clientId: data.clientId,
3457
- };
3458
- userDetails = await createUser( userData );
3459
- }
3460
- let userData = {
3461
- userId: userDetails?._id,
3462
- userName: userDetails?.userName,
3463
- userEmail: userDetails?.email,
3464
- userPhone: userDetails?.mobileNumber,
3465
- checkFlag: true,
3466
- checkListId: data.checklistId,
3467
- checkListName: data.checkListName,
3468
- client_id: data.clientId,
3469
- assignId: data?.id || clusterDetails?.[0]?._id,
3470
- coverage: 'store',
3471
- clusterName: clusterDetails?.[0]?.clusterName,
3472
- storeId: store.storeId,
3473
- storeName: store.storeName,
3474
- };
3475
- return userData;
3476
- } ) );
3477
- }
3478
- }
3479
- } else {
3480
- let query = [
3481
- {
3482
- $addFields: {
3483
- store: { $toLower: '$storeName' },
3484
- },
3485
- },
3486
- {
3487
- $match: {
3488
- clientId: data.clientId,
3489
- ...( !data.storeName ) ? { _id: new mongoose.Types.ObjectId( data.id ) } : { store: data.storeName.toLowerCase() },
3490
- },
3491
- },
3492
- ];
3493
- let storeDetails = await storeService.aggregate( query );
3494
- if ( storeDetails.length ) {
3495
- let email = data?.userEmail ? data.userEmail : storeDetails?.[0]?.spocDetails?.[0]?.email;
3496
- let userDetails = await userService.findOne( { email: email, clientId: data.clientId } );
3497
- if ( !userDetails ) {
3498
- let userData = {
3499
- userName: storeDetails?.[0]?.spocDetails?.[0]?.name,
3500
- email: storeDetails?.[0]?.spocDetails[0].email,
3501
- mobileNumber: storeDetails?.[0]?.spocDetails?.[0]?.phone,
3502
- clientId: data.clientId,
3503
- };
3504
- userDetails = await createUser( userData );
3505
- console.log( 'userDetails =>', userDetails );
3506
- }
3507
- assignedData = {
3508
- store_id: storeDetails?.[0]?.storeId,
3509
- storeName: storeDetails?.[0]?.storeName,
3510
- userId: userDetails._id,
3511
- userName: userDetails.userName,
3512
- userEmail: userDetails.email,
3513
- userPhone: userDetails?.mobileNumber,
3514
- city: storeDetails?.[0]?.storeProfile?.city,
3515
- country: storeDetails?.[0]?.storeProfile?.country,
3516
- checkFlag: true,
3517
- checkListId: data.checklistId,
3518
- checkListName: data.checkListName,
3519
- client_id: data.clientId,
3520
- assignId: data?.id || storeDetails?.[0]?._id,
3521
- coverage: 'store',
3522
- };
3523
- }
3524
- }
3525
- } else {
3526
- if ( data.type == 'teams' ) {
3527
- let query = [
3528
- {
3529
- $addFields: {
3530
- team: { $toLower: '$teamName' },
3531
- },
3532
- },
3533
- {
3534
- $match: {
3535
- clientId: data.clientId,
3536
- ...( !data?.teamName ) ? { _id: new mongoose.Types.ObjectId( data.id ) } : { team: data.teamName.toLowerCase() },
3537
- },
3538
- },
3539
- ];
3540
- let teamDetails = await teamsServices.aggregateTeams( query );
3541
- if ( teamDetails.length ) {
3542
- if ( data.insert ) {
3543
- assignedData = {
3544
- checkFlag: true,
3545
- checkListId: data.checklistId,
3546
- checkListName: data.checkListName,
3547
- client_id: data.clientId,
3548
- teamName: teamDetails?.[0]?.teamName,
3549
- assignId: data?.id || teamDetails?.[0]?._id,
3550
- coverage: 'user',
3551
- };
3552
- } else {
3553
- let userIdList = teamDetails[0].users.map( ( ele ) => ele.userId );
3554
- let userDetails = await userService.find( { _id: userIdList } );
3555
- assignedData = userDetails.map( ( user ) => {
3556
- let userData = {
3557
- userId: user._id,
3558
- userName: user.userName,
3559
- userEmail: user.email,
3560
- userPhone: user.mobileNumber,
3561
- checkFlag: true,
3562
- checkListId: data.checklistId,
3563
- checkListName: data.checkListName,
3564
- client_id: data.clientId,
3565
- assignId: data?.id || teamDetails?.[0]?._id,
3566
- coverage: 'user',
3567
- teamName: teamDetails?.[0]?.teamName,
3568
- };
3569
- return userData;
3570
- } );
3571
- }
3572
- }
3573
- } else {
3574
- let query = [
3575
- {
3576
- $addFields: {
3577
- userEmail: { $toLower: '$email' },
3578
- },
3579
- },
3580
- {
3581
- $match: {
3582
- clientId: data.clientId,
3583
- ...( !data?.userEmail ) ? { _id: new mongoose.Types.ObjectId( data.id ) } : { userEmail: data.userEmail.toLowerCase() },
3584
- },
3585
- },
3586
- ];
3587
- // console.log( 'data?.userEmail=>', data.userEmail );
3588
- let userDetails = await userService.aggregate( query );
3589
- if ( !userDetails.length ) {
3590
- let userData = {
3591
- userName: data?.userEmail?.split( '@' )[0],
3592
- email: data.userEmail,
3593
- clientId: data.clientId,
3594
- };
3595
- // console.log( userData, 'userData', data );
3596
- let details = await createUser( userData );
3597
- userDetails = [ details ];
3598
- }
3599
- if ( userDetails.length ) {
3600
- assignedData = {
3601
- userId: userDetails?.[0]?._id,
3602
- userName: userDetails?.[0]?.userName,
3603
- userEmail: userDetails?.[0]?.email,
3604
- userPhone: userDetails?.[0]?.mobileNumber,
3605
- checkFlag: true,
3606
- checkListId: data.checklistId,
3607
- checkListName: data.checkListName,
3608
- client_id: data.clientId,
3609
- assignId: data?.id || userDetails?.[0]?._id,
3610
- coverage: 'user',
3611
- };
3612
- }
3613
- }
3614
- }
3615
-
3616
- // console.log( assignedData, 'test', data );
3617
- if ( assignedData && !data.upload && data.insert ) {
3618
- await taskAssignService.updateOne( { checkListId: assignedData.checkListId, assignId: assignedData.assignId }, assignedData );
3619
- } else {
3620
- return assignedData;
3621
- }
3622
- }
3623
-
3624
- export async function assignTaskUser( req, res ) {
3625
- try {
3626
- let inputBody = req.body;
3627
- let assignDetails = inputBody.assignUsers;
3628
- let newUsers = inputBody.newUsers;
3629
- let taskDetails = await taskService.findOne( { _id: inputBody.taskId } );
3630
- if ( !taskDetails ) {
3631
- return res.sendError( 'No data found', 204 );
3632
- }
3633
- // await Promise.all( newUsers.map( async ( user ) => {
3634
- // let getUser = inputBody.assignUsers.find( ( ele ) => ele.userEmail.toLowerCase() == user.toLowerCase() );
3635
- // let userData = {
3636
- // userName: getUser.userName,
3637
- // email: user,
3638
- // mobileNumber: getUser?.phone,
3639
- // clientId: inputBody.clientId,
3640
- // };
3641
- // await createUser( userData );
3642
- // } ) );
3643
- for ( let i = 0; i < newUsers.length; i++ ) {
3644
- let getUser = inputBody.assignUsers.find( ( ele ) => ele.userEmail.toLowerCase() == newUsers[i].toLowerCase() );
3645
- let userData = {
3646
- userName: getUser.userName,
3647
- email: newUsers[i],
3648
- mobileNumber: getUser?.phone,
3649
- clientId: inputBody.clientId,
3650
- };
3651
- await createUser( userData );
3652
- }
3653
- let assignData = [];
3654
- await Promise.all( assignDetails.map( async ( assign ) => {
3655
- assign.checklistId = inputBody.taskId;
3656
- assign.checkListName = taskDetails.checkListName;
3657
- assign.coverage = inputBody.coverage;
3658
- assign.clientId = inputBody.clientId;
3659
- assign.upload = inputBody.type;
3660
- let uploadData = await assignUsers( assign );
3661
- if ( uploadData ) {
3662
- if ( Array.isArray( uploadData ) ) {
3663
- assignData.push( ...uploadData );
3664
- } else {
3665
- assignData.push( uploadData );
3666
- }
3667
- }
3668
- } ) );
3669
- return res.sendSuccess( { idList: [ ...new Set( assignData.map( ( item ) => item?.assignId?.toString() ) ) ], assignData } );
3670
- } catch ( e ) {
3671
- logger.error( { functionName: 'assignTaskUser', error: e } );
3672
- return res.sendError( e, 500 );
3673
- }
3674
- }
3675
3260
 
3676
3261
  export async function customertrial( params ) {
3677
3262
  try {
@@ -28,9 +28,6 @@ taskRouter
28
28
  .get( '/teamMigrations', taskController.teamMigrations )
29
29
  .get( '/clusterMigrations', taskController.clusterMigrations )
30
30
  .post( '/createaiChecklist', isAllowedInternalAPIHandler, taskController.createAiChecklist )
31
- .post( '/createaiTask', isAllowedInternalAPIHandler, taskController.createAiTask )
32
- .post( '/assign', isAllowedSessionHandler, taskController.taskAssign )
33
- .post( '/assignUpload', isAllowedSessionHandler, taskController.assignTaskUser )
34
31
  .post( '/createaiTask', isAllowedInternalAPIHandler, validate( aitaskvalidation ), taskController.createAiTask )
35
32
  .post( '/StoreHygienetask', isAllowedInternalAPIHandler, validate( StoreHygienetaskvalidation ), taskController.StoreHygienetask )
36
33
  .post( '/eyeTesttask', isAllowedInternalAPIHandler, validate( eyeTesttaskvalidation ), taskController.eyeTesttask )
@@ -26,7 +26,6 @@ export async function createclusterModel( data ) {
26
26
  export async function findcluster( query, project ) {
27
27
  return await clusterModel.find( query, project );
28
28
  };
29
-
30
29
  export function countDocumentsClusters( query ) {
31
30
  return clusterModel.countDocuments( query );
32
31
  }
@@ -13,7 +13,7 @@ export const updateMany = async ( query = {}, record={} ) => {
13
13
  };
14
14
 
15
15
  export const updateOne = async ( query = {}, record={} ) => {
16
- return model.taskAssignModel.updateOne( query, { $set: record }, { upsert: true } );
16
+ return model.taskAssignModel.updateOne( query, { $set: record } );
17
17
  };
18
18
 
19
19
  export const insertMany = async ( data = [] ) => {
@@ -20,10 +20,6 @@ export const updateOne = async ( query = {}, record={} ) => {
20
20
  return model.userModel.updateOne( query, { $set: record } );
21
21
  };
22
22
 
23
- export const upsert = async ( query = {}, record={} ) => {
24
- return model.userModel.updateOne( query, { $set: record }, { upsert: true } );
25
- };
26
-
27
23
  export const aggregate = async ( query = {} ) => {
28
24
  return model.userModel.aggregate( query );
29
25
  };
@@ -1,30 +0,0 @@
1
- import teamsModel from 'tango-api-schema/schema/teams.model.js';
2
-
3
-
4
- export async function createTeamsModel( data ) {
5
- return await teamsModel.create( data );
6
- };
7
- export async function updateOneTeams( query, record ) {
8
- return await teamsModel.updateOne( query, { $set: record }, { upsert: true } );
9
- };
10
-
11
- export async function aggregateTeams( query ) {
12
- return await teamsModel.aggregate( query );
13
- };
14
- export async function deleteTeams( query ={} ) {
15
- return await teamsModel.deleteOne( query );
16
- };
17
-
18
- export async function findOneTeams( query ={}, field={} ) {
19
- return await teamsModel.findOne( query, field );
20
- };
21
- export async function findteams( query ={}, field={} ) {
22
- return await teamsModel.find( query, field );
23
- };
24
-
25
- export async function updateOneTeamModel( query, record ) {
26
- return await teamsModel.updateOne( query, record );
27
- }
28
- export function countDocumentsTeams( query ) {
29
- return teamsModel.countDocuments( query );
30
- }