tango-app-api-store-builder 1.0.0-beta-182 → 1.0.0-beta-184

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-store-builder",
3
- "version": "1.0.0-beta-182",
3
+ "version": "1.0.0-beta-184",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -72,7 +72,7 @@ export async function updateTemplate( req, res ) {
72
72
  if ( !templateDetails ) {
73
73
  return res.sendError( 'No data found', 204 );
74
74
  }
75
- let checkName = await fixtureConfigService.find( { _id: { $nin: req.params.templateId }, fixtureName: inputData.fixtureName } );
75
+ let checkName = await fixtureConfigService.findOne( { _id: { $ne: req.params.templateId }, fixtureName: inputData.fixtureName } );
76
76
  if ( checkName ) {
77
77
  return res.sendError( 'Fixture name already exist', 400 );
78
78
  }
@@ -1022,6 +1022,12 @@ export async function getRolloutFeedback( req, res ) {
1022
1022
  const filterByApprovalStatus = req.body.filterByApprovalStatus || '';
1023
1023
  const resultMap = {};
1024
1024
  const commentMap = {};
1025
+ if ( req.body.redo ) {
1026
+ let taskDetails = await planoTaskService.findOne( { taskId: req.body.taskId, fixtureId: req.body.fixtureId } );
1027
+ if ( !taskDetails ) {
1028
+ req.body.taskId = req.body.refTaskId;
1029
+ }
1030
+ }
1025
1031
  await Promise.all(
1026
1032
  taskTypes.map( async ( type, index ) => {
1027
1033
  const pipeline = buildPipelineByType( type, req.body.planoId, req.body.floorId, filterByStatus, filterByApprovalStatus, req.body.showtask, req.body.taskId );
@@ -1088,6 +1094,50 @@ export async function getRolloutFeedbackv2( req, res ) {
1088
1094
  merchRolloutComment: commentMap['merchRollout'] || [],
1089
1095
  vmRolloutComment: commentMap['vmRollout'] || [],
1090
1096
  };
1097
+ if ( filterByStatus.length || filterByApprovalStatus ) {
1098
+ let data = response[`${req.body.type}RolloutData`].filter( ( ele ) => ele.storeFixtureList.length );
1099
+ if ( filterByStatus.length == 1 ) {
1100
+ data = data.filter( ( type ) => {
1101
+ let fixtureList = type.storeFixtureList.filter( ( ele ) => filterByStatus.includes( ele.status ) );
1102
+ if ( filterByStatus.includes( 'complete' ) ) {
1103
+ return type.storeFixtureList.length == fixtureList.length;
1104
+ } else {
1105
+ return fixtureList.length;
1106
+ }
1107
+ },
1108
+ );
1109
+ }
1110
+ if ( filterByApprovalStatus ) {
1111
+ if ( filterByApprovalStatus === 'pending' ) {
1112
+ data = data.filter( ( type ) => {
1113
+ let fixtureList = type.storeFixtureList.filter( ( ele ) => {
1114
+ if ( ele.status === 'complete' && !ele.answers?.[0]?.issues.length && !ele.answers?.[0]?.status ) {
1115
+ return true;
1116
+ } else {
1117
+ return ele.answers?.some( ( ans ) =>
1118
+ ans.issues?.some( ( issue ) =>
1119
+ issue?.Details?.some( ( detail ) => detail.status === 'pending' ),
1120
+ ),
1121
+ );
1122
+ }
1123
+ } );
1124
+
1125
+ return fixtureList.length;
1126
+ } );
1127
+ }
1128
+ }
1129
+ response[`${req.body.type}RolloutData`] = data;
1130
+ }
1131
+ response.vmRolloutData = await Promise.all( response.vmRolloutData.map( async ( ele ) => {
1132
+ ele.storeFixtureList = await Promise.all( ele.storeFixtureList.map( async ( fixt ) => {
1133
+ fixt.FixtureData.vmConfig = await Promise.all( fixt.FixtureData.vmConfig.map( async ( config ) => {
1134
+ let vmDetails = await planoVmService.findOne( { _id: config.vmId }, { vmType: 1, vmName: 1 } );
1135
+ return { ...config, vmType: vmDetails.vmType, vmName: vmDetails.vmName };
1136
+ } ) );
1137
+ return fixt;
1138
+ } ) );
1139
+ return ele;
1140
+ } ) );
1091
1141
  res.sendSuccess( response );
1092
1142
  } catch ( e ) {
1093
1143
  logger.error( { functionName: 'getRolloutFeedbackv2', error: e } );
@@ -1128,11 +1178,12 @@ function pipelineStage( type, planoId, floorId, filterByStatus, filterByApproval
1128
1178
  {
1129
1179
  $match: {
1130
1180
  $expr: {
1131
- $eq: [ '$taskId', '$$taskId' ],
1181
+ $and: [
1182
+ { $eq: [ '$taskId', '$$taskId' ] },
1183
+ ],
1132
1184
  },
1133
1185
  },
1134
1186
  },
1135
-
1136
1187
  ],
1137
1188
  as: 'planoData',
1138
1189
  },
@@ -1162,13 +1213,6 @@ function pipelineStage( type, planoId, floorId, filterByStatus, filterByApproval
1162
1213
  },
1163
1214
  };
1164
1215
 
1165
- let unwindCommenTask = {
1166
- $unwind: {
1167
- path: '$commentData',
1168
- preserveNullAndEmptyArrays: true,
1169
- },
1170
- };
1171
-
1172
1216
 
1173
1217
  const commonLookups = type === 'layout' ? [] : [
1174
1218
  {
@@ -1206,55 +1250,6 @@ function pipelineStage( type, planoId, floorId, filterByStatus, filterByApproval
1206
1250
  },
1207
1251
  ];
1208
1252
 
1209
- const vmStages = [ 'vm', 'vmRollout' ].includes( type ) ? [
1210
- {
1211
- $unwind: { path: '$FixtureData.vmConfig', preserveNullAndEmptyArrays: true },
1212
- },
1213
- {
1214
- $lookup: {
1215
- from: 'planovmdetails',
1216
- let: { vmId: '$FixtureData.vmConfig.vmId' },
1217
- pipeline: [
1218
- {
1219
- $match: { $expr: { $eq: [ '$_id', '$$vmId' ] } },
1220
- },
1221
- {
1222
- $project: { vmName: 1, vmType: 1 },
1223
- },
1224
- ],
1225
- as: 'vmDetails',
1226
- },
1227
- },
1228
- {
1229
- $unwind: { path: '$vmDetails', preserveNullAndEmptyArrays: true },
1230
- },
1231
- {
1232
- $set: {
1233
- 'FixtureData.vmConfig.vmName': '$vmDetails.vmName',
1234
- 'FixtureData.vmConfig.vmType': '$vmDetails.vmType',
1235
- },
1236
- },
1237
- {
1238
- $group: {
1239
- _id: {
1240
- taskId: '$taskId',
1241
- fixtureId: '$FixtureData._id',
1242
- },
1243
- rootDoc: { $first: '$$ROOT' },
1244
- vmConfigs: { $push: '$FixtureData.vmConfig' },
1245
- },
1246
- },
1247
- {
1248
- $addFields: {
1249
- 'rootDoc.FixtureData.vmConfig': '$vmConfigs',
1250
- },
1251
- },
1252
- {
1253
- $replaceRoot: { newRoot: '$rootDoc' },
1254
- },
1255
-
1256
-
1257
- ] : [];
1258
1253
  let finalGrouping = [
1259
1254
  {
1260
1255
  $group: {
@@ -1322,9 +1317,9 @@ function pipelineStage( type, planoId, floorId, filterByStatus, filterByApproval
1322
1317
  taskLookup,
1323
1318
  unwindTask,
1324
1319
  commandLookup,
1325
- unwindCommenTask,
1320
+ // unwindCommenTask,
1326
1321
  ...commonLookups,
1327
- ...vmStages,
1322
+ // ...vmStages,
1328
1323
  ...finalGrouping,
1329
1324
  { $sort: { _id: 1 } },
1330
1325
  ];
@@ -142,8 +142,8 @@ export async function createTask( req, res ) {
142
142
  delete payload._id;
143
143
  delete payload.createdAt;
144
144
  delete payload.updatedAt;
145
- await processedService.create( payload );
146
- return res.sendSuccess( 'Task redo triggered successfully' );
145
+ let response = await processedService.create( payload );
146
+ return res.sendSuccess( { message: 'Task redo triggered successfully', taskId: response?._id } );
147
147
  } else {
148
148
  if ( !req.body?.checkListName ) {
149
149
  return res.sendError( 'ChecklistName is required', 400 );