tango-app-api-store-builder 1.0.0-beta-49 → 1.0.0-beta-51

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-49",
3
+ "version": "1.0.0-beta-51",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1573,3 +1573,66 @@ export async function createVmData( req, res ) {
1573
1573
  return res.sendError( e.message || 'Internal Server Error', 500 );
1574
1574
  }
1575
1575
  }
1576
+
1577
+ export async function lk98lK1993Update( req, res ) {
1578
+ try {
1579
+ const modelFixture = await storeFixtureService.findOne( { storeName: 'LKST98', fixtureNumber: 1 } );
1580
+
1581
+ const modelShelves = await fixtureShelfService.find( { fixtureId: modelFixture.toObject()._id } );
1582
+
1583
+ const modelproducts = await planoMappingService.find( { fixtureId: modelFixture.toObject()._id, type: 'product' } );
1584
+
1585
+ const stores = [ 'LKST1193' ];
1586
+
1587
+ for ( let i = 0; i < stores.length; i++ ) {
1588
+ const store = stores[i];
1589
+
1590
+ const storeFixtures = await storeFixtureService.find( { storeName: store, fixtureType: { $ne: 'other' } } );
1591
+
1592
+ for ( let j = 0; j < storeFixtures.length; j++ ) {
1593
+ const fixture = storeFixtures[j].toObject();
1594
+
1595
+ for ( let k = 0; k < modelShelves.length; k++ ) {
1596
+ const modelShelf = modelShelves[k].toObject();
1597
+
1598
+ delete modelShelf._id;
1599
+
1600
+ const updateShelfData = {
1601
+ ...modelShelf,
1602
+ fixtureId: fixture._id,
1603
+ storeName: 'LKST1193',
1604
+ storeId: '11-1076',
1605
+ planoId: new mongoose.Types.ObjectId( '67c1a273dad5d3cfdbf18fe3' ),
1606
+ floorId: new mongoose.Types.ObjectId( '67c1a2a8dad5d3cfdbf1c9f5' ),
1607
+ };
1608
+
1609
+ const createdShelf = await fixtureShelfService.create( updateShelfData );
1610
+ console.log( updateShelfData );
1611
+
1612
+ for ( let l = 0; l < modelproducts.length; l++ ) {
1613
+ const modelProduct = modelproducts[l].toObject();
1614
+
1615
+ delete modelProduct._id;
1616
+
1617
+ const updateProductData = {
1618
+ ...modelProduct,
1619
+ fixtureId: fixture._id,
1620
+ shelfId: createdShelf.toObject()._id,
1621
+ storeName: 'LKST1193',
1622
+ storeId: '11-1076',
1623
+ planoId: new mongoose.Types.ObjectId( '67c1a273dad5d3cfdbf18fe3' ),
1624
+ floorId: new mongoose.Types.ObjectId( '67c1a2a8dad5d3cfdbf1c9f5' ),
1625
+ };
1626
+
1627
+ await planoMappingService.create( updateProductData );
1628
+ console.log( updateProductData );
1629
+ }
1630
+ }
1631
+ }
1632
+ }
1633
+ return res.sendSuccess( 'Updated successfully' );
1634
+ } catch ( e ) {
1635
+ logger.error( { functionName: 'transformDataAPI', error: e } );
1636
+ return res.sendError( e.message || 'Internal Server Error', 500 );
1637
+ }
1638
+ }
@@ -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
  } ),
@@ -428,6 +428,18 @@ export async function updateStatus( req, res ) {
428
428
  export async function updateAnswers( req, res ) {
429
429
  try {
430
430
  req.body.answers.forEach( ( ans ) => {
431
+ if ( ans?.correctedFixture?.length ) {
432
+ ans.correctedFixture.forEach( ( fixture ) => {
433
+ if ( fixture.image ) {
434
+ fixture.image = fixture.image.split( '.com/' )[1].split( '?' )[0];
435
+ fixture.image = decodeURIComponent( fixture.image );
436
+ }
437
+ if ( fixture.video ) {
438
+ fixture.video = fixture.video.split( '.com/' )[1].split( '?' )[0];
439
+ fixture.video = decodeURIComponent( fixture.video );
440
+ }
441
+ } );
442
+ }
431
443
  if ( ans.image ) {
432
444
  ans.image = ans.image.split( '.com/' )[1].split( '?' )[0];
433
445
  ans.image = decodeURIComponent( ans.image );
@@ -471,11 +483,29 @@ export async function getFixtureDetails( req, res ) {
471
483
  query['floorId'] = req.query.floorId;
472
484
  }
473
485
 
474
- let fixtureDetails = await planoTaskService.findOne( { fixtureId: req.query.fixtureId } );
486
+ let fixtureDetails = await planoTaskService.findOne( query );
475
487
  if ( !fixtureDetails ) {
476
488
  return res.sendError( 'No data found', 204 );
477
489
  }
478
490
  fixtureDetails = await Promise.all( fixtureDetails.answers.map( async ( ans ) => {
491
+ if ( ans?.correctedFixture?.length ) {
492
+ for ( let fixture of ans.correctedFixture ) {
493
+ if ( fixture.image ) {
494
+ let params = {
495
+ Bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
496
+ file_path: fixture.image,
497
+ };
498
+ fixture.image = await signedUrl( params );
499
+ }
500
+ if ( fixture.video ) {
501
+ let params = {
502
+ Bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
503
+ file_path: fixture.video,
504
+ };
505
+ fixture.video = await signedUrl( params );
506
+ }
507
+ }
508
+ }
479
509
  if ( ans.image ) {
480
510
  let params = {
481
511
  Bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
@@ -11,4 +11,5 @@ scriptRouter
11
11
  .post( '/bulkIinsertFloorData', scriptController.createFloors )
12
12
  .post( '/bulkIinsertVmTemplateData', scriptController.createVmData )
13
13
  .post( '/bulkIinsertFixturesShelvesVmsData', scriptController.createFixturesShelves )
14
- .post( '/updateFixturesShelvesVms', scriptController.updateFixturesShelves );
14
+ .post( '/updateFixturesShelvesVms', scriptController.updateFixturesShelves )
15
+ .post( '/lk98lK1993Update', scriptController.lk98lK1993Update );