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

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-50",
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
+ }
@@ -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 );
@@ -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 );