@infrab4a/connect-angular 4.5.3-beta.7 → 4.5.3-beta.9

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.
@@ -1736,7 +1736,7 @@ class CatalogService {
1736
1736
  return this.findCatalogAndSortByMostRevelantByTerm(productsIds, options, limits);
1737
1737
  }
1738
1738
  if (this.hasCategory(options) && options.sort === 'most-relevant') {
1739
- const { mostRelevant } = options.category;
1739
+ const mostRelevant = options.category.mostRelevant ?? [];
1740
1740
  console.log('mostRelevant', mostRelevant);
1741
1741
  const productsIds = await this.productRepository
1742
1742
  .find({
@@ -1778,13 +1778,10 @@ class CatalogService {
1778
1778
  console.log('mostRelevant', mostRelevants);
1779
1779
  console.log('productIds', productIds);
1780
1780
  const mostRelevantProductsIds = [...new Set(mostRelevants.concat(productIds))];
1781
- console.log('mostRelevantProductsIds', mostRelevantProductsIds);
1782
1781
  const totalResult = await this.productRepository.findCatalog({
1783
- fields: ['id', 'stock'],
1784
1782
  filters: {
1785
1783
  id: { operator: Where.IN, value: mostRelevantProductsIds },
1786
1784
  },
1787
- // limits,
1788
1785
  orderBy: this.buildSortQuery('news'),
1789
1786
  options: {
1790
1787
  minimal: ['price'],
@@ -1792,37 +1789,10 @@ class CatalogService {
1792
1789
  distinct: ['brand'],
1793
1790
  },
1794
1791
  }, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
1795
- console.log('totalResult', totalResult.count);
1796
- // const stockData = totalResult.data.filter((product) => product.stock.quantity > 0)
1797
- // const stockOut = totalResult.data.filter((product) => product.stock.quantity <= 0)
1798
- // const productIdsStock = mostRelevantProductsIds.filter((product) =>
1799
- // stockData.some((result) => result.id == product),
1800
- // )
1801
- // const productIdsStockOut = mostRelevantProductsIds.filter((product) =>
1802
- // stockOut.some((result) => result.id == product),
1803
- // )
1804
- // const limitedProductId = productIdsStock
1805
- // .concat(productIdsStockOut)
1806
- // .slice(limits.offset, limits.offset + limits.limit)
1807
1792
  const firstProducts = totalResult.data.filter((product) => mostRelevants.includes(product.id));
1808
1793
  const lastProducts = totalResult.data.filter((product) => !mostRelevants.includes(product.id));
1809
1794
  const categoryMostRelevants = firstProducts.concat(lastProducts);
1810
- // const orderedId = mostRelevantProductsIds.filter((product) => limitedProductId.includes(product))
1811
- // console.log('orderedId', orderedId)
1812
- // const productResult = await this.productRepository.findCatalog({
1813
- // filters: {
1814
- // id: { operator: Where.IN, value: orderedId },
1815
- // },
1816
- // })
1817
- // const totalResult = categoryMostRelevants.
1818
- // Pesquisa os most_relevant
1819
- // Valida stock
1820
- // Pesquisa os news
1821
- // Valida stock
1822
- // Junta e faz o slice
1823
- // Valida se não tem repetido
1824
1795
  const resultFinal = categoryMostRelevants.slice(limits.offset, limits.offset + limits.limit);
1825
- console.log('resultFinal', resultFinal);
1826
1796
  return {
1827
1797
  data: resultFinal,
1828
1798
  count: totalResult.count,