tango-app-api-store-builder 1.0.0-beta-118 → 1.0.0-beta-120

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-118",
3
+ "version": "1.0.0-beta-120",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -504,83 +504,82 @@ export async function updateFixtureStatus( req, res ) {
504
504
  }
505
505
  }
506
506
 
507
- export async function updateStoreFixture(req, res) {
507
+ export async function updateStoreFixture( req, res ) {
508
508
  try {
509
509
  const { fixtureId, data } = req.body;
510
510
 
511
- const currentFixture = await storeFixtureService.findOne({ _id: new mongoose.Types.ObjectId(fixtureId) });
512
- let currentFixtureDoc = currentFixture.toObject()
511
+ const currentFixture = await storeFixtureService.findOne( { _id: new mongoose.Types.ObjectId( fixtureId ) } );
512
+ let currentFixtureDoc = currentFixture.toObject();
513
513
 
514
514
  const productBrandName = new Set();
515
515
  const productCategory = new Set();
516
516
  const productSubCategory = new Set();
517
517
 
518
- data.shelfConfig.forEach((shelf) => {
519
- const { productBrandName: brand, productCategory: category, productSubCategory: subCategory } = shelf;
518
+ data.shelfConfig.forEach( ( shelf ) => {
519
+ const { productBrandName: brand, productCategory: category, productSubCategory: subCategory } = shelf;
520
520
 
521
- if (Array.isArray(brand)) {
522
- brand.forEach((b) => productBrandName.add(b));
523
- }
521
+ if ( Array.isArray( brand ) ) {
522
+ brand.forEach( ( b ) => productBrandName.add( b ) );
523
+ }
524
524
 
525
- if (Array.isArray(category)) {
526
- category.forEach((c) => productCategory.add(c));
527
- }
525
+ if ( Array.isArray( category ) ) {
526
+ category.forEach( ( c ) => productCategory.add( c ) );
527
+ }
528
528
 
529
- if (Array.isArray(subCategory)) {
530
- subCategory.forEach((s) => productSubCategory.add(s));
531
- }
532
- });
533
-
529
+ if ( Array.isArray( subCategory ) ) {
530
+ subCategory.forEach( ( s ) => productSubCategory.add( s ) );
531
+ }
532
+ } );
534
533
 
535
- if (currentFixtureDoc.fixtureConfigId.toString() !== data.fixtureConfigId) {
536
- const newTemplate = await fixtureConfigService.findOne({_id: new mongoose.Types.ObjectId(data.fixtureConfigId) })
534
+
535
+ if ( currentFixtureDoc.fixtureConfigId.toString() !== data.fixtureConfigId ) {
536
+ const newTemplate = await fixtureConfigService.findOne( { _id: data.fixtureConfigId } );
537
537
  currentFixtureDoc = {
538
538
  ...currentFixtureDoc,
539
539
  ...newTemplate.toObject(),
540
- fixtureConfigId:newTemplate.toObject()._id,
541
- productBrandName:[...productBrandName],
542
- productCategory:[...productCategory],
543
- productSubCategory:[...productSubCategory]
544
- }
545
- }else{
540
+ fixtureConfigDoc: newTemplate.toObject()._id,
541
+ productBrandName: [ ...productBrandName ],
542
+ productCategory: [ ...productCategory ],
543
+ productSubCategory: [ ...productSubCategory ],
544
+ };
545
+ } else {
546
546
  currentFixtureDoc = {
547
547
  ...currentFixtureDoc,
548
548
  ...data,
549
- productBrandName:[...productBrandName],
550
- productCategory:[...productCategory],
551
- productSubCategory:[...productSubCategory]
552
- }
549
+ productBrandName: [ ...productBrandName ],
550
+ productCategory: [ ...productCategory ],
551
+ productSubCategory: [ ...productSubCategory ],
552
+ };
553
553
  }
554
554
 
555
- delete currentFixtureDoc._id
555
+ delete currentFixtureDoc._id;
556
556
 
557
557
 
558
- await storeFixtureService.updateOne({ _id: new mongoose.Types.ObjectId(fixtureId) }, currentFixtureDoc);
558
+ await storeFixtureService.updateOne( { _id: new mongoose.Types.ObjectId( fixtureId ) }, currentFixtureDoc );
559
559
 
560
- if (data?.shelfConfig?.length) {
561
- await fixtureShelfService.deleteMany({ fixtureId: new mongoose.Types.ObjectId(fixtureId) })
560
+ if ( data?.shelfConfig?.length ) {
561
+ await fixtureShelfService.deleteMany( { fixtureId: new mongoose.Types.ObjectId( fixtureId ) } );
562
562
 
563
563
 
564
- data.shelfConfig.forEach(async (shelf) => {
565
- delete shelf?._id
564
+ data.shelfConfig.forEach( async ( shelf ) => {
565
+ delete shelf?._id;
566
566
  const additionalMeta = {
567
- clientId: currentFixture.clientId,
568
- storeId: currentFixture.storeId,
569
- storeName: currentFixture.storeName,
570
- planoId: currentFixture.planoId,
571
- floorId: currentFixture.floorId,
572
- fixtureId: currentFixture._id,
573
- }
574
-
575
- await fixtureShelfService.create({ ...additionalMeta, ...shelf });
576
- });
567
+ clientId: currentFixture.clientId,
568
+ storeId: currentFixture.storeId,
569
+ storeName: currentFixture.storeName,
570
+ planoId: currentFixture.planoId,
571
+ floorId: currentFixture.floorId,
572
+ fixtureId: currentFixture._id,
573
+ };
577
574
 
575
+ await fixtureShelfService.create( { ...additionalMeta, ...shelf } );
576
+ } );
578
577
  }
579
578
 
580
- res.sendSuccess('Updated Successfully');
581
- } catch (e) {
582
- logger.error({ functionName: 'updateStoreFixture', error: e });
583
- return res.sendError(e, 500);
579
+ res.sendSuccess( 'Updated Successfully' );
580
+ } catch ( e ) {
581
+ logger.error( { functionName: 'updateStoreFixture', error: e } );
582
+ return res.sendError( e, 500 );
584
583
  }
585
584
  }
