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

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.
@@ -2323,9 +2323,9 @@ export async function updateVmData( req, res ) {
2323
2323
 
2324
2324
  // import https from 'https';
2325
2325
  // async function scrapeCrest() {
2326
- // const storeIds = [ 'LKST682' ];
2326
+ // const storeIds = [ 'LKST309' ];
2327
2327
  // const apiUrl = 'https://api.getcrest.ai/api/ms_shelfsensei/layout/';
2328
- // const bearerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzUwODQwMzE1LCJpYXQiOjE3NTA4MzY3MTUsImp0aSI6IjFlOTM1ZmUwMTkwNzQzMDM5ZmJjYmZlOWVkOWM5Y2IwIiwidXNlcl9pZCI6MTA4NSwiaWQiOjEwODUsImlzX21lZXNlZWtfYWNjb3VudCI6ZmFsc2UsImN1c3RvbWVyX2dyb3VwIjozOTgsImxpY2VuY2Vfc2NvcGVzIjpbeyJyZXNvdXJjZV9zZXQiOiJwcF9zZXQiLCJzY29wZV9yb2xlIjoiY29udHJpYnV0b3IifSx7InJlc291cmNlX3NldCI6ImRwX3NldCIsInNjb3BlX3JvbGUiOiJjb250cmlidXRvciJ9LHsicmVzb3VyY2Vfc2V0IjoiZGZfc2V0Iiwic2NvcGVfcm9sZSI6ImNvbnRyaWJ1dG9yIn0seyJyZXNvdXJjZV9zZXQiOiJkZWZhdWx0X3NldCIsInNjb3BlX3JvbGUiOiJjb250cmlidXRvciJ9XX0.zxWZKlUPec5vEwKsWx0DvZ2ckJRkZBzvbH41uid6YJQ';
2328
+ // const bearerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzU1MDkzNzYwLCJpYXQiOjE3NTUwOTAxNjAsImp0aSI6ImU0NjA4OTg3Mjk0ZTQ5YTQ5NDlkMDFmMjdlODRkOGExIiwidXNlcl9pZCI6MTA4NSwiaWQiOjEwODUsImlzX21lZXNlZWtfYWNjb3VudCI6ZmFsc2UsImN1c3RvbWVyX2dyb3VwIjozOTgsImxpY2VuY2Vfc2NvcGVzIjpbeyJyZXNvdXJjZV9zZXQiOiJwcF9zZXQiLCJzY29wZV9yb2xlIjoiY29udHJpYnV0b3IifSx7InJlc291cmNlX3NldCI6ImRwX3NldCIsInNjb3BlX3JvbGUiOiJjb250cmlidXRvciJ9LHsicmVzb3VyY2Vfc2V0IjoiZGZfc2V0Iiwic2NvcGVfcm9sZSI6ImNvbnRyaWJ1dG9yIn0seyJyZXNvdXJjZV9zZXQiOiJkZWZhdWx0X3NldCIsInNjb3BlX3JvbGUiOiJjb250cmlidXRvciJ9XX0.eJJo4T2utbXMnXKB0td8WsAbbyZstMDtzeEVhOB_WBM';
2329
2329
  // const filePath = 'response.json';
2330
2330
  // let allResults = [];
2331
2331
 
@@ -7400,18 +7400,17 @@ export async function migrateCrestv1( req, res ) {
7400
7400
  clientId: '11',
7401
7401
  $and: [
7402
7402
  { storeName: req.body.storeName },
7403
- // { storeName: { $in: [ 'LKST1324', 'LKST495' ] } },
7404
- // { storeName: { $nin: [ 'LKST98', 'LKST1193' ] } },
7403
+ // { storeName: { $in: [] } },
7405
7404
  ],
7406
7405
  };
7407
7406
 
7408
7407
  let storeList = await storeService.find( storeQuery );
7409
7408
 
7410
7409
  // const constantFixtureLength = 1220;
7411
- const constantDetailedFixtureLength = 1220;
7410
+ const constantDetailedFixtureLength = 1524;
7412
7411
 
7413
7412
  // const constantFixtureWidth = 610;
7414
- const constantDetailedFixtureWidth = 1524;
7413
+ const constantDetailedFixtureWidth = 1220;
7415
7414
 
7416
7415
  const mmToFeet = 305;
7417
7416
 
@@ -7422,6 +7421,7 @@ export async function migrateCrestv1( req, res ) {
7422
7421
 
7423
7422
  for ( let i = 0; i < storeList.length; i++ ) {
7424
7423
  const storeData = await fetchStoreData( storeList[i], staticToken, res );
7424
+ console.log( storeData.storeName );
7425
7425
 
7426
7426
  if ( storeData?.data?.message !== 'SUCCESS' ) continue;
7427
7427
 
@@ -7508,51 +7508,96 @@ export async function migrateCrestv1( req, res ) {
7508
7508
  if ( isFloorKeyExist ) {
7509
7509
  backFixtures = backFixtures.filter( ( fixture ) => fixture.floor === floorArray[floorIndex] );
7510
7510
  }
7511
+ const frontTopWall = storeData.data.result.filter( ( entry ) => entry['main'] === 'FRONT VERTICAL WALL' );
7512
+ let frontTopFixtures = frontTopWall.flatMap( ( wall ) => wall.fixtures );
7513
+ if ( isFloorKeyExist ) {
7514
+ frontTopFixtures = frontTopFixtures.filter( ( fixture ) => fixture.floor === floorArray[floorIndex] );
7515
+ }
7511
7516
  let floorFixtures = storeData.data.result.filter(
7512
7517
  ( entry ) => entry['main'] === 'Euro Center' || entry['main'] === 'Euro Center Dr',
7513
7518
  );
7514
7519
  if ( isFloorKeyExist ) {
7515
7520
  floorFixtures = floorFixtures.filter( ( fixture ) => fixture.floor === floorArray[floorIndex] );
7516
7521
  }
7522
+ const w1Fixtures = leftFixtures;
7523
+ const w1FixturesX = w1Fixtures.reduce( ( sum, fixture ) => sum + ( constantDetailedFixtureWidth / mmToFeet ), 0 );
7524
+ const w2Fixtures = backFixtures;
7525
+ const w2FixturesY = w2Fixtures.reduce( ( sum, fixture ) => sum + ( constantDetailedFixtureLength / mmToFeet ), 0 );
7526
+ const w3Fixtures = rightFixtures;
7527
+ const w3FixturesX = w3Fixtures.reduce( ( sum, fixture ) => sum + ( constantDetailedFixtureWidth / mmToFeet ), 0 );
7528
+ const w4Fixtures = [];
7529
+ const w4FixturesY = w4Fixtures.reduce( ( sum, fixture ) => sum + ( constantDetailedFixtureLength / mmToFeet ), 0 );
7530
+ const w5Fixtures = frontTopFixtures;
7531
+ const w5FixturesY = w5Fixtures.reduce( ( sum, fixture ) => sum + ( constantDetailedFixtureLength / mmToFeet ), 0 );
7532
+ const cFixtures = floorFixtures;
7533
+ const cFixturesX = cFixtures.length * ( constantDetailedFixtureWidth / mmToFeet );
7534
+ const cFixturesY = 2 * ( constantDetailedFixtureLength / mmToFeet );
7535
+ const entranceY = 10;
7536
+
7537
+ let minXDistance = Math.max( w1FixturesX, cFixturesX, w3FixturesX );
7538
+ if ( w2Fixtures.length ) {
7539
+ minXDistance += constantDetailedFixtureWidth / mmToFeet;
7540
+ }
7517
7541
 
7518
- // const leftXDistanceFeet = leftFixtures.length ? roundToTwo( ( leftFixtures.length * ( constantFixtureLength / mmToFeet ) ) ) : 0;
7519
- const leftXDetailedDistanceFeet = leftFixtures.length ? roundToTwo( ( leftFixtures.length * ( constantDetailedFixtureLength / mmToFeet ) ) ) : 0;
7520
-
7521
- // const leftYDistanceFeet = leftFixtures.length ? roundToTwo( ( ( constantFixtureWidth / mmToFeet ) ) ) : 0;
7522
- const leftYDetailedDistanceFeet = leftFixtures.length ? roundToTwo( ( ( constantDetailedFixtureWidth / mmToFeet ) ) ) : 0;
7542
+ if ( w4Fixtures.length || w5Fixtures.length ) {
7543
+ if ( w4Fixtures.length && w5Fixtures.length ) {
7544
+ minXDistance += constantDetailedFixtureWidth / mmToFeet;
7545
+ } else if ( w4Fixtures.length ) {
7546
+ minXDistance += constantDetailedFixtureWidth / mmToFeet;
7547
+ } else if ( w5Fixtures.length ) {
7548
+ minXDistance += constantDetailedFixtureWidth / mmToFeet;
7549
+ }
7550
+ }
7523
7551
 
7524
- // const rightXDistanceFeet = rightFixtures.length ? roundToTwo( ( rightFixtures.length * ( constantFixtureLength / mmToFeet ) ) ) : 0;
7525
- const rightXDetailedDistanceFeet = rightFixtures.length ? roundToTwo( ( rightFixtures.length * ( constantDetailedFixtureLength / mmToFeet ) ) ) : 0;
7552
+ // if(cFixtures.length){
7553
+ // minXDistance += 2 * (cFixtures.reduce((max: number, fixture: any) => Math.max(max, fixture.fixtureStaticWidth.value / mmToFeet), 0))
7554
+ // }
7526
7555
 
7527
- // const rightYDistanceFeet = rightFixtures.length ? roundToTwo( ( constantFixtureWidth / mmToFeet ) ) : 0;
7528
- const rightYDetailedDistanceFeet = rightFixtures.length ? roundToTwo( ( constantDetailedFixtureWidth / mmToFeet ) ): 0;
7556
+ let minYDistance = Math.max( w2FixturesY, cFixturesY, ( w4FixturesY + w5FixturesY + entranceY ) );
7557
+ if ( w1Fixtures.length ) {
7558
+ minYDistance += constantDetailedFixtureLength / mmToFeet;
7559
+ }
7529
7560
 
7530
- const maxFixturesPerRow = floorFixtures.length/2;
7531
- const totalRows = 2;
7561
+ if ( w3Fixtures.length ) {
7562
+ minYDistance += constantDetailedFixtureLength / mmToFeet;
7563
+ }
7532
7564
 
7533
- // const floorXDistanceFeet = floorFixtures.length ? roundToTwo( ( ( floorFixtures.length/2 ) * ( constantFixtureLength / mmToFeet ) ) ) : 0;
7534
- const floorXDetailedDistanceFeet = floorFixtures.length ? roundToTwo( ( ( floorFixtures.length/2 ) * ( constantDetailedFixtureLength / mmToFeet ) ) ): 0;
7565
+ if ( cFixtures.length ) {
7566
+ minYDistance += 2 * ( constantDetailedFixtureLength / mmToFeet );
7567
+ }
7535
7568
 
7536
- // const floorYDistanceFeet = floorFixtures.length ? roundToTwo( ( 2 * ( constantFixtureWidth/ mmToFeet ) ) ): 0;
7537
- const floorYDetailedDistanceFeet = floorFixtures.length ? roundToTwo( 2 * ( constantDetailedFixtureWidth/mmToFeet ) ): 0;
7569
+ let w4Length = w4Fixtures?.length ?
7570
+ ( w4Fixtures.length + 1 ) * ( constantDetailedFixtureLength / mmToFeet ) :
7571
+ 0;
7538
7572
 
7539
- // const backXDistanceFeet = backFixtures.length ? roundToTwo( ( constantFixtureWidth / mmToFeet ) ) : 0;
7540
- const backXDetailedDistanceFeet = backFixtures.length ? roundToTwo( ( constantDetailedFixtureLength / mmToFeet ) ) : 0;
7541
7573
 
7542
- // const backYDistanceFeet = backFixtures.length ? roundToTwo( ( ( backFixtures.length * ( constantFixtureLength / mmToFeet ) ) + ( ( ( leftFixtures.length ? 1 : 0 ) + ( rightFixtures.length ? 1 : 0 ) * constantFixtureWidth )/mmToFeet ) ) ) : 0;
7543
- const backYDetailedDistanceFeet = backFixtures.length ? roundToTwo( ( ( backFixtures.length * ( constantDetailedFixtureWidth / mmToFeet ) ) + ( ( ( leftFixtures.length ? 1 : 0 ) + ( rightFixtures.length ? 1 : 0 ) * constantDetailedFixtureWidth )/mmToFeet ) ) ): 0;
7574
+ const w5Length = w5Fixtures?.length ?
7575
+ ( w5Fixtures.length + 1 ) * ( constantDetailedFixtureLength / mmToFeet ) :
7576
+ 0;
7544
7577
 
7545
- // const maxXDistance = Math.max( leftXDistanceFeet, rightXDistanceFeet, floorXDistanceFeet );
7546
- const maxXDetailedDistance = Math.max( leftXDetailedDistanceFeet, rightXDetailedDistanceFeet, floorXDetailedDistanceFeet );
7578
+ const usedY = w4Length + w5Length;
7579
+ const remainingY = Math.max( minYDistance - usedY, 0 );
7547
7580
 
7548
- // const maxYDistance = Math.max( floorYDistanceFeet, backYDistanceFeet );
7549
- const maxYDetailedDistance = Math.max( floorYDetailedDistanceFeet, backYDetailedDistanceFeet );
7581
+ const w4Empty = w4Length === 0;
7582
+ const w5Empty = w5Length === 0;
7550
7583
 
7551
- // const finalXDistance = roundToTwo( ( maxXDistance < ( backXDistanceFeet + floorXDistanceFeet )? ( ( backXDistanceFeet + floorXDistanceFeet ) + ( ( 2 * constantFixtureLength )/mmToFeet ) ) : ( floorFixtures.length && backFixtures.length ) ? ( maxXDistance + ( ( 2 * constantFixtureLength )/mmToFeet ) ) : maxXDistance ) );
7552
- const finalXDetailedDistance = roundToTwo( ( maxXDetailedDistance < ( backXDetailedDistanceFeet + floorXDetailedDistanceFeet )? ( ( backXDetailedDistanceFeet + floorXDetailedDistanceFeet ) + ( ( 2 * constantDetailedFixtureLength )/mmToFeet ) ) : ( floorFixtures.length && backFixtures.length ) ? ( maxXDetailedDistance + ( ( 2 * constantDetailedFixtureLength )/mmToFeet ) ) : maxXDetailedDistance ) );
7584
+ let entranceLength = 0;
7585
+ let w4Final = w4Length;
7586
+ let w5Final = w5Length;
7553
7587
 
7554
- // const finalYDistance = roundToTwo( ( maxYDistance < ( leftYDistanceFeet + rightYDistanceFeet + floorYDistanceFeet ) ? ( ( leftYDistanceFeet + rightYDistanceFeet + floorYDistanceFeet ) + ( ( 2 * constantFixtureWidth )/mmToFeet ) ) : ( maxYDistance + ( ( constantFixtureWidth )/mmToFeet ) ) ) );
7555
- const finalYDetailedDistance = roundToTwo( ( maxYDetailedDistance < ( leftYDetailedDistanceFeet + rightYDetailedDistanceFeet + floorYDetailedDistanceFeet ) ? ( ( leftYDetailedDistanceFeet + rightYDetailedDistanceFeet + floorYDetailedDistanceFeet ) + ( ( 2 * constantDetailedFixtureWidth )/mmToFeet ) ) : ( maxYDetailedDistance + ( ( constantDetailedFixtureWidth )/mmToFeet ) ) ) );
7588
+ if ( w4Empty && w5Empty ) {
7589
+ w4Final = w5Final = entranceLength = minYDistance / 3;
7590
+ } else if ( w4Empty && !w5Empty ) {
7591
+ w5Final = w5Length;
7592
+ w4Final = remainingY / 2;
7593
+ entranceLength = remainingY / 2;
7594
+ } else if ( !w4Empty && w5Empty ) {
7595
+ w4Final = w4Length;
7596
+ w5Final = remainingY / 2;
7597
+ entranceLength = remainingY / 2;
7598
+ } else {
7599
+ entranceLength = remainingY;
7600
+ }
7556
7601
 
7557
7602
 
7558
7603
  const floorInsertData = {
@@ -7566,7 +7611,7 @@ export async function migrateCrestv1( req, res ) {
7566
7611
  layoutPolygon: [
7567
7612
  {
7568
7613
  elementType: 'wall',
7569
- distance: finalXDetailedDistance,
7614
+ distance: roundToTwo( minXDistance ),
7570
7615
  unit: 'ft',
7571
7616
  direction: 'right',
7572
7617
  angle: 90,
@@ -7575,7 +7620,7 @@ export async function migrateCrestv1( req, res ) {
7575
7620
  },
7576
7621
  {
7577
7622
  elementType: 'wall',
7578
- distance: finalYDetailedDistance,
7623
+ distance: roundToTwo( minYDistance ),
7579
7624
  unit: 'ft',
7580
7625
  direction: 'down',
7581
7626
  angle: 90,
@@ -7584,7 +7629,7 @@ export async function migrateCrestv1( req, res ) {
7584
7629
  },
7585
7630
  {
7586
7631
  elementType: 'wall',
7587
- distance: finalXDetailedDistance,
7632
+ distance: roundToTwo( minXDistance ),
7588
7633
  unit: 'ft',
7589
7634
  direction: 'left',
7590
7635
  angle: 90,
@@ -7593,7 +7638,7 @@ export async function migrateCrestv1( req, res ) {
7593
7638
  },
7594
7639
  {
7595
7640
  elementType: 'wall',
7596
- distance: roundToTwo( ( ( finalYDetailedDistance * 35 ) / 100 ) ),
7641
+ distance: roundToTwo( w4Final ),
7597
7642
  unit: 'ft',
7598
7643
  direction: 'up',
7599
7644
  angle: 90,
@@ -7602,7 +7647,7 @@ export async function migrateCrestv1( req, res ) {
7602
7647
  },
7603
7648
  {
7604
7649
  elementType: 'entrance',
7605
- distance: roundToTwo( ( ( finalYDetailedDistance * 30 ) / 100 ) ),
7650
+ distance: roundToTwo( entranceLength ),
7606
7651
  unit: 'ft',
7607
7652
  direction: 'up',
7608
7653
  angle: 90,
@@ -7611,7 +7656,7 @@ export async function migrateCrestv1( req, res ) {
7611
7656
  },
7612
7657
  {
7613
7658
  elementType: 'wall',
7614
- distance: roundToTwo( ( ( finalYDetailedDistance * 35 ) / 100 ) ),
7659
+ distance: roundToTwo( w5Final ),
7615
7660
  unit: 'ft',
7616
7661
  direction: 'up',
7617
7662
  angle: 90,
@@ -7632,6 +7677,9 @@ export async function migrateCrestv1( req, res ) {
7632
7677
 
7633
7678
  let leftAssociatedElementFixtureNumber = 1;
7634
7679
 
7680
+ let leftCurrentX = 0;
7681
+ let leftCurrentY = 0;
7682
+
7635
7683
  for ( let index = 0; index < leftFixtures.length; index++ ) {
7636
7684
  const fixture = leftFixtures[index];
7637
7685
 
@@ -7645,6 +7693,11 @@ export async function migrateCrestv1( req, res ) {
7645
7693
  continue;
7646
7694
  }
7647
7695
 
7696
+ leftCurrentX = ( ( constantDetailedFixtureWidth / mmToFeet ) * index );
7697
+ if ( w5Fixtures.length ) {
7698
+ leftCurrentX += ( ( constantDetailedFixtureWidth / mmToFeet ) );
7699
+ }
7700
+
7648
7701
  let fixtureConfig = await fixtureLibraryService.findOne( libraryType );
7649
7702
 
7650
7703
  if ( !fixtureConfig ) {
@@ -7704,7 +7757,6 @@ export async function migrateCrestv1( req, res ) {
7704
7757
  const vmConfig = fixtureConfigDoc.vmConfig.filter( ( vm ) => vm.position === zone.zoneName );
7705
7758
  const pids = zone.products.filter( ( vm ) => !vm.isMerchandisingElement );
7706
7759
 
7707
-
7708
7760
  return vms.map( ( vm, k ) => {
7709
7761
  let configData = vmConfig[0];
7710
7762
 
@@ -7716,14 +7768,13 @@ export async function migrateCrestv1( req, res ) {
7716
7768
  configData = vmConfig.find( ( config ) => config.vmWidthmm === 230 );
7717
7769
  }
7718
7770
 
7719
-
7720
7771
  if ( configData.vmWidthmm === 905 ) {
7721
7772
  configData.zone = 'stretch';
7722
7773
  }
7723
7774
 
7724
- if ( configData.vmWidthmm === 230 ) {
7725
- configData.zone = 'left';
7726
- }
7775
+ // if ( configData.vmWidthmm === 230 ) {
7776
+ // configData.zone = configData.zone;
7777
+ // }
7727
7778
 
7728
7779
  if ( !configData ) return;
7729
7780
 
@@ -7870,8 +7921,8 @@ export async function migrateCrestv1( req, res ) {
7870
7921
  'associatedElementType': 'wall',
7871
7922
  'associatedElementNumber': 1,
7872
7923
  'relativePosition': {
7873
- 'x': roundToTwo( ( index * ( constantDetailedFixtureLength / mmToFeet ) ) ),
7874
- 'y': 0,
7924
+ 'x': leftCurrentX,
7925
+ 'y': leftCurrentY,
7875
7926
  'unit': 'ft',
7876
7927
  },
7877
7928
  'fixtureNumber': fixtureCounter,
@@ -7930,6 +7981,9 @@ export async function migrateCrestv1( req, res ) {
7930
7981
 
7931
7982
  let backAssociatedElementFixtureNumber = 1;
7932
7983
 
7984
+ let backCurrentX = floorInsertData.layoutPolygon.find( ( wall ) => wall.elementType === 'wall' && wall.elementNumber === 1 )?.distance;
7985
+ let backCurrentY = 0;
7986
+
7933
7987
  for ( let index = 0; index < backFixtures.length; index++ ) {
7934
7988
  const fixture = backFixtures[index];
7935
7989
 
@@ -7943,6 +7997,11 @@ export async function migrateCrestv1( req, res ) {
7943
7997
  continue;
7944
7998
  }
7945
7999
 
8000
+ backCurrentY = ( ( constantDetailedFixtureLength / mmToFeet ) * index );
8001
+ if ( w1Fixtures.length ) {
8002
+ backCurrentY += ( ( constantDetailedFixtureLength / mmToFeet ) );
8003
+ }
8004
+
7946
8005
  let fixtureConfig = await fixtureLibraryService.findOne( libraryType );
7947
8006
 
7948
8007
  if ( !fixtureConfig ) {
@@ -8018,9 +8077,9 @@ export async function migrateCrestv1( req, res ) {
8018
8077
  configData.zone = 'stretch';
8019
8078
  }
8020
8079
 
8021
- if ( configData.vmWidthmm === 230 ) {
8022
- configData.zone = 'left';
8023
- }
8080
+ // if ( configData.vmWidthmm === 230 ) {
8081
+ // configData.zone = 'left';
8082
+ // }
8024
8083
 
8025
8084
  if ( !configData ) return;
8026
8085
 
@@ -8167,8 +8226,8 @@ export async function migrateCrestv1( req, res ) {
8167
8226
  'associatedElementType': 'wall',
8168
8227
  'associatedElementNumber': 2,
8169
8228
  'relativePosition': {
8170
- 'x': roundToTwo( ( finalXDetailedDistance - ( constantDetailedFixtureLength/mmToFeet ) ) ),
8171
- 'y': roundToTwo( ( ( index * ( ( constantDetailedFixtureWidth/mmToFeet ) ) ) + ( ( leftFixtures.length ? 1 : 0 ) * constantDetailedFixtureWidth/mmToFeet ) ) ),
8229
+ 'x': roundToTwo( backCurrentX - ( constantDetailedFixtureWidth / mmToFeet ) ),
8230
+ 'y': roundToTwo( backCurrentY ),
8172
8231
  'unit': 'ft',
8173
8232
  },
8174
8233
  'fixtureNumber': fixtureCounter,
@@ -8226,6 +8285,8 @@ export async function migrateCrestv1( req, res ) {
8226
8285
  }
8227
8286
 
8228
8287
  let rightAssociatedElementFixtureNumber = 1;
8288
+ let rightCurrentX = 0;
8289
+ let rightCurrentY = floorInsertData.layoutPolygon.find( ( wall ) => wall.elementType === 'wall' && wall.elementNumber === 2 )?.distance;
8229
8290
 
8230
8291
  for ( let index = 0; index < rightFixtures.length; index++ ) {
8231
8292
  const fixture = rightFixtures[index];
@@ -8240,6 +8301,11 @@ export async function migrateCrestv1( req, res ) {
8240
8301
  continue;
8241
8302
  }
8242
8303
 
8304
+ rightCurrentX = ( ( constantDetailedFixtureWidth / mmToFeet ) * index );
8305
+ if ( w4Fixtures.length ) {
8306
+ rightCurrentX += ( ( constantDetailedFixtureWidth / mmToFeet ) );
8307
+ }
8308
+
8243
8309
  let fixtureConfig = await fixtureLibraryService.findOne( libraryType );
8244
8310
 
8245
8311
  if ( !fixtureConfig ) {
@@ -8316,9 +8382,9 @@ export async function migrateCrestv1( req, res ) {
8316
8382
  configData.zone = 'stretch';
8317
8383
  }
8318
8384
 
8319
- if ( configData.vmWidthmm === 230 ) {
8320
- configData.zone = 'left';
8321
- }
8385
+ // if ( configData.vmWidthmm === 230 ) {
8386
+ // configData.zone = 'left';
8387
+ // }
8322
8388
 
8323
8389
  if ( !configData ) return;
8324
8390
 
@@ -8464,8 +8530,8 @@ export async function migrateCrestv1( req, res ) {
8464
8530
  'associatedElementType': 'wall',
8465
8531
  'associatedElementNumber': 3,
8466
8532
  'relativePosition': {
8467
- 'x': roundToTwo( ( index * ( constantDetailedFixtureLength / mmToFeet ) ) ),
8468
- 'y': roundToTwo( ( finalYDetailedDistance - ( constantDetailedFixtureWidth / mmToFeet ) ) ),
8533
+ 'x': roundToTwo( rightCurrentX ),
8534
+ 'y': roundToTwo( rightCurrentY - ( constantDetailedFixtureLength / mmToFeet ) ),
8469
8535
  'unit': 'ft',
8470
8536
  },
8471
8537
  'fixtureNumber': fixtureCounter,
@@ -8522,27 +8588,325 @@ export async function migrateCrestv1( req, res ) {
8522
8588
  } );
8523
8589
  }
8524
8590
 
8525
- let centerAssociatedElementFixtureNumber = 1;
8591
+ let frontTopAssociatedElementFixtureNumber = 1;
8592
+ let frontTopCurrentX = 0;
8593
+ let frontTopCurrentY = 0;
8526
8594
 
8527
- for ( let index = 0; index < floorFixtures.length; index++ ) {
8528
- const fixture = floorFixtures[index];
8595
+ for ( let index = 0; index < frontTopFixtures.length; index++ ) {
8596
+ const fixture = frontTopFixtures[index];
8529
8597
 
8530
- const centerRow = Math.floor( totalRows / 2 );
8598
+ if ( !fixture.fixtureName ) {
8599
+ return;
8600
+ }
8531
8601
 
8532
- // const startingX = roundToTwo( ( finalXDistance / 2 - ( maxFixturesPerRow / 2 ) * ( constantFixtureLength / mmToFeet ) ) );
8533
- const detailedStartingX = roundToTwo( ( finalXDetailedDistance / 2 - ( maxFixturesPerRow / 2 ) * ( constantDetailedFixtureLength / mmToFeet ) ) );
8602
+ const libraryType = getLibraryType( fixture.fixtureName );
8534
8603
 
8535
- // const startingY = finalYDistance / 2 - centerRow * ( constantFixtureWidth / mmToFeet );
8536
- const detailedStartingY = finalYDetailedDistance / 2 - centerRow * ( constantDetailedFixtureWidth / mmToFeet );
8604
+ if ( libraryType.fixtureCategory === 'Space' ) {
8605
+ continue;
8606
+ }
8537
8607
 
8538
- const colIndex = Math.floor( index / 2 );
8539
- const rowIndex = index % 2 === 0 ? 1 : 0;
8608
+ frontTopCurrentY = ( ( constantDetailedFixtureLength / mmToFeet ) * index ) + ( constantDetailedFixtureLength / mmToFeet );
8540
8609
 
8541
- // const xPos = roundToTwo( startingX + colIndex * ( constantFixtureLength / mmToFeet ) );
8542
- // const yPos = roundToTwo( startingY + rowIndex * ( constantFixtureWidth / mmToFeet ) );
8543
8610
 
8544
- const detailedXPos = roundToTwo( ( detailedStartingX + colIndex * ( constantDetailedFixtureLength / mmToFeet ) ) );
8545
- const detailedYPos = roundToTwo( ( detailedStartingY + rowIndex * ( constantDetailedFixtureWidth / mmToFeet ) ) );
8611
+ let fixtureConfig = await fixtureLibraryService.findOne( libraryType );
8612
+
8613
+ if ( !fixtureConfig ) {
8614
+ const existingLibrary = await fixtureLibraryService.findOne( { fixtureCategory: libraryType.fixtureCategory } );
8615
+
8616
+ const insertData = {
8617
+ ...sampleLibrary,
8618
+ ...( existingLibrary ? existingLibrary.toObject() : {} ),
8619
+ ...libraryType,
8620
+ };
8621
+
8622
+ delete insertData._id;
8623
+
8624
+ fixtureConfig = await fixtureLibraryService.upsertOne( libraryType, insertData );
8625
+ }
8626
+ const fixtureConfigDoc = fixtureConfig.toObject();
8627
+
8628
+ let mapKey = `${fixtureConfigDoc.fixtureCategory}${fixtureConfigDoc.fixtureWidth.value}${fixtureConfigDoc.fixtureWidth.unit},${fixture.header}`;
8629
+
8630
+ const fixtureProductSubBrandName = new Set();
8631
+
8632
+
8633
+ const shelfTemplate = fixtureConfigDoc.shelfConfig.map( ( configShelf, j ) => {
8634
+ const shelfZone = fixture.productZones.find( ( zone ) => zone.zoneName === configShelf.shelfZone );
8635
+ const shelfSection = shelfZone?.products.find( ( product ) => !product.isMerchandisingElement );
8636
+
8637
+ const shelfIdentifier = `shelf${j + 1}=${shelfSection?.productName}`;
8638
+
8639
+ mapKey += ','+shelfIdentifier;
8640
+
8641
+ const productSubBrandName = shelfSection?.productName?.replace( /\s*PIDs?\b/g, '' )?.split( /\s*\+\s*/ ) || [];
8642
+
8643
+ productSubBrandName.forEach( ( item ) => fixtureProductSubBrandName.add( item ) );
8644
+
8645
+ return {
8646
+ shelfNumber: j+1,
8647
+ shelfType: configShelf?.shelfType,
8648
+ productPerShelf: configShelf?.productPerShelf,
8649
+ trayRows: configShelf?.trayRows,
8650
+ productBrandName: productSubBrandName,
8651
+ zone: configShelf.shelfZone,
8652
+ };
8653
+ } );
8654
+
8655
+ [ ...fixtureProductSubBrandName ].forEach( async ( brand ) => {
8656
+ const upsertData = {
8657
+ clientId: '11',
8658
+ brandName: brand,
8659
+ brandDetails: [],
8660
+ };
8661
+
8662
+ await planoProductCategoryService.upsertOne( { brandName: brand }, upsertData );
8663
+ } );
8664
+
8665
+
8666
+ const vmConfig = fixture.productZones?.flatMap( ( zone ) => {
8667
+ const vms = zone.products.filter( ( vm ) => vm.isMerchandisingElement );
8668
+ const vmConfig = fixtureConfigDoc.vmConfig.filter( ( vm ) => vm.position === zone.zoneName );
8669
+ const pids = zone.products.filter( ( vm ) => !vm.isMerchandisingElement );
8670
+
8671
+ return vms.map( ( vm, k ) => {
8672
+ let configData = vmConfig[0];
8673
+
8674
+ if ( vm.productName === 'Creatr' && zone.zoneName === 'Mid' ) {
8675
+ configData = vmConfig.find( ( config ) => config.vmWidthmm === 905 );
8676
+ configData.zone = 'stretch';
8677
+ }
8678
+
8679
+ if ( vm.productName === 'Creatr' && zone.zoneName === 'Mid' && pids.length ) {
8680
+ configData = vmConfig.find( ( config ) => config.vmWidthmm === 230 );
8681
+ }
8682
+
8683
+ if ( configData.vmWidthmm === 905 ) {
8684
+ configData.zone = 'stretch';
8685
+ }
8686
+
8687
+ // if ( configData.vmWidthmm === 230 ) {
8688
+ // configData.zone = 'left';
8689
+ // }
8690
+
8691
+ if ( !configData ) return;
8692
+
8693
+ const vmIdentifier = `vm${k+1}=${vm.productName}+${configData.vmHeightmm}+${configData.vmWidthmm}+${configData.startShelf}+${configData.endShelf}+${configData.zone}`;
8694
+
8695
+ mapKey += ','+vmIdentifier;
8696
+
8697
+ return {
8698
+ startYPosition: configData.startShelf,
8699
+ endYPosition: configData.endShelf,
8700
+ xZone: configData.zone,
8701
+ vmName: vm.productName,
8702
+ vmHeight: configData.vmHeightmm,
8703
+ vmWidth: configData.vmWidthmm,
8704
+ imageUrl: zone?.actual_image_url,
8705
+ };
8706
+ } );
8707
+ } );
8708
+
8709
+ const vmTemplate = await Promise.all( vmConfig.map( async ( vmTemplate ) => {
8710
+ const vmInsertData = {
8711
+ clientId: '11',
8712
+ vmName: vmTemplate.vmName,
8713
+ vmHeight: {
8714
+ value: vmTemplate.vmHeight,
8715
+ unit: 'mm',
8716
+ },
8717
+ vmWidth: {
8718
+ value: vmTemplate.vmWidth,
8719
+ unit: 'mm',
8720
+ },
8721
+ status: 'complete',
8722
+ vmBrand: vmTemplate.vmBrand,
8723
+ vmType: 'LKVM',
8724
+ };
8725
+ if ( vmTemplate?.imageUrl ) {
8726
+ const parsedUrl = new URL( vmTemplate.imageUrl );
8727
+ const attachmentId = parsedUrl.searchParams.get( 'attachment_id' );
8728
+
8729
+ const isVmImageExist = await planoVmService.findOne( { crestImageId: attachmentId } );
8730
+
8731
+ if ( !isVmImageExist ) {
8732
+ const vmImageData = await fetchVmImage( attachmentId );
8733
+
8734
+ const imageMeta = await getImageMetadata( vmImageData );
8735
+
8736
+ const params = {
8737
+ Bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
8738
+ Key: `vmType/`,
8739
+ fileName: `${attachmentId}.${imageMeta.fileExtension}`,
8740
+ ContentType: imageMeta.contentType,
8741
+ body: vmImageData,
8742
+ };
8743
+
8744
+ const imgUpload = await fileUpload( params );
8745
+
8746
+ vmInsertData.crestImageId = attachmentId;
8747
+ vmInsertData.vmImageUrl = imgUpload.Key;
8748
+
8749
+
8750
+ if ( imageMeta.imageShape === 'square' ) {
8751
+ vmInsertData.vmHeight.value = 100;
8752
+ vmInsertData.vmWidth.value = 230;
8753
+ }
8754
+ } else {
8755
+ vmInsertData.crestImageId = attachmentId;
8756
+ vmInsertData.vmImageUrl = isVmImageExist.toObject().vmImageUrl;
8757
+ }
8758
+ }
8759
+
8760
+ const vmDetails = await planoVmService.upsertOne(
8761
+ {
8762
+ 'vmName': vmInsertData.vmName,
8763
+ },
8764
+ vmInsertData,
8765
+ );
8766
+
8767
+ return {
8768
+ vmId: vmDetails.toObject()._id,
8769
+ startYPosition: vmTemplate.startYPosition,
8770
+ endYPosition: vmTemplate.endYPosition,
8771
+ xZone: vmTemplate.xZone,
8772
+ yZone: 'stretch',
8773
+ };
8774
+ } ) );
8775
+
8776
+ const existingTemplateWithMaxIndex = await fixtureConfigService.sortAndFindOne(
8777
+ { fixtureCategory: fixtureConfigDoc.fixtureCategory,
8778
+ fixtureWidth: fixtureConfigDoc.fixtureWidth }, {}, { templateIndex: -1 } );
8779
+
8780
+ let templateIndex = 1;
8781
+
8782
+ if ( existingTemplateWithMaxIndex.length ) {
8783
+ const isTemplateSimilar = await fixtureConfigService.findOne( { crestMapKey: mapKey } );
8784
+
8785
+ if ( isTemplateSimilar ) {
8786
+ templateIndex = isTemplateSimilar.toObject().templateIndex;
8787
+ } else {
8788
+ templateIndex = existingTemplateWithMaxIndex[0].toObject().templateIndex + 1;
8789
+ }
8790
+ }
8791
+
8792
+
8793
+ const templateName = `Template-${templateIndex}-${fixtureConfigDoc.fixtureCategory}`;
8794
+
8795
+
8796
+ const fixtureTemplateData = {
8797
+ ...fixtureConfigDoc,
8798
+ 'shelfConfig': shelfTemplate,
8799
+ 'vmConfig': vmTemplate,
8800
+ 'clientId': fixtureConfigDoc.clientId,
8801
+ 'fixtureName': templateName,
8802
+ 'templateIndex': templateIndex,
8803
+ 'header': {
8804
+ label: fixture.header ? fixture.header : fixture.fixtureSubname[0],
8805
+ isEnabled: true,
8806
+ },
8807
+ 'footer': {
8808
+ label: fixture.footer,
8809
+ isEnabled: true,
8810
+ },
8811
+ 'isBodyEnabled': true,
8812
+ 'productResolutionLevel': 'L3',
8813
+ 'productBrandName': [ ...fixtureProductSubBrandName ],
8814
+ 'fixtureLibraryId': fixtureConfigDoc._id,
8815
+ 'crestMapKey': mapKey,
8816
+ };
8817
+
8818
+ delete fixtureTemplateData._id;
8819
+
8820
+
8821
+ const fixtureTemplate = await fixtureConfigService.upsertOne(
8822
+ { crestMapKey: mapKey },
8823
+ fixtureTemplateData,
8824
+ );
8825
+
8826
+ const fixtureData = {
8827
+ ...fixtureTemplate.toObject(),
8828
+ 'storeName': layoutDoc.storeName,
8829
+ 'storeId': storeDetails?.toObject()?.storeId ? storeDetails.toObject().storeId : 'nil',
8830
+ 'planoId': layoutDoc.planoId,
8831
+ 'floorId': layoutDoc._id,
8832
+ 'associatedElementType': 'wall',
8833
+ 'associatedElementNumber': 5,
8834
+ 'relativePosition': {
8835
+ 'x': roundToTwo( frontTopCurrentX ),
8836
+ 'y': roundToTwo( frontTopCurrentY ),
8837
+ 'unit': 'ft',
8838
+ },
8839
+ 'fixtureNumber': fixtureCounter,
8840
+ // 'relativeDetailedPosition': {
8841
+ // 'x': roundToTwo( ( index * ( constantDetailedFixtureLength / mmToFeet ) ) ),
8842
+ // 'y': roundToTwo( ( finalYDetailedDistance - ( constantDetailedFixtureWidth / mmToFeet ) ) ),
8843
+ // 'unit': 'ft',
8844
+ // },
8845
+ 'associatedElementFixtureNumber': frontTopAssociatedElementFixtureNumber,
8846
+ 'fixtureConfigId': fixtureTemplate.toObject()._id,
8847
+ };
8848
+
8849
+ frontTopAssociatedElementFixtureNumber += 1;
8850
+
8851
+ delete fixtureData._id;
8852
+ delete fixtureData.shelfConfig;
8853
+
8854
+ const createdFixture = await storeFixtureService.upsertOne(
8855
+ {
8856
+ floorId: layoutDoc._id,
8857
+ fixtureNumber: fixtureCounter++,
8858
+ },
8859
+ fixtureData,
8860
+ );
8861
+
8862
+ if ( !fixtureConfigDoc.shelfConfig.length || fixture.header === 'CL' || fixture.fixtureSubname?.includes( 'CL' ) ) continue;
8863
+
8864
+ fixtureTemplate.shelfConfig.forEach( async ( configShelf, j ) => {
8865
+ const shelfData = {
8866
+ 'clientId': '11',
8867
+ 'storeName': layoutDoc.storeName,
8868
+ 'storeId': storeDetails?.toObject()?.storeId ? storeDetails.toObject().storeId : 'nil',
8869
+ 'planoId': layoutDoc.planoId,
8870
+ 'floorId': layoutDoc._id,
8871
+ 'fixtureId': createdFixture._id,
8872
+ 'shelfNumber': j + 1,
8873
+ 'shelfOrder': 'LTR',
8874
+ 'shelfCapacity': configShelf.shelfCapacity,
8875
+ 'productBrandName': configShelf.productBrandName,
8876
+ 'shelfType': configShelf.shelfType,
8877
+ 'productPerShelf': configShelf.productPerShelf,
8878
+ 'trayRows': configShelf.trayRows,
8879
+ 'productPerTray': configShelf.productPerTray,
8880
+ 'zone': configShelf.zone,
8881
+ };
8882
+
8883
+ await fixtureShelfService.upsertOne(
8884
+ {
8885
+ fixtureId: createdFixture._id,
8886
+ shelfNumber: j + 1,
8887
+ },
8888
+ shelfData,
8889
+ );
8890
+ } );
8891
+ }
8892
+
8893
+ let centerAssociatedElementFixtureNumber = 1;
8894
+
8895
+ const maxFixturesPerRow = cFixtures.length / 2;
8896
+ const totalRows = 2;
8897
+ const centerRow = Math.floor( totalRows / 2 );
8898
+
8899
+ for ( let index = 0; index < floorFixtures.length; index++ ) {
8900
+ const fixture = floorFixtures[index];
8901
+
8902
+ const startX = ( minXDistance / 2 - ( maxFixturesPerRow / 2 ) * ( constantDetailedFixtureWidth / mmToFeet ) );
8903
+ const startY = minYDistance / 2 - centerRow * ( constantDetailedFixtureLength / mmToFeet );
8904
+
8905
+ const colIndex = Math.floor( ( index ) / 2 );
8906
+ const rowIndex = ( index ) % 2 === 0 ? 1 : 0;
8907
+
8908
+ const currentCurrentX = ( startX + colIndex * ( constantDetailedFixtureWidth / mmToFeet ) );
8909
+ const currentCurrentY = ( startY + rowIndex * ( constantDetailedFixtureLength / mmToFeet ) );
8546
8910
 
8547
8911
  const fixtureConfig = await fixtureLibraryService.findOne( { fixtureCategory: fixture.main } );
8548
8912
  if ( !fixtureConfig ) continue;
@@ -8589,6 +8953,7 @@ export async function migrateCrestv1( req, res ) {
8589
8953
  await planoProductCategoryService.upsertOne( { brandName: brand }, upsertData );
8590
8954
  } );
8591
8955
 
8956
+ const vmProduct = new Set();
8592
8957
 
8593
8958
  const vmConfig = fixture.centerSuperSubMain?.flatMap( ( vm ) => {
8594
8959
  if ( !vm?.isVisualMerchandiser ) {
@@ -8596,6 +8961,8 @@ export async function migrateCrestv1( req, res ) {
8596
8961
  }
8597
8962
  const vmConfig = fixtureConfigDoc.vmConfig;
8598
8963
 
8964
+ vmProduct.add( vm.name );
8965
+
8599
8966
  const [ configData1, configData2 ] = [ vmConfig[0], vmConfig[1] ];
8600
8967
 
8601
8968
  return [
@@ -8719,7 +9086,7 @@ export async function migrateCrestv1( req, res ) {
8719
9086
  'fixtureName': templateName,
8720
9087
  'templateIndex': templateIndex,
8721
9088
  'header': {
8722
- label: fixture.centerSubMain,
9089
+ label: fixture.header,
8723
9090
  isEnabled: true,
8724
9091
  },
8725
9092
  'footer': {
@@ -8728,7 +9095,7 @@ export async function migrateCrestv1( req, res ) {
8728
9095
  },
8729
9096
  'isBodyEnabled': true,
8730
9097
  'productResolutionLevel': 'L3',
8731
- 'productBrandName': [ ...fixtureProductSubBrandName ],
9098
+ 'productBrandName': [ ...vmProduct ],
8732
9099
  'fixtureLibraryId': fixtureConfigDoc._id,
8733
9100
  'crestMapKey': mapKey,
8734
9101
  };
@@ -8749,8 +9116,8 @@ export async function migrateCrestv1( req, res ) {
8749
9116
  'planoId': layoutDoc.planoId,
8750
9117
  'floorId': layoutDoc._id,
8751
9118
  'relativePosition': {
8752
- 'x': detailedXPos,
8753
- 'y': detailedYPos,
9119
+ 'x': roundToTwo( currentCurrentX ),
9120
+ 'y': roundToTwo( currentCurrentY ),
8754
9121
  'unit': 'ft',
8755
9122
  },
8756
9123
  'fixtureNumber': fixtureCounter,
@@ -8789,7 +9156,7 @@ export async function migrateCrestv1( req, res ) {
8789
9156
  'shelfNumber': j + 1,
8790
9157
  'shelfOrder': 'LTR',
8791
9158
  'shelfCapacity': configShelf.shelfCapacity,
8792
- 'productBrandName': configShelf.productBrandName,
9159
+ 'productBrandName': [ ...vmProduct ],
8793
9160
  'shelfType': configShelf.shelfType,
8794
9161
  'productPerShelf': configShelf.productPerShelf,
8795
9162
  'trayRows': configShelf.trayRows,
@@ -9030,3 +9397,154 @@ export async function updatePlanoMappings( req, res ) {
9030
9397
  return res.sendError( e, 500 );
9031
9398
  }
9032
9399
  }
9400
+
9401
+ async function updateVmByPriority( db ) {
9402
+ const priorityList = [
9403
+ new mongoose.Types.ObjectId( '686cf5812e0f3d99b9d1e8b7' ),
9404
+ new mongoose.Types.ObjectId( '686cf5812e0f3d99b9d1e8c3' ),
9405
+ new mongoose.Types.ObjectId( '686cf5802e0f3d99b9d1e8a9' ),
9406
+ ];
9407
+
9408
+ const storeNames =[];
9409
+
9410
+ for ( const store of storeNames ) {
9411
+ let updated = false;
9412
+
9413
+ for ( const priorityId of priorityList ) {
9414
+ const fixture = await storeFixtureService.findOne( {
9415
+ 'storeName': store,
9416
+ 'vmConfig.vmId': priorityId,
9417
+ } );
9418
+
9419
+ if ( fixture ) {
9420
+ await storeFixtureService.updateOneArrayItem(
9421
+ { _id: fixture._id },
9422
+ { $set: { 'vmConfig.$[elem].vmId': new mongoose.Types.ObjectId( '689c7672be8971d7cac3653d' ) } },
9423
+ { arrayFilters: [ { 'elem.vmId': priorityId } ] },
9424
+ );
9425
+ console.log( `Updated store ${store}, fixture ${fixture._id}` );
9426
+ updated = true;
9427
+ break;
9428
+ }
9429
+ }
9430
+
9431
+ if ( !updated ) {
9432
+ console.log( `No fixture found to update in store ${store}` );
9433
+ }
9434
+ }
9435
+ }
9436
+
9437
+
9438
+ async function updateVmByHeader( db ) {
9439
+ const replacementId = new mongoose.Types.ObjectId( '689c7672be8971d7cac3653d' );
9440
+
9441
+ const storeNames = [];
9442
+
9443
+ for ( const store of storeNames ) {
9444
+ const premiumFixture = await storeFixtureService.findOne( {
9445
+ 'storeName': store,
9446
+ 'header.label': 'Premium Trending 1',
9447
+ } );
9448
+
9449
+ if ( premiumFixture ) {
9450
+ await storeFixtureService.updateOneArrayItem(
9451
+ { _id: premiumFixture._id },
9452
+ { $set: { 'vmConfig.0.vmId': replacementId } },
9453
+ );
9454
+ console.log( `Updated Premium Trending 1 fixture in store ${store}, fixture ${premiumFixture._id}` );
9455
+ } else {
9456
+ console.log( `No Premium Trending 1 fixture found in store ${store}` );
9457
+ }
9458
+ }
9459
+ }
9460
+
9461
+
9462
+ async function updateHeaders() {
9463
+ const brandMapping = {
9464
+ 'OD Eye(0.4)+JJ Sun(0.6)': 'Owndays',
9465
+ 'VC Eye / LK Air+Hooper': 'VC Eye / LK Air',
9466
+ 'JJ Eye(0.4)+OD Eye(0.6)': 'John Jacobs',
9467
+ 'Trending 1': 'Trending',
9468
+ 'Hooper(0.5)+BZ(0.5)': 'Hooper',
9469
+ 'CL+JJ Sun(0.5)+Hooper(0.5)': 'John Jacobs',
9470
+ 'JJ Sun(0.6)+JJ Eye(0.4)': 'John Jacobs',
9471
+ 'Fossil Eye(0.5)+Polaroid Eye(0.5)': 'Fossil',
9472
+ 'Work Essentials 4': 'Work Essentials',
9473
+ 'OD Eye(0.5)+JJ Sun (0.5)': 'Owndays',
9474
+ 'Fossil Eye(0.6)+Hooper(0.4)': 'Fossil',
9475
+ 'LK Air': 'Lenskart Air',
9476
+ 'Almost Gone 1': 'Almost Gone',
9477
+ 'Fossil Eye': 'Fossil',
9478
+ 'JJ Eye(0.6)+JJ Sun(0.4)': 'John Jacobs',
9479
+ 'Premium Trending 2': 'Premium Trending',
9480
+ 'JJ Sun Non Metal': 'John Jacobs',
9481
+ 'Work Essentials 2': 'Work Essentials',
9482
+ 'VC Eye / LK Air(0.5)+OD Eye(0.5)': 'VC Eye / LK Air',
9483
+ 'VC Sun': 'VC Eye / LK Air',
9484
+ 'Trending 4': 'Trending',
9485
+ 'Premium Trending 3': 'Premium Trending',
9486
+ 'Premium Work 4': 'Premium Work',
9487
+ 'Shades 3': 'Shades',
9488
+ 'VC Eye Half Rim & Rimless': 'VC Eye / LK Air',
9489
+ 'Cl': 'Aqua lens',
9490
+ 'Innovation 1': 'Innovation',
9491
+ 'Shades 4': 'Shades',
9492
+ 'Premium Work 3': 'Premium Work',
9493
+ 'Premium Work 1': 'Premium Work',
9494
+ 'VC Eye / LK Air + Hooper': 'VC Eye / LK Air',
9495
+ 'Shades 1': 'Shades',
9496
+ 'Hooper(0.6)+BZ(0.4)': 'Hooper',
9497
+ 'Hooper+BZ': 'Hooper',
9498
+ 'Premium Trending 1': 'Premium Trending',
9499
+ 'Trending': 'Trending',
9500
+ 'Premium Shades 2': 'Premium Shades',
9501
+ 'JJ Eye': 'John Jacobs',
9502
+ 'OD Eye(0.5)+VC Eye / LK Air(0.5)': 'Owndays',
9503
+ 'OD Eye': 'Premium Shades',
9504
+ 'Hooper Eye': 'Hooper',
9505
+ 'JJ Sun(0.6)+VC Sun(0.4)': 'John Jacobs',
9506
+ 'Premium Shades 3': 'Premium Shades',
9507
+ 'LPL Eye': 'Le Petit Lunetier',
9508
+ 'Premium Work 2': 'Premium Work',
9509
+ 'Phonic+VC Eye / LK Air': 'VC Eye / LK Air',
9510
+ 'Hooper Sun': 'Hooper',
9511
+ 'Work Essentials 1': 'Work Essentials',
9512
+ 'JJ Sun': 'John Jacobs',
9513
+ 'JJ Eye(0.4)+JJ Sun(0.6)': 'John Jacobs',
9514
+ 'JJ sun': 'John Jacobs',
9515
+ 'JJ Eye(0.5)+JJ Sun(0.5)': 'John Jacobs',
9516
+ 'VC Eye Non-Metal': 'Vincent Chase',
9517
+ 'Premium Trending': 'Premium Trending',
9518
+ 'VC Eye Metal': 'Vincent Chase',
9519
+ 'Trending 3': 'Trending',
9520
+ 'Vincent Chase Lenskart air': 'VC Eye / LK Air',
9521
+ 'JJ Eye(0.6)+OD Eye(0.4)': 'John Jacobs',
9522
+ 'VC Eye/ LK Air(0.6)+Hooper(0.4)': 'VC Eye / LK Air',
9523
+ 'Trending 2': 'Trending',
9524
+ 'Hustlr': 'Hustlr',
9525
+ 'All JJ Eye': 'John Jacobs',
9526
+ 'VC Sun Metal': 'VC Eye / LK Air',
9527
+ 'Owndays Eye': 'Owndays',
9528
+ 'Premium Trending 4': 'Premium Trending',
9529
+ 'Premium Shades 1': 'Premium Shades',
9530
+ 'OD Eye(0.5)+LPL Eye(0.5)': 'Owndays',
9531
+ 'JJ Eye Metal': 'John Jacobs',
9532
+ 'JJ Sun(0.5)+JJ Eye(0.5)': 'John Jacobs',
9533
+ 'Hooper(0.6)+OD EYE(0.4)': 'Hooper',
9534
+ 'OD Eye(0.6)+JJ sun(0.4)': 'Owndays',
9535
+ 'JJ Eye Half Rim & Rimless': 'John Jacobs',
9536
+ 'VC sun': 'VC Eye / LK Air',
9537
+ 'OD Eye(0.6)+Fossil Eye(0.4)': 'Owndays',
9538
+ 'Work Essentials': 'Work Essentials',
9539
+ 'Work Essentials 3': 'Work Essentials',
9540
+ 'Fossil Eye(0.5)+OD Eye(0.5)': 'Owndays',
9541
+ 'VC Eye / LK Air(0.5)+Phonic(0.5)': 'VC Eye / LK Air',
9542
+ 'VC Eye / LK Air(0.5)+LK Boost(0.5)': 'VC Eye / LK Air',
9543
+ 'Shades 2': 'Shades',
9544
+ };
9545
+
9546
+ Object.entries( brandMapping ).forEach( async ( [ key, value ] ) => {
9547
+ await storeFixtureService.updateMany( { 'header.label': key }, { 'header.label': value } );
9548
+ console.log( key );
9549
+ } );
9550
+ }