tango-app-api-store-builder 1.0.0-beta-178 → 1.0.0-beta-180

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.
@@ -3064,8 +3064,9 @@ export async function storeFixturesTaskv2( req, res ) {
3064
3064
  } ) );
3065
3065
 
3066
3066
  let disabled = true;
3067
- if ( compliance?.status && compliance.status == 'incomplete' ) {
3067
+ if ( compliance?.status ) {
3068
3068
  const hasDisagree = compliance?.answers?.some( ( answer ) =>
3069
+ answer?.status === 'disagree' ||
3069
3070
  answer?.issues?.some( ( issue ) =>
3070
3071
  issue?.Details?.some( ( detail ) => detail.status === 'disagree' ),
3071
3072
  ),
@@ -3164,8 +3165,9 @@ export async function storeFixturesTaskv2( req, res ) {
3164
3165
  } ) );
3165
3166
 
3166
3167
  let disabled = true;
3167
- if ( compliance?.status && compliance.status == 'incomplete' ) {
3168
+ if ( compliance?.status ) {
3168
3169
  const hasDisagree = compliance?.answers?.some( ( answer ) =>
3170
+ answer?.status === 'disagree' ||
3169
3171
  answer?.issues?.some( ( issue ) =>
3170
3172
  issue?.Details?.some( ( detail ) => detail.status === 'disagree' ),
3171
3173
  ),
@@ -4677,7 +4679,7 @@ export async function getRolloutDetails( req, res ) {
4677
4679
  { $eq: [ '$floorId', '$$floorId' ] },
4678
4680
  { $in: [ '$taskId', '$$taskId' ] },
4679
4681
  { $in: [ '$type', [ 'merchRollout', 'vmRollout' ] ] },
4680
- { $eq: [ '$status', 'incomplete' ] },
4682
+ // { $eq: [ '$status', 'incomplete' ] },
4681
4683
  ],
4682
4684
  },
4683
4685
  },
@@ -4691,32 +4693,37 @@ export async function getRolloutDetails( req, res ) {
4691
4693
  $anyElementTrue: {
4692
4694
  $map: {
4693
4695
  input: {
4694
- $reduce: {
4695
- input: '$answers',
4696
- initialValue: [],
4697
- in: {
4698
- $concatArrays: [
4699
- '$$value',
4700
- {
4701
- $reduce: {
4702
- input: { $ifNull: [ '$$this.issues', [] ] },
4703
- initialValue: [],
4704
- in: {
4705
- $concatArrays: [
4706
- '$$value',
4707
- { $ifNull: [ '$$this.Details', [] ] },
4708
- ],
4696
+ $concatArrays: [
4697
+ '$answers', // include top-level answers (so we can check answers.status)
4698
+ {
4699
+ $reduce: {
4700
+ input: '$answers',
4701
+ initialValue: [],
4702
+ in: {
4703
+ $concatArrays: [
4704
+ '$$value',
4705
+ {
4706
+ $reduce: {
4707
+ input: { $ifNull: [ '$$this.issues', [] ] },
4708
+ initialValue: [],
4709
+ in: {
4710
+ $concatArrays: [
4711
+ '$$value',
4712
+ { $ifNull: [ '$$this.Details', [] ] },
4713
+ ],
4714
+ },
4715
+ },
4709
4716
  },
4710
- },
4717
+ ],
4711
4718
  },
4712
- ],
4719
+ },
4713
4720
  },
4714
- },
4721
+ ],
4715
4722
  },
4716
4723
  as: 'detail',
4717
4724
  in: {
4718
4725
  $or: [
4719
- { $eq: [ '$$detail.status', 'pending' ] },
4726
+ { $eq: [ '$$detail.status', 'pending' ] }, // works for both answers and details
4720
4727
  ],
4721
4728
  },
4722
4729
  },
@@ -4726,27 +4733,32 @@ export async function getRolloutDetails( req, res ) {
4726
4733
  $anyElementTrue: {
4727
4734
  $map: {
4728
4735
  input: {
4729
- $reduce: {
4730
- input: '$answers',
4731
- initialValue: [],
4732
- in: {
4733
- $concatArrays: [
4734
- '$$value',
4735
- {
4736
- $reduce: {
4737
- input: { $ifNull: [ '$$this.issues', [] ] },
4738
- initialValue: [],
4739
- in: {
4740
- $concatArrays: [
4741
- '$$value',
4742
- { $ifNull: [ '$$this.Details', [] ] },
4743
- ],
4736
+ $concatArrays: [
4737
+ '$answers',
4738
+ {
4739
+ $reduce: {
4740
+ input: '$answers',
4741
+ initialValue: [],
4742
+ in: {
4743
+ $concatArrays: [
4744
+ '$$value',
4745
+ {
4746
+ $reduce: {
4747
+ input: { $ifNull: [ '$$this.issues', [] ] },
4748
+ initialValue: [],
4749
+ in: {
4750
+ $concatArrays: [
4751
+ '$$value',
4752
+ { $ifNull: [ '$$this.Details', [] ] },
4753
+ ],
4754
+ },
4755
+ },
4744
4756
  },
4745
- },
4757
+ ],
4746
4758
  },
4747
- ],
4759
+ },
4748
4760
  },
4749
- },
4761
+ ],
4750
4762
  },
4751
4763
  as: 'detail',
4752
4764
  in: {
@@ -4761,47 +4773,15 @@ export async function getRolloutDetails( req, res ) {
4761
4773
  },
4762
4774
  {
4763
4775
  $group: {
4764
- _id: '$floorId',
4765
- merchCount: {
4766
- $sum: { $cond: [ { $eq: [ '$type', 'merchRollout' ] }, 1, 0 ] },
4767
- },
4768
- vmCount: {
4769
- $sum: { $cond: [ { $eq: [ '$type', 'vmRollout' ] }, 1, 0 ] },
4770
- },
4771
- merchPending: {
4772
- $sum: {
4773
- $cond: [
4774
- { $and: [ { $eq: [ '$type', 'merchRollout' ] }, '$hasPendingIssues' ] },
4775
- 1,
4776
- 0,
4777
- ],
4778
- },
4779
- },
4780
- vmPending: {
4781
- $sum: {
4782
- $cond: [
4783
- { $and: [ { $eq: [ '$type', 'vmRollout' ] }, '$hasPendingIssues' ] },
4784
- 1,
4785
- 0,
4786
- ],
4787
- },
4788
- },
4789
- merchDisagree: {
4790
- $sum: {
4791
- $cond: [
4792
- { $and: [ { $eq: [ '$type', 'merchRollout' ] }, '$hasDisagreeIssues' ] },
4793
- 1,
4794
- 0,
4795
- ],
4776
+ _id: '',
4777
+ merch: {
4778
+ $max: {
4779
+ $cond: [ { $eq: [ '$type', 'merchRollout' ] }, '$$ROOT', null ],
4796
4780
  },
4797
4781
  },
4798
- vmDisagree: {
4799
- $sum: {
4800
- $cond: [
4801
- { $and: [ { $eq: [ '$type', 'vmRollout' ] }, '$hasDisagreeIssues' ] },
4802
- 1,
4803
- 0,
4804
- ],
4782
+ vm: {
4783
+ $max: {
4784
+ $cond: [ { $eq: [ '$type', 'vmRollout' ] }, '$$ROOT', null ],
4805
4785
  },
4806
4786
  },
4807
4787
  },
@@ -4813,30 +4793,58 @@ export async function getRolloutDetails( req, res ) {
4813
4793
  $switch: {
4814
4794
  branches: [
4815
4795
  {
4816
- case: { $and: [ { $gt: [ '$merchCount', 0 ] }, { $gt: [ '$merchPending', 0 ] } ] },
4796
+ case: { $eq: [ '$merch', null ] },
4797
+ then: '',
4798
+ },
4799
+ {
4800
+ case: '$merch.hasPendingIssues',
4817
4801
  then: 'pending',
4818
4802
  },
4819
4803
  {
4820
- case: { $and: [ { $gt: [ '$merchCount', 0 ] }, { $gt: [ '$merchDisagree', 0 ] } ] },
4804
+ case: '$merch.hasDisagreeIssues',
4821
4805
  then: 'disagree',
4822
4806
  },
4807
+ {
4808
+ case: {
4809
+ $and: [
4810
+ { $eq: [ '$merch.hasPendingIssues', false ] },
4811
+ { $eq: [ '$merch.hasDisagreeIssues', false ] },
4812
+ { $eq: [ '$merch.approvalStatus', 'approved' ] },
4813
+ ],
4814
+ },
4815
+ then: 'complete',
4816
+ },
4823
4817
  ],
4824
- default: '',
4818
+ default: 'pending',
4825
4819
  },
4826
4820
  },
4827
4821
  vmStatus: {
4828
4822
  $switch: {
4829
4823
  branches: [
4830
4824
  {
4831
- case: { $and: [ { $gt: [ '$vmCount', 0 ] }, { $gt: [ '$vmPending', 0 ] } ] },
4825
+ case: { $eq: [ '$vm', null ] },
4826
+ then: '',
4827
+ },
4828
+ {
4829
+ case: '$vm.hasPendingIssues',
4832
4830
  then: 'pending',
4833
4831
  },
4834
4832
  {
4835
- case: { $and: [ { $gt: [ '$vmCount', 0 ] }, { $gt: [ '$vmDisagree', 0 ] } ] },
4833
+ case: '$vm.hasDisagreeIssues',
4836
4834
  then: 'disagree',
4837
4835
  },
4836
+ {
4837
+ case: {
4838
+ $and: [
4839
+ { $eq: [ '$vm.hasPendingIssues', false ] },
4840
+ { $eq: [ '$vm.hasDisagreeIssues', false ] },
4841
+ { $eq: [ '$vm.approvalStatus', 'approved' ] },
4842
+ ],
4843
+ },
4844
+ then: 'complete',
4845
+ },
4838
4846
  ],
4839
- default: '',
4847
+ default: 'pending',
4840
4848
  },
4841
4849
  },
4842
4850
  },
@@ -5203,8 +5211,9 @@ export async function getRolloutTaskDetails( req, res ) {
5203
5211
  $expr: {
5204
5212
  $and: [
5205
5213
  { $eq: [ '$planoId', new mongoose.Types.ObjectId( req.query.planoId ) ] },
5214
+ { $eq: [ '$floorId', new mongoose.Types.ObjectId( req.query.floorId ) ] },
5206
5215
  { $in: [ '$taskId', '$$task' ] },
5207
- { $eq: [ '$status', 'incomplete' ] },
5216
+ // { $eq: [ '$status', 'incomplete' ] },
5208
5217
  { $in: [ '$type', [ 'merchRollout', 'vmRollout' ] ] },
5209
5218
  ],
5210
5219
  },
@@ -5217,32 +5226,37 @@ export async function getRolloutTaskDetails( req, res ) {
5217
5226
  $anyElementTrue: {
5218
5227
  $map: {
5219
5228
  input: {
5220
- $reduce: {
5221
- input: '$answers',
5222
- initialValue: [],
5223
- in: {
5224
- $concatArrays: [
5225
- '$$value',
5226
- {
5227
- $reduce: {
5228
- input: { $ifNull: [ '$$this.issues', [] ] },
5229
- initialValue: [],
5230
- in: {
5231
- $concatArrays: [
5232
- '$$value',
5233
- { $ifNull: [ '$$this.Details', [] ] },
5234
- ],
5229
+ $concatArrays: [
5230
+ '$answers', // include top-level answers (so we can check answers.status)
5231
+ {
5232
+ $reduce: {
5233
+ input: '$answers',
5234
+ initialValue: [],
5235
+ in: {
5236
+ $concatArrays: [
5237
+ '$$value',
5238
+ {
5239
+ $reduce: {
5240
+ input: { $ifNull: [ '$$this.issues', [] ] },
5241
+ initialValue: [],
5242
+ in: {
5243
+ $concatArrays: [
5244
+ '$$value',
5245
+ { $ifNull: [ '$$this.Details', [] ] },
5246
+ ],
5247
+ },
5248
+ },
5235
5249
  },
5236
- },
5250
+ ],
5237
5251
  },
5238
- ],
5252
+ },
5239
5253
  },
5240
- },
5254
+ ],
5241
5255
  },
5242
5256
  as: 'detail',
5243
5257
  in: {
5244
5258
  $or: [
5245
- { $eq: [ '$$detail.status', 'pending' ] },
5259
+ { $eq: [ '$$detail.status', 'pending' ] }, // works for both answers and details
5246
5260
  ],
5247
5261
  },
5248
5262
  },
@@ -5252,27 +5266,32 @@ export async function getRolloutTaskDetails( req, res ) {
5252
5266
  $anyElementTrue: {
5253
5267
  $map: {
5254
5268
  input: {
5255
- $reduce: {
5256
- input: '$answers',
5257
- initialValue: [],
5258
- in: {
5259
- $concatArrays: [
5260
- '$$value',
5261
- {
5262
- $reduce: {
5263
- input: { $ifNull: [ '$$this.issues', [] ] },
5264
- initialValue: [],
5265
- in: {
5266
- $concatArrays: [
5267
- '$$value',
5268
- { $ifNull: [ '$$this.Details', [] ] },
5269
- ],
5269
+ $concatArrays: [
5270
+ '$answers',
5271
+ {
5272
+ $reduce: {
5273
+ input: '$answers',
5274
+ initialValue: [],
5275
+ in: {
5276
+ $concatArrays: [
5277
+ '$$value',
5278
+ {
5279
+ $reduce: {
5280
+ input: { $ifNull: [ '$$this.issues', [] ] },
5281
+ initialValue: [],
5282
+ in: {
5283
+ $concatArrays: [
5284
+ '$$value',
5285
+ { $ifNull: [ '$$this.Details', [] ] },
5286
+ ],
5287
+ },
5288
+ },
5270
5289
  },
5271
- },
5290
+ ],
5272
5291
  },
5273
- ],
5292
+ },
5274
5293
  },
5275
- },
5294
+ ],
5276
5295
  },
5277
5296
  as: 'detail',
5278
5297
  in: {
@@ -5287,47 +5306,15 @@ export async function getRolloutTaskDetails( req, res ) {
5287
5306
  },
5288
5307
  {
5289
5308
  $group: {
5290
- _id: '$floorId',
5291
- merchCount: {
5292
- $sum: { $cond: [ { $eq: [ '$type', 'merchRollout' ] }, 1, 0 ] },
5293
- },
5294
- vmCount: {
5295
- $sum: { $cond: [ { $eq: [ '$type', 'vmRollout' ] }, 1, 0 ] },
5296
- },
5297
- merchPending: {
5298
- $sum: {
5299
- $cond: [
5300
- { $and: [ { $eq: [ '$type', 'merchRollout' ] }, '$hasPendingIssues' ] },
5301
- 1,
5302
- 0,
5303
- ],
5304
- },
5305
- },
5306
- vmPending: {
5307
- $sum: {
5308
- $cond: [
5309
- { $and: [ { $eq: [ '$type', 'vmRollout' ] }, '$hasPendingIssues' ] },
5310
- 1,
5311
- 0,
5312
- ],
5313
- },
5314
- },
5315
- merchDisagree: {
5316
- $sum: {
5317
- $cond: [
5318
- { $and: [ { $eq: [ '$type', 'merchRollout' ] }, '$hasDisagreeIssues' ] },
5319
- 1,
5320
- 0,
5321
- ],
5309
+ _id: '',
5310
+ merch: {
5311
+ $max: {
5312
+ $cond: [ { $eq: [ '$type', 'merchRollout' ] }, '$$ROOT', null ],
5322
5313
  },
5323
5314
  },
5324
- vmDisagree: {
5325
- $sum: {
5326
- $cond: [
5327
- { $and: [ { $eq: [ '$type', 'vmRollout' ] }, '$hasDisagreeIssues' ] },
5328
- 1,
5329
- 0,
5330
- ],
5315
+ vm: {
5316
+ $max: {
5317
+ $cond: [ { $eq: [ '$type', 'vmRollout' ] }, '$$ROOT', null ],
5331
5318
  },
5332
5319
  },
5333
5320
  },
@@ -5336,94 +5323,61 @@ export async function getRolloutTaskDetails( req, res ) {
5336
5323
  $project: {
5337
5324
  _id: 0,
5338
5325
  merchStatus: {
5339
- $cond: {
5340
- if: {
5341
- $and: [
5342
- { $gt: [ '$merchCount', 0 ] },
5343
- { $eq: [ '$merchPending', 0 ] },
5344
- { $eq: [ '$merchDisagree', 0 ] },
5345
- ],
5346
- },
5347
- then: 'complete',
5348
- else: {
5349
- $cond: {
5350
- if: {
5326
+ $switch: {
5327
+ branches: [
5328
+ {
5329
+ case: { $eq: [ '$merch', null ] },
5330
+ then: '',
5331
+ },
5332
+ {
5333
+ case: '$merch.hasPendingIssues',
5334
+ then: 'pending',
5335
+ },
5336
+ {
5337
+ case: '$merch.hasDisagreeIssues',
5338
+ then: 'disagree',
5339
+ },
5340
+ {
5341
+ case: {
5351
5342
  $and: [
5352
- {
5353
- $gt: [ '$merchCount', 0 ],
5354
- },
5355
- {
5356
- $gt: [
5357
- '$merchPending',
5358
- 0,
5359
- ],
5360
- },
5343
+ { $eq: [ '$merch.hasPendingIssues', false ] },
5344
+ { $eq: [ '$merch.hasDisagreeIssues', false ] },
5345
+ { $eq: [ '$merch.approvalStatus', 'approved' ] },
5361
5346
  ],
5362
5347
  },
5363
- then: 'pending',
5364
- else: {
5365
- $cond: {
5366
- if: {
5367
- $and: [
5368
- {
5369
- $gt: [ '$merchCount', 0 ],
5370
- },
5371
- {
5372
- $gt: [
5373
- '$merchDisagree',
5374
- 0,
5375
- ],
5376
- },
5377
- ],
5378
- },
5379
- then: 'disagree',
5380
- else: '',
5381
- },
5382
- },
5348
+ then: 'complete',
5383
5349
  },
5384
- },
5350
+ ],
5351
+ default: 'pending',
5385
5352
  },
5386
5353
  },
5387
5354
  vmStatus: {
5388
- $cond: {
5389
- if: {
5390
- $and: [
5391
- { $gt: [ '$vmCount', 0 ] },
5392
- { $eq: [ '$vmPending', 0 ] },
5393
- { $eq: [ '$vmDisagree', 0 ] },
5394
- ],
5395
- },
5396
- then: 'complete',
5397
- else: {
5398
- $cond: {
5399
- if: {
5355
+ $switch: {
5356
+ branches: [
5357
+ {
5358
+ case: { $eq: [ '$vm', null ] },
5359
+ then: '',
5360
+ },
5361
+ {
5362
+ case: '$vm.hasPendingIssues',
5363
+ then: 'pending',
5364
+ },
5365
+ {
5366
+ case: '$vm.hasDisagreeIssues',
5367
+ then: 'disagree',
5368
+ },
5369
+ {
5370
+ case: {
5400
5371
  $and: [
5401
- { $gt: [ '$vmCount', 0 ] },
5402
- { $gt: [ '$vmPending', 0 ] },
5372
+ { $eq: [ '$vm.hasPendingIssues', false ] },
5373
+ { $eq: [ '$vm.hasDisagreeIssues', false ] },
5374
+ { $eq: [ '$vm.approvalStatus', 'approved' ] },
5403
5375
  ],
5404
5376
  },
5405
- then: 'pending',
5406
- else: {
5407
- $cond: {
5408
- if: {
5409
- $and: [
5410
- {
5411
- $gt: [ '$vmCount', 0 ],
5412
- },
5413
- {
5414
- $gt: [
5415
- '$vmDisagree',
5416
- 0,
5417
- ],
5418
- },
5419
- ],
5420
- },
5421
- then: 'disagree',
5422
- else: '',
5423
- },
5424
- },
5377
+ then: 'complete',
5425
5378
  },
5426
- },
5379
+ ],
5380
+ default: 'pending',
5427
5381
  },
5428
5382
  },
5429
5383
  },
@@ -5480,7 +5434,7 @@ export async function getRolloutTaskDetails( req, res ) {
5480
5434
  await storeFixtureService.count( { floorId: req.query.floorId, isMerchEdited: true } ),
5481
5435
  await storeFixtureService.count( { floorId: req.query.floorId, isVmEdited: true } ),
5482
5436
  ] );
5483
- return res.sendSuccess( { taskDetails: taskInfo?.[0]?.taskStatus || [], merchCount, vmCount } );
5437
+ return res.sendSuccess( { taskDetails: taskInfo[0]?.taskStatus || [], merchCount, vmCount } );
5484
5438
  } catch ( e ) {
5485
5439
  logger.error( { functionName: 'getTaskDetails', error: e } );
5486
5440
  return res.sendError( e, 500 );