tango-app-api-store-builder 1.0.0-beta-50 → 1.0.0-beta-52

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-50",
3
+ "version": "1.0.0-beta-52",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -568,6 +568,7 @@ export async function storeFixturesv1( req, res ) {
568
568
 
569
569
  const floorsWithFixtures = await Promise.all(
570
570
  floors.map( async ( floor ) => {
571
+ let productCapacity = 0;
571
572
  const layoutPolygonWithFixtures = await Promise.all(
572
573
  floor.layoutPolygon.map( async ( element ) => {
573
574
  const fixtures = await storeFixtureService.find( {
@@ -588,6 +589,7 @@ export async function storeFixturesv1( req, res ) {
588
589
  } else {
589
590
  fixture.imageUrl = '';
590
591
  }
592
+ productCapacity += fixture.toObject().fixtureCapacity;
591
593
  const productCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'product' } );
592
594
 
593
595
  const vmCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'vm' } );
@@ -682,6 +684,7 @@ export async function storeFixturesv1( req, res ) {
682
684
  } else {
683
685
  fixture.imageUrl = '';
684
686
  }
687
+ productCapacity += fixture.toObject().fixtureCapacity;
685
688
  const productCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'product' } );
686
689
 
687
690
  const vmCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'vm' } );
@@ -759,7 +762,8 @@ export async function storeFixturesv1( req, res ) {
759
762
  ...floor.toObject(),
760
763
  layoutPolygon: layoutPolygonWithFixtures,
761
764
  centerFixture: centerFixturesWithStatus,
762
- productCount: productCount,
765
+ productCount: productCapacity,
766
+ // productCapacity: productCapacity,
763
767
  otherElements: otherElements,
764
768
  };
765
769
  } ),
@@ -1988,6 +1992,7 @@ export async function storeFixturesTask( req, res ) {
1988
1992
 
1989
1993
  const floorsWithFixtures = await Promise.all(
1990
1994
  floors.map( async ( floor ) => {
1995
+ let productCapacity = 0;
1991
1996
  const layoutPolygonWithFixtures = await Promise.all(
1992
1997
  floor.layoutPolygon.map( async ( element ) => {
1993
1998
  const fixtures = await storeFixtureService.find( {
@@ -2008,6 +2013,7 @@ export async function storeFixturesTask( req, res ) {
2008
2013
  } else {
2009
2014
  fixture.imageUrl = '';
2010
2015
  }
2016
+ productCapacity += fixture.toObject().fixtureCapacity;
2011
2017
  const productCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'product' } );
2012
2018
 
2013
2019
  const vmCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'vm' } );
@@ -2075,6 +2081,7 @@ export async function storeFixturesTask( req, res ) {
2075
2081
  } else {
2076
2082
  fixture.imageUrl = '';
2077
2083
  }
2084
+ productCapacity += fixture.toObject().fixtureCapacity;
2078
2085
  const productCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'product' } );
2079
2086
 
2080
2087
  const vmCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'vm' } );
@@ -2124,7 +2131,8 @@ export async function storeFixturesTask( req, res ) {
2124
2131
  ...floor.toObject(),
2125
2132
  layoutPolygon: layoutPolygonWithFixtures,
2126
2133
  centerFixture: centerFixturesWithStatus,
2127
- productCount: productCount,
2134
+ productCount: productCapacity,
2135
+ // productCapacity: productCapacity,
2128
2136
  otherElements: otherElements,
2129
2137
  };
2130
2138
  } ),
@@ -448,6 +448,18 @@ export async function updateAnswers( req, res ) {
448
448
  ans.video = ans.video.split( '.com/' )[1].split( '?' )[0];
449
449
  ans.video = decodeURIComponent( ans.video );
450
450
  }
451
+ if ( ans?.newVms?.length ) {
452
+ ans.newVms.forEach( ( vms ) => {
453
+ if ( vms?.imageUrl ) {
454
+ vms.imageUrl = vms.imageUrl.split( '.com/' )[1].split( '?' )[0];
455
+ vms.imageUrl = decodeURIComponent( vms.imageUrl );
456
+ }
457
+ if ( vms?.video ) {
458
+ vms.video = vms.video.split( '.com/' )[1].split( '?' )[0];
459
+ vms.video = decodeURIComponent( vms.video );
460
+ }
461
+ } );
462
+ }
451
463
  } );
452
464
 
453
465
  let data = {
@@ -483,11 +495,47 @@ export async function getFixtureDetails( req, res ) {
483
495
  query['floorId'] = req.query.floorId;
484
496
  }
485
497
 
486
- let fixtureDetails = await planoTaskService.findOne( { fixtureId: req.query.fixtureId } );
498
+ let fixtureDetails = await planoTaskService.findOne( query );
487
499
  if ( !fixtureDetails ) {
488
500
  return res.sendError( 'No data found', 204 );
489
501
  }
490
502
  fixtureDetails = await Promise.all( fixtureDetails.answers.map( async ( ans ) => {
503
+ if ( ans?.correctedFixture?.length ) {
504
+ for ( let fixture of ans.correctedFixture ) {
505
+ if ( fixture.image ) {
506
+ let params = {
507
+ Bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
508
+ file_path: fixture.image,
509
+ };
510
+ fixture.image = await signedUrl( params );
511
+ }
512
+ if ( fixture.video ) {
513
+ let params = {
514
+ Bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
515
+ file_path: fixture.video,
516
+ };
517
+ fixture.video = await signedUrl( params );
518
+ }
519
+ }
520
+ }
521
+ if ( ans?.newVms?.length ) {
522
+ for ( let fixture of ans.newVms ) {
523
+ if ( fixture.imageUrl ) {
524
+ let params = {
525
+ Bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
526
+ file_path: fixture.imageUrl,
527
+ };
528
+ fixture.imageUrl = await signedUrl( params );
529
+ }
530
+ if ( fixture.video ) {
531
+ let params = {
532
+ Bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
533
+ file_path: fixture.video,
534
+ };
535
+ fixture.video = await signedUrl( params );
536
+ }
537
+ }
538
+ }
491
539
  if ( ans.image ) {
492
540
  let params = {
493
541
  Bucket: JSON.parse( process.env.BUCKET ).storeBuilder,