tango-app-api-trax 3.4.1-activitylog-7 → 3.4.1-activitylog-9

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.4.1-activitylog-7",
3
+ "version": "3.4.1-activitylog-9",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -559,6 +559,8 @@ export const getChecklistFromZipId = async ( req, res ) => {
559
559
  resultData.questions = getzipdata.questions;
560
560
  resultData.insertType = getzipdata.insertType;
561
561
  resultData.status = getzipdata.status;
562
+ resultData.fromDate = getzipdata.fromDate;
563
+ resultData.toDate = getzipdata.toDate;
562
564
  return res.sendSuccess( resultData );
563
565
  }
564
566
  } else {
@@ -344,7 +344,7 @@ export const create = async ( req, res ) => {
344
344
  return res.sendError( e, 500 );
345
345
  } );
346
346
  } catch ( e ) {
347
- console.log( 'e', e );
347
+ // console.log( 'e', e );
348
348
  logger.error( 'create =>', e );
349
349
  return res.sendError( e, 500 );
350
350
  }
@@ -2387,7 +2387,7 @@ export const validateUserv1 = async ( req, res ) => {
2387
2387
  }, {} );
2388
2388
 
2389
2389
  const duplicateUsers = Object.keys( duplicateUser ).filter( ( storeName ) => duplicateUser[storeName].count > 1 );
2390
- console.log( duplicateUsers, 'user' );
2390
+ // console.log( duplicateUsers, 'user' );
2391
2391
  if ( duplicateUsers.length ) {
2392
2392
  return res.sendError( { validate: false, duplicates: duplicateUsers, message: 'Email is Duplicated' }, 400 );
2393
2393
  }
