tango-app-api-store-builder 1.0.0-beta-183 → 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-183",
3
+ "version": "1.0.0-beta-184",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1094,6 +1094,50 @@ export async function getRolloutFeedbackv2( req, res ) {
1094
1094
  merchRolloutComment: commentMap['merchRollout'] || [],
1095
1095
  vmRolloutComment: commentMap['vmRollout'] || [],
1096
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
+ } ) );
1097
1141
  res.sendSuccess( response );
1098
1142
  } catch ( e ) {
1099
1143
  logger.error( { functionName: 'getRolloutFeedbackv2', error: e } );
@@ -1134,11 +1178,12 @@ function pipelineStage( type, planoId, floorId, filterByStatus, filterByApproval
1134
1178
  {
1135
1179
  $match: {
1136
1180
  $expr: {
1137
- $eq: [ '$taskId', '$$taskId' ],
1181
+ $and: [
1182
+ { $eq: [ '$taskId', '$$taskId' ] },
1183
+ ],
1138
1184
  },
1139
1185
  },
1140
1186
  },
1141
-
1142
1187
  ],
1143
1188
  as: 'planoData',
1144
1189
  },
@@ -1168,13 +1213,6 @@ function pipelineStage( type, planoId, floorId, filterByStatus, filterByApproval
1168
1213
  },
1169
1214
  };
1170
1215
 
1171
- let unwindCommenTask = {
1172
- $unwind: {
1173
- path: '$commentData',
1174
- preserveNullAndEmptyArrays: true,
1175
- },
1176
- };
1177
-
1178
1216
 
1179
1217
  const commonLookups = type === 'layout' ? [] : [
1180
1218
  {
@@ -1212,55 +1250,6 @@ function pipelineStage( type, planoId, floorId, filterByStatus, filterByApproval
1212
1250
  },
1213
1251
  ];
1214
1252
 
1215
- const vmStages = [ 'vm', 'vmRollout' ].includes( type ) ? [
1216
- {
1217
- $unwind: { path: '$FixtureData.vmConfig', preserveNullAndEmptyArrays: true },
1218
- },
1219
- {
1220
- $lookup: {
1221
- from: 'planovmdetails',
1222
- let: { vmId: '$FixtureData.vmConfig.vmId' },
1223
- pipeline: [
1224
- {
1225
- $match: { $expr: { $eq: [ '$_id', '$$vmId' ] } },
1226
- },
1227
- {
1228
- $project: { vmName: 1, vmType: 1 },
1229
- },
1230
- ],
1231
- as: 'vmDetails',
1232
- },
1233
- },
1234
- {
1235
- $unwind: { path: '$vmDetails', preserveNullAndEmptyArrays: true },
1236
- },
1237
- {
1238
- $set: {
1239
- 'FixtureData.vmConfig.vmName': '$vmDetails.vmName',
1240
- 'FixtureData.vmConfig.vmType': '$vmDetails.vmType',
1241
- },
1242
- },
1243
- {
1244
- $group: {
1245
- _id: {
1246
- taskId: '$taskId',
1247
- fixtureId: '$FixtureData._id',
1248
- },
1249
- rootDoc: { $first: '$$ROOT' },
1250
- vmConfigs: { $push: '$FixtureData.vmConfig' },
1251
- },
1252
- },
1253
- {
1254
- $addFields: {
1255
- 'rootDoc.FixtureData.vmConfig': '$vmConfigs',
1256
- },
1257
- },
1258
- {
1259
- $replaceRoot: { newRoot: '$rootDoc' },
1260
- },
1261
-
1262
-
1263
- ] : [];
1264
1253
  let finalGrouping = [
1265
1254
  {
1266
1255
  $group: {
@@ -1328,9 +1317,9 @@ function pipelineStage( type, planoId, floorId, filterByStatus, filterByApproval
1328
1317
  taskLookup,
1329
1318
  unwindTask,
1330
1319
  commandLookup,
1331
- unwindCommenTask,
1320
+ // unwindCommenTask,
1332
1321
  ...commonLookups,
1333
- ...vmStages,
1322
+ // ...vmStages,
1334
1323
  ...finalGrouping,
1335
1324
  { $sort: { _id: 1 } },
1336
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 );