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

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-184",
3
+ "version": "1.0.0-beta-186",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -32,7 +32,7 @@
32
32
  "path": "^0.12.7",
33
33
  "selenium-webdriver": "^4.31.0",
34
34
  "sharp": "^0.34.1",
35
- "tango-api-schema": "^2.3.19",
35
+ "tango-api-schema": "^2.3.22",
36
36
  "tango-app-api-middleware": "3.1.48",
37
37
  "url": "^0.11.4",
38
38
  "winston": "^3.17.0",
@@ -1055,6 +1055,7 @@ export async function getRolloutFeedback( req, res ) {
1055
1055
  const comments = await planoGlobalCommentService.find( {
1056
1056
  planoId: new mongoose.Types.ObjectId( req.body.planoId ),
1057
1057
  floorId: new mongoose.Types.ObjectId( req.body.floorId ),
1058
+ taskId: { $in: [ new mongoose.Types.ObjectId( req.body.taskId ), new mongoose.Types.ObjectId( req.body.req.body.refTaskId ) ] },
1058
1059
  taskType: type,
1059
1060
  } );
1060
1061
  commentMap[type] = comments;
@@ -1122,6 +1123,22 @@ export async function getRolloutFeedbackv2( req, res ) {
1122
1123
  }
1123
1124
  } );
1124
1125
 
1126
+ return fixtureList.length;
1127
+ } );
1128
+ } else {
1129
+ data = data.filter( ( type ) => {
1130
+ let fixtureList = type.storeFixtureList.filter( ( ele ) => {
1131
+ if ( ele.status === 'complete' && !ele.answers?.[0]?.issues.length && ele.answers?.[0]?.status ) {
1132
+ return true;
1133
+ } else {
1134
+ return ele.answers?.some( ( ans ) =>
1135
+ ans.issues?.some( ( issue ) =>
1136
+ issue?.Details?.some( ( detail ) => detail.status !== 'pending' ),
1137
+ ),
1138
+ );
1139
+ }
1140
+ } );
1141
+
1125
1142
  return fixtureList.length;
1126
1143
  } );
1127
1144
  }
@@ -1280,8 +1297,8 @@ function pipelineStage( type, planoId, floorId, filterByStatus, filterByApproval
1280
1297
  },
1281
1298
  ],
1282
1299
  },
1283
- { $gt: [ { $size: { $ifNull: [ '$Fixtureshelves', [] ] } }, 0 ] },
1284
- { $gt: [ { $size: { $ifNull: [ '$FixtureData.shelfConfig', [] ] } }, 0 ] },
1300
+ // { $gt: [ { $size: { $ifNull: [ '$Fixtureshelves', [] ] } }, 0 ] },
1301
+ // { $gt: [ { $size: { $ifNull: [ '$FixtureData.shelfConfig', [] ] } }, 0 ] },
1285
1302
  ],
1286
1303
  },