@@ -3352,7 +3352,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
3352
3352
  if ( getCLconfig.coverage == 'store' ) {
3353
3353
  let clusterList = allQuestion.filter( ( ele ) => ele?.clusterName ).map( ( item ) => item.assignId );
3354
3354
  if ( clusterList.length ) {
3355
- let clusterDetails = await clusterServices.findcluster( { _id: { $in: clusterList } } );
3355
+ let clusterDetails = await clusterServices.findcluster( { _id: { $in: clusterList }, clientId: getCLconfig.client_id } );
3356
3356
  if ( clusterDetails.length ) {
3357
3357
  let idList = clusterDetails.flatMap( ( item ) => item.stores.map( ( ele ) => ele.store ) );
3358
3358
  let getStoreDetails = await storeService.find( { _id: { $in: idList }, status: 'active' } );
@@ -3419,7 +3419,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
3419
3419
  if ( getCLconfig.coverage == 'user' ) {
3420
3420
  let teamsList = allQuestion.filter( ( ele ) => ele?.teamName ).map( ( item ) => item.assignId );
3421
3421
  if ( teamsList.length ) {
3422
- let teamDetails = await teamsServices.findteams( { _id: { $in: teamsList } } );
3422
+ let teamDetails = await teamsServices.findteams( { _id: { $in: teamsList }, clientId: getCLconfig.client_id } );
3423
3423
  if ( teamDetails.length ) {
3424
3424
  let idList = [ ...teamDetails.flatMap( ( item ) => item.users.map( ( ele ) => ele.userId ) ), ...teamDetails.flatMap( ( item ) => item.Teamlead.map( ( ele ) => ele.userId ) ) ];
3425
3425
  let userIdList = allQuestion.filter( ( qn ) => !qn?.teamName ).map( ( qn ) => qn.assignId.toString() );
@@ -3536,7 +3536,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
3536
3536
  }
3537
3537
  if ( getsubmitDetails ) {
3538
3538
  getsubmitDetails = [ getsubmitDetails ];
3539
- console.log( submittedDetails, getsubmitDetails );
3539
+ // console.log( submittedDetails, getsubmitDetails );
3540
3540
  }
3541
3541
  function findDifferences( obj1, obj2 ) {
3542
3542
  return Object.keys( obj1 ).reduce( ( diff, key ) => {
@@ -4071,7 +4071,7 @@ export const selectAssign = async ( req, res ) => {
4071
4071
  }
4072
4072
  return res.sendSuccess( { 'totalCount': resuldData.length, 'data': resuldData } );
4073
4073
  } catch ( e ) {
4074
- console.log( 'e =>', e );
4074
+ // console.log( 'e =>', e );
4075
4075
  logger.error( 'selectAssign =>', e );
4076
4076
  return res.sendError( e, 500 );
4077
4077
  }
@@ -4083,7 +4083,9 @@ async function assignUsers( data ) {
4083
4083
  let clusterDetails = await clusterServices.findcluster( { clientId: data.clientId, _id: new mongoose.Types.ObjectId( data.id ) } );
4084
4084
  if ( clusterDetails.length ) {
4085
4085
  let clusterList = clusterDetails[0].stores.map( ( ele ) => ele.store );
4086
+ // console.log( clusterList );
4086
4087
  let storeDetails = await storeService.find( { _id: { $in: clusterList }, status: 'active' } );
4088
+ // console.log( storeDetails.length );
4087
4089
  assignedData = await Promise.all( storeDetails.map( async ( store ) => {
4088
4090
  let userData = {
4089
4091
  storeId: store.storeId,
@@ -4091,7 +4093,7 @@ async function assignUsers( data ) {
4091
4093
  userName: store.spocDetails?.[0]?.name,
4092
4094
  userEmail: store.spocDetails?.[0]?.email,
4093
4095
  clusterName: clusterDetails?.[0]?.clusterName,
4094
- id: clusterDetails?.[0]?._id,
4096
+ id: [ clusterDetails?.[0]?._id ],
4095
4097
  };
4096
4098
  return userData;
4097
4099
  } ) );
@@ -4106,7 +4108,7 @@ async function assignUsers( data ) {
4106
4108
  userName: user.userName,
4107
4109
  userEmail: user.email,
4108
4110
  teamName: teamDetails?.[0]?.teamName,
4109
- id: teamDetails?.[0]?._id,
4111
+ id: [ teamDetails?.[0]?._id ],
4110
4112
  };
4111
4113
  return userData;
4112
4114
  } );
@@ -4144,12 +4146,12 @@ export async function checklistAssign( req, res ) {
4144
4146
  uniqueArr.push( ...uploadData );
4145
4147
  }
4146
4148
  } ) );
4147
-
4148
4149
  if ( uniqueArr.length ) {
4149
4150
  if ( req.body.coverage == 'store' ) {
4150
4151
  uniqueArr = uniqueArr.reduce( ( acc, obj ) => {
4151
4152
  if ( acc[obj.storeName] ) {
4152
4153
  acc[obj.storeName].clusterName += ',' + obj.clusterName;
4154
+ acc[obj.storeName].id.push( ...obj.id );
4153
4155
  } else {
4154
4156
  acc[obj.storeName] = { ...obj };
4155
4157
  }
@@ -4161,6 +4163,7 @@ export async function checklistAssign( req, res ) {
4161
4163
  uniqueArr = uniqueArr.reduce( ( acc, obj ) => {
4162
4164
  if ( acc[obj.userEmail] ) {
4163
4165
  acc[obj.userEmail].teamName += ','+ obj.teamName;
4166
+ acc[obj.userEmail].id.push( ...obj.id );
4164
4167
  } else {
4165
4168
  acc[obj.userEmail] = { ...obj };
4166
4169
  }
@@ -4186,18 +4189,25 @@ export async function updateAssign( req, res ) {
4186
4189
  if ( !checklistDetails ) {
4187
4190
  return res.sendError( 'No data found', 204 );
4188
4191
  }
4189
- let groupList = req.body.assignedGroup;
4190
- req.body.assignedGroup = [ ...new Set( req.body.assignedGroup.map( ( item ) => item.id ) ) ];
4191
- groupList = req.body.assignedGroup.reduce( ( acc, ele ) => {
4192
- let findDetails = groupList.find( ( item ) => item.id == ele );
4193
- if ( findDetails ) {
4194
- acc.push( findDetails?.clusterName || findDetails?.teamName );
4195
- };
4196
- return acc;
4197
- }, [] );
4198
- // req.body.assignedGroup = req.body.assignedGroup.map( ( ele ) => {
4199
- // return { id: ele };
4200
- // } );
4192
+ let groupList = [];
4193
+ let groupAssignList = req.body.assignedGroup;
4194
+ req.body.assignedGroup = [ ...new Set( req.body.assignedGroup.flatMap( ( item ) => item.id ) ) ];
4195
+
4196
+ groupAssignList.forEach( ( ele ) => {
4197
+ let gName;
4198
+ if ( ele?.clusterName ) {
4199
+ gName = ele.clusterName.split( ',' );
4200
+ }
4201
+ if ( ele?.teamName ) {
4202
+ gName = ele.teamName.split( ',' );
4203
+ }
4204
+ gName.forEach( ( name ) => {
4205
+ if ( !groupList.includes( name ) ) {
4206
+ groupList.push( name );
4207
+ }
4208
+ } );
4209
+ } );
4210
+
4201
4211
  let getAssignedDetails = await assignedService.find( { checkListId: req.body.checkListId } );
4202
4212
  let oldCoverage;
4203
4213
  if ( getAssignedDetails.length ) {