586
585
 
@@ -16,6 +16,7 @@ import * as planoQrConversionRequestService from '../service/planoQrConversionRe
16
16
  import * as fixtureConfigService from '../service/fixtureConfig.service.js';
17
17
  import * as planoStaticData from '../service/planoStaticData.service.js';
18
18
  import * as planoVmService from '../service/planoVm.service.js';
19
+ import * as planotaskService from '../service/processedTaskservice.js';
19
20
 
20
21
 
21
22
  dayjs.extend( utc );
@@ -3053,7 +3054,7 @@ export async function storeFixturesTaskv2( req, res ) {
3053
3054
  status: compliance?.status ? compliance.status : '',
3054
3055
  shelfCount: shelves.length,
3055
3056
  productCount: productCount,
3056
- disabled: disabled,
3057
+ disabled: req?.body?.redo ? disabled : false,
3057
3058
  vmCount: vmCount,
3058
3059
  shelfConfig: shelfDetails,
3059
3060
  vmConfig: vmDetails,
@@ -3142,7 +3143,7 @@ export async function storeFixturesTaskv2( req, res ) {
3142
3143
  status: compliance?.status ? compliance.status : '',
3143
3144
  shelfCount: shelves.shelves,
3144
3145
  productCount: productCount,
3145
- disabled: disabled,
3146
+ disabled: req?.body?.redo ? disabled : false,
3146
3147
  vmCount: vmCount,
3147
3148
  shelfConfig: shelfDetails,
3148
3149
  vms: vmDetails,
@@ -3246,6 +3247,329 @@ export async function planoList( req, res ) {
3246
3247
  },
3247
3248
  },
3248
3249
  { $unwind: { path: '$fixtureDetails', preserveNullAndEmptyArrays: true } },
3250
+ {
3251
+ $lookup: {
3252
+ from: 'processedtasks',
3253
+ let: { plano: '$_id' },
3254
+ pipeline: [
3255
+ {
3256
+ $match: {
3257
+ $expr: {
3258
+ $and: [
3259
+ { $eq: [ '$planoId', '$$plano' ] },
3260
+ { isPlano: true },
3261
+ ],
3262
+ },
3263
+ },
3264
+ },
3265
+ {
3266
+ $group: {
3267
+ _id: '$planoType',
3268
+ dateString: { $last: '$date_string' },
3269
+ checklistStatus: { $last: '$checklistStatus' },
3270
+ },
3271
+ },
3272
+ ],
3273
+ as: 'planoTask',
3274
+ },
3275
+ },
3276
+ {
3277
+ $lookup: {
3278
+ from: 'planotaskcompliances',
3279
+ let: { plano: '$_id' },
3280
+ pipeline: [
3281
+ {
3282
+ $match: {
3283
+ $expr: {
3284
+ $eq: [ '$planoId', '$$plano' ],
3285
+ },
3286
+ },
3287
+ },
3288
+ { $sort: { _id: -1 } },
3289
+ {
3290
+ $group: {
3291
+ _id: { planoId: '$planoId', type: '$type' },
3292
+ layoutCount: {
3293
+ $sum: {
3294
+ $cond: {
3295
+ if: {
3296
+ $and: [
3297
+ { $eq: [ '$type', 'layout' ] },
3298
+ ],
3299
+ },
3300
+ then: 1,
3301
+ else: 0,
3302
+ },
3303
+ },
3304
+ },
3305
+ fixtureCount: {
3306
+ $sum: {
3307
+ $cond: {
3308
+ if: {
3309
+ $and: [
3310
+ {
3311
+ $eq: [ '$type', 'fixture' ],
3312
+ },
3313
+ ],
3314
+ },
3315
+ then: 1,
3316
+ else: 0,
3317
+ },
3318
+ },
3319
+ },
3320
+ vmCount: {
3321
+ $sum: {
3322
+ $cond: {
3323
+ if: {
3324
+ $and: [
3325
+ { $eq: [ '$type', 'vm' ] },
3326
+ ],
3327
+ },
3328
+ then: 1,
3329
+ else: 0,
3330
+ },
3331
+ },
3332
+ },
3333
+ layoutPending: {
3334
+ $sum: {
3335
+ $cond: {
3336
+ if: {
3337
+ $and: [
3338
+ {
3339
+ $eq: [ '$type', 'layout' ],
3340
+ },
3341
+ {
3342
+ $anyElementTrue: {
3343
+ $map: {
3344
+ input: {
3345
+ $reduce: {
3346
+ input: '$answers',
3347
+ initialValue: [],
3348
+ in: {
3349
+ $concatArrays: [
3350
+ '$$value',
3351
+ {
3352
+ $ifNull: [
3353
+ '$$this.issues',
3354
+ [],
3355
+ ],
3356
+ },
3357
+ ],
3358
+ },
3359
+ },
3360
+ },
3361
+ as: 'issue',
3362
+ in: {
3363
+ $eq: [
3364
+ '$$issue.status',
3365
+ 'pending',
3366
+ ],
3367
+ },
3368
+ },
3369
+ },
3370
+ },
3371
+ ],
3372
+ },
3373
+ then: 1,
3374
+ else: 0,
3375
+ },
3376
+ },
3377
+ },
3378
+ fixturePending: {
3379
+ $sum: {
3380
+ $cond: {
3381
+ if: {
3382
+ $and: [
3383
+ {
3384
+ $eq: [ '$type', 'fixture' ],
3385
+ },
3386
+ {
3387
+ $anyElementTrue: {
3388
+ $map: {
3389
+ input: {
3390
+ $reduce: {
3391
+ input: '$answers',
3392
+ initialValue: [],
3393
+ in: {
3394
+ $concatArrays: [
3395
+ '$$value',
3396
+ {
3397
+ $ifNull: [
3398
+ '$$this.issues',
3399
+ [],
3400
+ ],
3401
+ },
3402
+ ],
3403
+ },
3404
+ },
3405
+ },
3406
+ as: 'issue',
3407
+ in: {
3408
+ $eq: [
3409
+ '$$issue.status',
3410
+ 'pending',
3411
+ ],
3412
+ },
3413
+ },
3414
+ },
3415
+ },
3416
+ ],
3417
+ },
3418
+ then: 1,
3419
+ else: 0,
3420
+ },
3421
+ },
3422
+ },
3423
+ vmPending: {
3424
+ $sum: {
3425
+ $cond: {
3426
+ if: {
3427
+ $and: [
3428
+ {
3429
+ $eq: [ '$type', 'vm' ],
3430
+ },
3431
+ {
3432
+ $anyElementTrue: {
3433
+ $map: {
3434
+ input: {
3435
+ $reduce: {
3436
+ input: '$answers',
3437
+ initialValue: [],
3438
+ in: {
3439
+ $concatArrays: [
3440
+ '$$value',
3441
+ {
3442
+ $ifNull: [
3443
+ '$$this.issues',
3444
+ [],
3445
+ ],
3446
+ },
3447
+ ],
3448
+ },
3449
+ },
3450
+ },
3451
+ as: 'issue',
3452
+ in: {
3453
+ $eq: [
3454
+ '$$issue.status',
3455
+ 'pending',
3456
+ ],
3457
+ },
3458
+ },
3459
+ },
3460
+ },
3461
+ ],
3462
+ },
3463
+ then: 1,
3464
+ else: 0,
3465
+ },
3466
+ },
3467
+ },
3468
+ },
3469
+ },
3470
+ {
3471
+ $project: {
3472
+ _id: 0,
3473
+ layoutStatus: {
3474
+ $cond: {
3475
+ if: {
3476
+ $and: [
3477
+ { $gt: [ '$layoutCount', 0 ] },
3478
+ { $eq: [ '$layoutPending', 0 ] },
3479
+ ],
3480
+ },
3481
+ then: 'complete',
3482
+ else: {
3483
+ $cond: {
3484
+ if: {
3485
+ $and: [
3486
+ {
3487
+ $gt: [ '$layoutCount', 0 ],
3488
+ },
3489
+ {
3490
+ $gt: [
3491
+ '$layoutPending',
3492
+ 0,
3493
+ ],
3494
+ },
3495
+ ],
3496
+ },
3497
+ then: 'pending',
3498
+ else: '',
3499
+ },
3500
+ },
3501
+ },
3502
+ },
3503
+ fixtureStatus: {
3504
+ $cond: {
3505
+ if: {
3506
+ $and: [
3507
+ { $gt: [ '$fixtureCount', 0 ] },
3508
+ {
3509
+ $eq: [ '$fixturePending', 0 ],
3510
+ },
3511
+ ],
3512
+ },
3513
+ then: 'complete',
3514
+ else: {
3515
+ $cond: {
3516
+ if: {
3517
+ $and: [
3518
+ {
3519
+ $gt: [
3520
+ '$fixtureCount',
3521
+ 0,
3522
+ ],
3523
+ },
3524
+ {
3525
+ $gt: [
3526
+ '$fixturePending',
3527
+ 0,
3528
+ ],
3529
+ },
3530
+ ],
3531
+ },
3532
+ then: 'pending',
3533
+ else: '',
3534
+ },
3535
+ },
3536
+ },
3537
+ },
3538
+ vmStatus: {
3539
+ $cond: {
3540
+ if: {
3541
+ $and: [
3542
+ { $gt: [ '$vmCount', 0 ] },
3543
+ { $eq: [ '$vmPending', 0 ] },
3544
+ ],
3545
+ },
3546
+ then: 'complete',
3547
+ else: {
3548
+ $cond: {
3549
+ if: {
3550
+ $and: [
3551
+ { $gt: [ '$vmCount', 0 ] },
3552
+ { $gt: [ '$vmPending', 0 ] },
3553
+ ],
3554
+ },
3555
+ then: 'pending',
3556
+ else: '',
3557
+ },
3558
+ },
3559
+ },
3560
+ },
3561
+ layoutPending: 1,
3562
+ fixturePending: 1,
3563
+ vmPending: 1,
3564
+ layoutCount: 1,
3565
+ fixtureCount: 1,
3566
+ vmCount: 1,
3567
+ },
3568
+ },
3569
+ ],
3570
+ as: 'taskDetails',
3571
+ },
3572
+ },
3249
3573
  {
3250
3574
  $project: {
3251
3575
  storeName: 1,
@@ -3258,6 +3582,9 @@ export async function planoList( req, res ) {
3258
3582
  planoProgress: 1,
3259
3583
  createdAt: 1,
3260
3584
  lastUpdate: '$updatedAt',
3585
+ taskDetails: { $ifNull: [ { $arrayElemAt: [ '$taskDetails', 0 ] }, [] ] },
3586
+ planoTask: { $ifNull: [ '$planoTask', [] ] },
3587
+ layoutCount: { $size: '$layout.layoutDetails' },
3261
3588
  },
3262
3589
  },
3263
3590
  ];
@@ -3271,9 +3598,55 @@ export async function planoList( req, res ) {
3271
3598
  },
3272
3599
  } );