1287
1304
  {
@@ -4689,12 +4689,20 @@ export async function getRolloutDetails( req, res ) {
4689
4689
  },
4690
4690
  {
4691
4691
  $set: {
4692
+ hasCompletedAnswers: {
4693
+ $anyElementTrue: {
4694
+ $map: {
4695
+ input: '$answers',
4696
+ as: 'ans',
4697
+ in: { $eq: [ '$$ans.status', null ] },
4698
+ },
4699
+ },
4700
+ },
4692
4701
  hasPendingIssues: {
4693
4702
  $anyElementTrue: {
4694
4703
  $map: {
4695
4704
  input: {
4696
4705
  $concatArrays: [
4697
- '$answers', // include top-level answers (so we can check answers.status)
4698
4706
  {
4699
4707
  $reduce: {
4700
4708
  input: '$answers',
@@ -4722,9 +4730,7 @@ export async function getRolloutDetails( req, res ) {
4722
4730
  },
4723
4731
  as: 'detail',
4724
4732
  in: {
4725
- $or: [
4726
- { $eq: [ '$$detail.status', 'pending' ] }, // works for both answers and details
4727
- ],
4733
+ $or: [ { $eq: [ '$$detail.status', 'pending' ] } ],
4728
4734
  },
4729
4735
  },
4730
4736
  },
@@ -4762,9 +4768,7 @@ export async function getRolloutDetails( req, res ) {
4762
4768
  },
4763
4769
  as: 'detail',
4764
4770
  in: {
4765
- $or: [
4766
- { $eq: [ '$$detail.status', 'disagree' ] },
4767
- ],
4771
+ $or: [ { $eq: [ '$$detail.status', 'disagree' ] } ],
4768
4772
  },
4769
4773
  },
4770
4774
  },
@@ -4773,15 +4777,95 @@ export async function getRolloutDetails( req, res ) {
4773
4777
  },
4774
4778
  {
4775
4779
  $group: {
4776
- _id: '',
4777
- merch: {
4778
- $max: {
4779
- $cond: [ { $eq: [ '$type', 'merchRollout' ] }, '$$ROOT', null ],
4780
+ _id: { taskId: '$taskId' },
4781
+
4782
+ // merch counters
4783
+ merchDisagree: {
4784
+ $sum: {
4785
+ $cond: [
4786
+ { $and: [ { $eq: [ '$type', 'merchRollout' ] }, '$hasDisagreeIssues' ] },
4787
+ 1,
4788
+ 0,
4789
+ ],
4780
4790
  },
4781
4791
  },
4782
- vm: {
4783
- $max: {
4784
- $cond: [ { $eq: [ '$type', 'vmRollout' ] }, '$$ROOT', null ],
4792
+ merchPending: {
4793
+ $sum: {
4794
+ $cond: [
4795
+ {
4796
+ $and: [
4797
+ { $eq: [ '$type', 'merchRollout' ] },
4798
+ { $or: [ '$hasPendingIssues', '$hasCompletedAnswers' ] },
4799
+ ],
4800
+ },
4801
+ 1,
4802
+ 0,
4803
+ ],
4804
+ },
4805
+ },
4806
+ merchApproved: {
4807
+ $push: {
4808
+ $cond: [
4809
+ {
4810
+ $and: [
4811
+ { $eq: [ '$type', 'merchRollout' ] },
4812
+ { $eq: [ '$approvalStatus', 'approved' ] },
4813
+ ],
4814
+ },
4815
+ '$approvalStatus',
4816
+ '$$REMOVE',
4817
+ ],
4818
+ },
4819
+ },
4820
+
4821
+ // vm counters
4822
+ vmDisagree: {
4823
+ $sum: {
4824
+ $cond: [
4825
+ { $and: [ { $eq: [ '$type', 'vmRollout' ] }, '$hasDisagreeIssues' ] },
4826
+ 1,
4827
+ 0,
4828
+ ],
4829
+ },
4830
+ },
4831
+ vmPending: {
4832
+ $sum: {
4833
+ $cond: [
4834
+ {
4835
+ $and: [
4836
+ { $eq: [ '$type', 'vmRollout' ] },
4837
+ { $or: [ '$hasPendingIssues', '$hasCompletedAnswers' ] },
4838
+ ],
4839
+ },
4840
+ 1,
4841
+ 0,
4842
+ ],
4843
+ },
4844
+ },
4845
+ vmApproved: {
4846
+ $push: {
4847
+ $cond: [
4848
+ {
4849
+ $and: [
4850
+ { $eq: [ '$type', 'vmRollout' ] },
4851
+ { $eq: [ '$approvalStatus', 'approved' ] },
4852
+ ],
4853
+ },
4854
+ '$approvalStatus',
4855
+ '$$REMOVE',
4856
+ ],
4857
+ },
4858
+ },
4859
+
4860
+ // counts
4861
+ merchCount: {
4862
+ $sum: {
4863
+ $cond: [ { $eq: [ '$type', 'merchRollout' ] }, 1, 0 ],
4864
+ },
4865
+ },
4866
+ vmCount: {
4867
+ $sum: {
4868
+ $cond: [ { $eq: [ '$type', 'vmRollout' ] }, 1, 0 ],
4785
4869
  },
4786
4870
  },
4787
4871
  },
@@ -4793,23 +4877,23 @@ export async function getRolloutDetails( req, res ) {
4793
4877
  $switch: {
4794
4878
  branches: [
4795
4879
  {
4796
- case: { $eq: [ '$merch', null ] },
4880
+ case: { $eq: [ '$merchCount', 0 ] },
4797
4881
  then: '',
4798
4882
  },
4799
4883
  {
4800
- case: '$merch.hasPendingIssues',
4884
+ case: { $gt: [ '$merchPending', 0 ] },
4801
4885
  then: 'pending',
4802
4886
  },
4803
4887
  {
4804
- case: '$merch.hasDisagreeIssues',
4888
+ case: { $gt: [ '$merchDisagree', 0 ] },
4805
4889
  then: 'disagree',
4806
4890
  },
4807
4891
  {
4808
4892
  case: {
4809
4893
  $and: [
4810
- { $eq: [ '$merch.hasPendingIssues', false ] },
4811
- { $eq: [ '$merch.hasDisagreeIssues', false ] },
4812
- { $eq: [ '$merch.approvalStatus', 'approved' ] },
4894
+ { $eq: [ '$merchPending', 0 ] },
4895
+ { $eq: [ '$merchDisagree', 0 ] },
4896
+ { $eq: [ { $size: '$merchApproved' }, '$merchCount' ] },
4813
4897
  ],
4814
4898
  },
4815
4899
  then: 'complete',
@@ -4822,23 +4906,23 @@ export async function getRolloutDetails( req, res ) {
4822
4906
  $switch: {
4823
4907
  branches: [
4824
4908
  {
4825
- case: { $eq: [ '$vm', null ] },
4909
+ case: { $eq: [ '$vmCount', 0 ] },
4826
4910
  then: '',
4827
4911
  },
4828
4912
  {
4829
- case: '$vm.hasPendingIssues',
4913
+ case: { $gt: [ '$vmPending', 0 ] },
4830
4914
  then: 'pending',
4831
4915
  },
4832
4916
  {
4833
- case: '$vm.hasDisagreeIssues',
4917
+ case: { $gt: [ '$vmDisagree', 0 ] },
4834
4918
  then: 'disagree',
4835
4919
  },
4836
4920
  {
4837
4921
  case: {
4838
4922
  $and: [
4839
- { $eq: [ '$vm.hasPendingIssues', false ] },
4840
- { $eq: [ '$vm.hasDisagreeIssues', false ] },
4841
- { $eq: [ '$vm.approvalStatus', 'approved' ] },
4923
+ { $eq: [ '$vmPending', 0 ] },
4924
+ { $eq: [ '$vmDisagree', 0 ] },
4925
+ { $eq: [ { $size: '$vmApproved' }, '$vmCount' ] },
4842
4926
  ],
4843
4927
  },
4844
4928
  then: 'complete',
@@ -4985,15 +5069,15 @@ export async function getRolloutDetails( req, res ) {
4985
5069
  $and: [
4986
5070
  {
4987
5071
  $or: [
4988
- { $and: [ { taskDetails: { $elemMatch: { type: 'merchRollout', status: 'submit' } } }, { merchEditedCount: 0 } ] },
4989
- { $and: [ { taskDetails: { $elemMatch: { type: 'vmRollout', status: 'submit' } } }, { vmEditedCount: 0 } ] },
5072
+ { $and: [ { taskDetails: { $elemMatch: { type: 'merchRollout', status: 'submit' } } }, { merchEditedCount: 0 }, { 'taskFeedback.fixtureStatus': 'complete' } ] },
5073
+ { $and: [ { taskDetails: { $elemMatch: { type: 'vmRollout', status: 'submit' } } }, { vmEditedCount: 0 }, { 'taskFeedback.vmStatus': 'complete' } ] },
4990
5074
  ],
4991
5075
  },
4992
- {
4993
- $expr: {
4994
- $eq: [ { $size: { $objectToArray: '$taskFeedback' } }, 0 ],
4995
- },
4996
- },
5076
+ // {
5077
+ // $expr: {
5078
+ // $eq: [ { $size: { $objectToArray: '$taskFeedback' } }, 0 ],
5079
+ // },
5080
+ // },
4997
5081
  ],
4998
5082
  } );
4999
5083
  }
@@ -5222,12 +5306,20 @@ export async function getRolloutTaskDetails( req, res ) {
5222
5306
  { $sort: { _id: -1 } },
5223
5307
  {
5224
5308
  $set: {
5309
+ hasCompletedAnswers: {
5310
+ $anyElementTrue: {
5311
+ $map: {
5312
+ input: '$answers',
5313
+ as: 'ans',
5314
+ in: { $eq: [ '$$ans.status', null ] },
5315
+ },
5316
+ },
5317
+ },
5225
5318
  hasPendingIssues: {
5226
5319
  $anyElementTrue: {
5227
5320
  $map: {
5228
5321
  input: {
5229
5322
  $concatArrays: [
5230
- '$answers', // include top-level answers (so we can check answers.status)
5231
5323
  {
5232
5324
  $reduce: {
5233
5325
  input: '$answers',
@@ -5255,9 +5347,7 @@ export async function getRolloutTaskDetails( req, res ) {
5255
5347
  },
5256
5348
  as: 'detail',
5257
5349
  in: {
5258
- $or: [
5259
- { $eq: [ '$$detail.status', 'pending' ] }, // works for both answers and details
5260
- ],
5350
+ $or: [ { $eq: [ '$$detail.status', 'pending' ] } ],
5261
5351
  },
5262
5352
  },
5263
5353
  },
@@ -5295,9 +5385,7 @@ export async function getRolloutTaskDetails( req, res ) {
5295
5385
  },
5296
5386
  as: 'detail',
5297
5387
  in: {
5298
- $or: [
5299
- { $eq: [ '$$detail.status', 'disagree' ] },
5300
- ],
5388
+ $or: [ { $eq: [ '$$detail.status', 'disagree' ] } ],
5301
5389
  },
5302
5390
  },
5303
5391
  },
@@ -5306,15 +5394,95 @@ export async function getRolloutTaskDetails( req, res ) {
5306
5394
  },
5307
5395
  {
5308
5396
  $group: {
5309
- _id: '',
5310
- merch: {
5311
- $max: {
5312
- $cond: [ { $eq: [ '$type', 'merchRollout' ] }, '$$ROOT', null ],
5397
+ _id: { taskId: '$taskId' },
5398
+
5399
+ // merch counters
5400
+ merchDisagree: {
5401
+ $sum: {
5402
+ $cond: [
5403
+ { $and: [ { $eq: [ '$type', 'merchRollout' ] }, '$hasDisagreeIssues' ] },
5404
+ 1,
5405
+ 0,
5406
+ ],
5407
+ },
5408
+ },
5409
+ merchPending: {
5410
+ $sum: {
5411
+ $cond: [
5412
+ {
5413
+ $and: [
5414
+ { $eq: [ '$type', 'merchRollout' ] },
5415
+ { $or: [ '$hasPendingIssues', '$hasCompletedAnswers' ] },
5416
+ ],
5417
+ },
5418
+ 1,
5419
+ 0,
5420
+ ],
5421
+ },
5422
+ },
5423
+ merchApproved: {
5424
+ $push: {
5425
+ $cond: [
5426
+ {
5427
+ $and: [
5428
+ { $eq: [ '$type', 'merchRollout' ] },
5429
+ { $eq: [ '$approvalStatus', 'approved' ] },
5430
+ ],
5431
+ },
5432
+ '$approvalStatus',
5433
+ '$$REMOVE',
5434
+ ],
5435
+ },
5436
+ },
5437
+
5438
+ // vm counters
5439
+ vmDisagree: {
5440
+ $sum: {
5441
+ $cond: [
5442
+ { $and: [ { $eq: [ '$type', 'vmRollout' ] }, '$hasDisagreeIssues' ] },
5443
+ 1,
5444
+ 0,
5445
+ ],
5446
+ },
5447
+ },
5448
+ vmPending: {
5449
+ $sum: {
5450
+ $cond: [
5451
+ {
5452
+ $and: [
5453
+ { $eq: [ '$type', 'vmRollout' ] },
5454
+ { $or: [ '$hasPendingIssues', '$hasCompletedAnswers' ] },
5455
+ ],
5456
+ },
5457
+ 1,
5458
+ 0,
5459
+ ],
5313
5460
  },
5314
5461
  },
5315
- vm: {
5316
- $max: {
5317
- $cond: [ { $eq: [ '$type', 'vmRollout' ] }, '$$ROOT', null ],
5462
+ vmApproved: {
5463
+ $push: {
5464
+ $cond: [
5465
+ {
5466
+ $and: [
5467
+ { $eq: [ '$type', 'vmRollout' ] },
5468
+ { $eq: [ '$approvalStatus', 'approved' ] },
5469
+ ],
5470
+ },
5471
+ '$approvalStatus',
5472
+ '$$REMOVE',
5473
+ ],
5474
+ },
5475
+ },
5476
+
5477
+ // counts
5478
+ merchCount: {
5479
+ $sum: {
5480
+ $cond: [ { $eq: [ '$type', 'merchRollout' ] }, 1, 0 ],
5481
+ },
5482
+ },
5483
+ vmCount: {
5484
+ $sum: {
5485
+ $cond: [ { $eq: [ '$type', 'vmRollout' ] }, 1, 0 ],
5318
5486
  },
5319
5487
  },
5320
5488
  },
@@ -5326,23 +5494,23 @@ export async function getRolloutTaskDetails( req, res ) {
5326
5494
  $switch: {
5327
5495
  branches: [
5328
5496
  {
5329
- case: { $eq: [ '$merch', null ] },
5497
+ case: { $eq: [ '$merchCount', 0 ] },
5330
5498
  then: '',
5331
5499
  },
5332
5500
  {
5333
- case: '$merch.hasPendingIssues',
5501
+ case: { $gt: [ '$merchPending', 0 ] },
5334
5502
  then: 'pending',
5335
5503
  },
5336
5504
  {
5337
- case: '$merch.hasDisagreeIssues',
5505
+ case: { $gt: [ '$merchDisagree', 0 ] },
5338
5506
  then: 'disagree',
5339
5507
  },
5340
5508
  {
5341
5509
  case: {
5342
5510
  $and: [
5343
- { $eq: [ '$merch.hasPendingIssues', false ] },
5344
- { $eq: [ '$merch.hasDisagreeIssues', false ] },
5345
- { $eq: [ '$merch.approvalStatus', 'approved' ] },
5511
+ { $eq: [ '$merchPending', 0 ] },
5512
+ { $eq: [ '$merchDisagree', 0 ] },
5513
+ { $eq: [ { $size: '$merchApproved' }, '$merchCount' ] },
5346
5514
  ],
5347
5515
  },
5348
5516
  then: 'complete',
@@ -5355,23 +5523,23 @@ export async function getRolloutTaskDetails( req, res ) {
5355
5523
  $switch: {
5356
5524
  branches: [
5357
5525
  {
5358
- case: { $eq: [ '$vm', null ] },
5526
+ case: { $eq: [ '$vmCount', 0 ] },
5359
5527
  then: '',
5360
5528
  },
5361
5529
  {
5362
- case: '$vm.hasPendingIssues',
5530
+ case: { $gt: [ '$vmPending', 0 ] },
5363
5531
  then: 'pending',
5364
5532
  },
5365
5533
  {
5366
- case: '$vm.hasDisagreeIssues',
5534
+ case: { $gt: [ '$vmDisagree', 0 ] },
5367
5535
  then: 'disagree',
5368
5536
  },
5369
5537
  {
5370
5538
  case: {
5371
5539
  $and: [
5372
- { $eq: [ '$vm.hasPendingIssues', false ] },
5373
- { $eq: [ '$vm.hasDisagreeIssues', false ] },
5374
- { $eq: [ '$vm.approvalStatus', 'approved' ] },
5540
+ { $eq: [ '$vmPending', 0 ] },
5541
+ { $eq: [ '$vmDisagree', 0 ] },
5542
+ { $eq: [ { $size: '$vmApproved' }, '$vmCount' ] },
5375
5543
  ],
5376
5544
  },
5377
5545
  then: 'complete',
@@ -5434,7 +5602,7 @@ export async function getRolloutTaskDetails( req, res ) {
5434
5602
  await storeFixtureService.count( { floorId: req.query.floorId, isMerchEdited: true } ),
5435
5603
  await storeFixtureService.count( { floorId: req.query.floorId, isVmEdited: true } ),
5436
5604
  ] );
5437
- return res.sendSuccess( { taskDetails: taskInfo[0]?.taskStatus || [], merchCount, vmCount } );
5605
+ return res.sendSuccess( { taskDetails: taskInfo?.[0]?.taskStatus || [], merchCount, vmCount } );
5438
5606
  } catch ( e ) {
5439
5607
  logger.error( { functionName: 'getTaskDetails', error: e } );
5440
5608
  return res.sendError( e, 500 );