@infrab4a/connect 4.16.1-beta.4 → 4.16.2-beta.1
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/index.cjs.js +21 -4
- package/index.esm.js +21 -4
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -4952,7 +4952,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4952
4952
|
const mostRelevants = category.getMostRelevantByShop(shop);
|
|
4953
4953
|
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))];
|
|
4954
4954
|
const products = [];
|
|
4955
|
-
const { data: productsData } = await this.productRepository.
|
|
4955
|
+
const { data: productsData } = await this.productRepository.findCatalog({
|
|
4956
|
+
filters: {
|
|
4957
|
+
id: { operator: exports.Where.IN, value: mostRelevantProductsIds },
|
|
4958
|
+
published: true,
|
|
4959
|
+
},
|
|
4960
|
+
fields: [
|
|
4956
4961
|
'id',
|
|
4957
4962
|
'name',
|
|
4958
4963
|
'slug',
|
|
@@ -4978,13 +4983,25 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4978
4983
|
'shoppingCount',
|
|
4979
4984
|
'gender',
|
|
4980
4985
|
'createdAt',
|
|
4981
|
-
]
|
|
4986
|
+
],
|
|
4987
|
+
options: { enableCount: false },
|
|
4988
|
+
orderBy: {
|
|
4982
4989
|
shoppingCount: 'desc',
|
|
4983
4990
|
rate: 'desc',
|
|
4984
4991
|
stock: 'desc',
|
|
4985
4992
|
name: 'asc',
|
|
4986
|
-
}
|
|
4987
|
-
|
|
4993
|
+
},
|
|
4994
|
+
}, shop === exports.Shops.MENSMARKET ? 'male' : 'female');
|
|
4995
|
+
const mostRelevantWithouyStock = productsData.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
|
|
4996
|
+
const firstProducts = productsData
|
|
4997
|
+
.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
|
|
4998
|
+
.sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id));
|
|
4999
|
+
const lastProducts = productsData
|
|
5000
|
+
.filter((product) => !mostRelevants.includes(product.id) && product.stock.quantity > 0)
|
|
5001
|
+
.concat(mostRelevantWithouyStock);
|
|
5002
|
+
const categoryMostRelevants = firstProducts.concat(lastProducts);
|
|
5003
|
+
const resultFinal = categoryMostRelevants.slice(0, options.limit);
|
|
5004
|
+
products.push(...resultFinal);
|
|
4988
5005
|
return products;
|
|
4989
5006
|
}
|
|
4990
5007
|
async getChildren(parentId) {
|
package/index.esm.js
CHANGED
|
@@ -4946,7 +4946,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4946
4946
|
const mostRelevants = category.getMostRelevantByShop(shop);
|
|
4947
4947
|
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))];
|
|
4948
4948
|
const products = [];
|
|
4949
|
-
const { data: productsData } = await this.productRepository.
|
|
4949
|
+
const { data: productsData } = await this.productRepository.findCatalog({
|
|
4950
|
+
filters: {
|
|
4951
|
+
id: { operator: Where.IN, value: mostRelevantProductsIds },
|
|
4952
|
+
published: true,
|
|
4953
|
+
},
|
|
4954
|
+
fields: [
|
|
4950
4955
|
'id',
|
|
4951
4956
|
'name',
|
|
4952
4957
|
'slug',
|
|
@@ -4972,13 +4977,25 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4972
4977
|
'shoppingCount',
|
|
4973
4978
|
'gender',
|
|
4974
4979
|
'createdAt',
|
|
4975
|
-
]
|
|
4980
|
+
],
|
|
4981
|
+
options: { enableCount: false },
|
|
4982
|
+
orderBy: {
|
|
4976
4983
|
shoppingCount: 'desc',
|
|
4977
4984
|
rate: 'desc',
|
|
4978
4985
|
stock: 'desc',
|
|
4979
4986
|
name: 'asc',
|
|
4980
|
-
}
|
|
4981
|
-
|
|
4987
|
+
},
|
|
4988
|
+
}, shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
4989
|
+
const mostRelevantWithouyStock = productsData.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
|
|
4990
|
+
const firstProducts = productsData
|
|
4991
|
+
.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
|
|
4992
|
+
.sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id));
|
|
4993
|
+
const lastProducts = productsData
|
|
4994
|
+
.filter((product) => !mostRelevants.includes(product.id) && product.stock.quantity > 0)
|
|
4995
|
+
.concat(mostRelevantWithouyStock);
|
|
4996
|
+
const categoryMostRelevants = firstProducts.concat(lastProducts);
|
|
4997
|
+
const resultFinal = categoryMostRelevants.slice(0, options.limit);
|
|
4998
|
+
products.push(...resultFinal);
|
|
4982
4999
|
return products;
|
|
4983
5000
|
}
|
|
4984
5001
|
async getChildren(parentId) {
|