3273
3600
  }
3601
+ if ( inputData?.filter?.taskPending?.length ) {
3602
+ query.push( {
3603
+ $match: {
3604
+ ...( inputData.filter.taskPending == 'layout' ) ? { 'taskDetails.layoutStatus': 'pending', 'planoTask._id': 'layout', 'planoTask.checklistStatus': 'submit' } :{},
3605
+ ...( inputData.filter.taskPending == 'fixture' ) ? { 'taskDetails.fixtureStatus': 'pending', 'planoTask._id': 'fixture', 'planoTask.checklistStatus': 'submit' } :{},
3606
+ ...( inputData.filter.taskPending == 'vm' ) ? { 'taskDetails.vmStatus': 'pending', 'planoTask._id': 'vm', 'planoTask.checklistStatus': 'submit' } :{},
3607
+ },
3608
+ } );
3609
+ }
3610
+
3611
+ let orQuery = [];
3612
+
3613
+ if ( inputData.filter.status.length ) {
3614
+ if ( inputData.filter.status.includes( 'taskAssigned' ) ) {
3615
+ orQuery.push( { 'planoTask.checklistStatus': { $in: [ 'open', 'inprogress' ] } } );
3616
+ }
3617
+ if ( inputData.filter.status.includes( 'reviewPending' ) ) {
3618
+ orQuery.push( { $and: [ { 'taskDetails.layoutStatus': 'pending' }, { 'planoTask._id': 'layout' }, { 'planoTask.checklistStatus': 'submit' } ] } );
3619
+ orQuery.push( { $and: [ { 'taskDetails.fixtureStatus': 'pending' }, { 'planoTask._id': 'fixture' }, { 'planoTask.checklistStatus': 'submit' } ] } );
3620
+ orQuery.push( { $and: [ { 'taskDetails.vmStatus': 'pending' }, { 'planoTask._id': 'vm' }, { 'planoTask.checklistStatus': 'submit' } ] } );
3621
+ }
3622
+ if ( inputData.filter.status.includes( 'complete' ) ) {
3623
+ orQuery.push( { 'taskDetails.layoutStatus': 'complete' } );
3624
+ orQuery.push( { 'taskDetails.fixtureStatus': 'complete' } );
3625
+ orQuery.push( { 'taskDetails.vmStatus': 'complete' } );
3626
+ }
3627
+ if ( inputData.filter.status.includes( 'yetToAssign' ) ) {
3628
+ orQuery.push( { $expr: { $eq: [ { $size: '$planoTask' }, 0 ] } } );
3629
+ }
3630
+ }
3631
+
3632
+ if ( orQuery.length ) {
3633
+ query.push( {
3634
+ $match: {
3635
+ $or: orQuery,
3636
+ },
3637
+ } );
3638
+ }
3274
3639
 
3275
3640
  query.push( {
3276
3641
  $facet: {
3642
+ planoList: [
3643
+ {
3644
+ $group: {
3645
+ _id: '',
3646
+ planoIds: { $addToSet: '$_id' },
3647
+ },
3648
+ },
3649
+ ],
3277
3650
  data: [
3278
3651
  { $skip: skip },
3279
3652
  { $limit: limit },
@@ -3283,14 +3656,235 @@ export async function planoList( req, res ) {
3283
3656
  ],
3284
3657
  },
3285
3658
  } );
3659
+
3286
3660
  let planoDetails = await planoService.aggregate( query );
3287
3661
 
3288
3662
  if ( !planoDetails[0].data.length ) {
3289
3663
  return res.sendError( 'No data found', 204 );
3290
3664
  }
3665
+
3666
+ let planoList = await planoService.find( { clientId: req.body.clientId }, { _id: 1 } );
3667
+ let idList = planoList?.map( ( ele ) => new mongoose.Types.ObjectId( ele._id ) );
3668
+ let planoTaskDetails = await planotaskService.find( { planoId: { $in: idList }, checklistStatus: 'submit' } );
3669
+ idList = planoTaskDetails.map( ( ele ) => new mongoose.Types.ObjectId( ele.planoId ) );
3670
+ let taskQuery = [
3671
+ {
3672
+ $match: {
3673
+ planoId: { $in: idList },
3674
+ checklistStatus: 'submit',
3675
+ },
3676
+ },
3677
+ {
3678
+ $lookup: {
3679
+ from: 'planotaskcompliances',
3680
+ let: { plano: '$planoId', type: '$planoType' },
3681
+ pipeline: [
3682
+ {
3683
+ $match: {
3684
+ $expr: {
3685
+ $and: [
3686
+ { $eq: [ '$planoId', '$$plano' ] },
3687
+ { $eq: [ '$type', '$$type' ] },
3688
+ ],
3689
+ },
3690
+ },
3691
+ },
3692
+ {
3693
+ $group: {
3694
+ _id: { planoId: '$planoId', type: '$type' },
3695
+ layoutPending: {
3696
+ $sum: {
3697
+ $cond: {
3698
+ if: {
3699
+ $and: [
3700
+ {
3701
+ $eq: [ '$type', 'layout' ],
3702
+ },
3703
+ {
3704
+ $anyElementTrue: {
3705
+ $map: {
3706
+ input: {
3707
+ $reduce: {
3708
+ input: '$answers',
3709
+ initialValue: [],
3710
+ in: {
3711
+ $concatArrays: [
3712
+ '$$value',
3713
+ {
3714
+ $ifNull: [
3715
+ '$$this.issues',
3716
+ [],
3717
+ ],
3718
+ },
3719
+ ],
3720
+ },
3721
+ },
3722
+ },
3723
+ as: 'issue',
3724
+ in: {
3725
+ $eq: [
3726
+ '$$issue.status',
3727
+ 'pending',
3728
+ ],
3729
+ },
3730
+ },
3731
+ },
3732
+ },
3733
+ ],
3734
+ },
3735
+ then: 1,
3736
+ else: 0,
3737
+ },
3738
+ },
3739
+ },
3740
+ fixturePending: {
3741
+ $sum: {
3742
+ $cond: {
3743
+ if: {
3744
+ $and: [
3745
+ {
3746
+ $eq: [ '$type', 'fixture' ],
3747
+ },
3748
+ {
3749
+ $anyElementTrue: {
3750
+ $map: {
3751
+ input: {
3752
+ $reduce: {
3753
+ input: '$answers',
3754
+ initialValue: [],
3755
+ in: {
3756
+ $concatArrays: [
3757
+ '$$value',
3758
+ {
3759
+ $ifNull: [
3760
+ '$$this.issues',
3761
+ [],
3762
+ ],
3763
+ },
3764
+ ],
3765
+ },
3766
+ },
3767
+ },
3768
+ as: 'issue',
3769
+ in: {
3770
+ $eq: [
3771
+ '$$issue.status',
3772
+ 'pending',
3773
+ ],
3774
+ },
3775
+ },
3776
+ },
3777
+ },
3778
+ ],
3779
+ },
3780
+ then: 1,
3781
+ else: 0,
3782
+ },
3783
+ },
3784
+ },
3785
+ vmPending: {
3786
+ $sum: {
3787
+ $cond: {
3788
+ if: {
3789
+ $and: [
3790
+ {
3791
+ $eq: [ '$type', 'vm' ],
3792
+ },
3793
+ {
3794
+ $anyElementTrue: {
3795
+ $map: {
3796
+ input: {
3797
+ $reduce: {
3798
+ input: '$answers',
3799
+ initialValue: [],
3800
+ in: {
3801
+ $concatArrays: [
3802
+ '$$value',
3803
+ {
3804
+ $ifNull: [
3805
+ '$$this.issues',
3806
+ [],
3807
+ ],
3808
+ },
3809
+ ],
3810
+ },
3811
+ },
3812
+ },
3813
+ as: 'issue',
3814
+ in: {
3815
+ $eq: [
3816
+ '$$issue.status',
3817
+ 'pending',
3818
+ ],
3819
+ },
3820
+ },
3821
+ },
3822
+ },
3823
+ ],
3824
+ },
3825
+ then: 1,
3826
+ else: 0,
3827
+ },
3828
+ },
3829
+ },
3830
+ },
3831
+ },
3832
+ {
3833
+ $group: {
3834
+ _id: 0,
3835
+ layoutPending: {
3836
+ $sum: { $cond: {
3837
+ if: {
3838
+ $gt: [ '$layoutPending', 0 ],
3839
+ },
3840
+ then: 1,
3841
+ else: 0,
3842
+ } },
3843
+ },
3844
+ fixturePending: {
3845
+ $sum: { $cond: {
3846
+ if: {
3847
+ $gt: [ '$fixturePending', 0 ],
3848
+ },
3849
+ then: 1,
3850
+ else: 0,
3851
+ } },
3852
+ },
3853
+ vmPending: {
3854
+ $sum: { $cond: {
3855
+ if: {
3856
+ $gt: [ '$vmPending', 0 ],
3857
+ },
3858
+ then: 1,
3859
+ else: 0,
3860
+ } },
3861
+ },
3862
+ },
3863
+ },
3864
+ ],
3865
+ as: 'taskFeedback',
3866
+ },
3867
+ },
3868
+ {
3869
+ $project: {
3870
+ _id: 0,
3871
+ taskFeedback: { $ifNull: [ { $arrayElemAt: [ '$taskFeedback', 0 ] }, [] ] },
3872
+ },
3873
+ },
3874
+ {
3875
+ $project: {
3876
+ layoutPending: '$taskFeedback.layoutPending',
3877
+ fixturePending: '$taskFeedback.fixturePending',
3878
+ vmPending: '$taskFeedback.vmPending',
3879
+ },
3880
+ },
3881
+ ];
3882
+
3883
+ let pendingDetails = await planotaskService.aggregate( taskQuery );
3291
3884
  let result = {
3292
3885
  data: planoDetails[0].data,
3293
3886
  count: planoDetails?.[0]?.count?.[0]?.total || 0,
3887
+ pendingDetails: [ { ...pendingDetails?.[0], allStores: planoList?.length || 0 } ],
3294
3888
  };
3295
3889
  return res.sendSuccess( result );
3296
3890
  } catch ( e ) {
@@ -414,12 +414,12 @@ export async function uploadImage( req, res ) {
414
414
  if ( !req.files.file ) {
415
415
  return res.sendError( 'Please upload a file', 400 );
416
416
  }
417
-
417
+ console.log( req.files );
418
418
  let params = {
419
419
  Bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
420
420
  Key: `${req.body.taskId}/${req.body.qno}/${Date.now()}/`,
421
421
  fileName: req.files.file.name,
422
- ContentType: req.files.file.mimeType,
422
+ ContentType: req.files.file.mimeType?req.files.file.mimeType:req.files.file.mimetypes,
423
423
  body: req.files.file.data,
424
424
  };
425
425
  let fileRes = await fileUpload( params );