bench
This commit is contained in:
@@ -283,22 +283,17 @@ export default function importRows(provider) {
|
||||
const father = await runner.query(articleQueries.GET_ID_BY_SKU, { sku: fatherSku });
|
||||
const fatherId = father.rows[0]?.articleId;
|
||||
if (fatherId && fatherId !== childId) {
|
||||
await runner.query(articleQueries.UPDATE_FATHER_BY_SKU, {
|
||||
sku,
|
||||
fatherArticleId: fatherId,
|
||||
});
|
||||
await runner.query(articleQueries.SET_IS_FATHER, {
|
||||
articleId: fatherId,
|
||||
});
|
||||
const childCount = await runner.query(getChildCountSql, {
|
||||
articleId: fatherId,
|
||||
});
|
||||
const count = childCount.rows[0].count;
|
||||
// The child's sort is its 0-based position among the father's children.
|
||||
await runner.query(articleQueries.SET_FATHER_SORT, {
|
||||
articleId: childId,
|
||||
await runner.query(articleQueries.UPDATE_FATHER_BY_SKU, {
|
||||
sku,
|
||||
fatherArticleId: fatherId,
|
||||
fathersort: count - 1,
|
||||
fathersort: count,
|
||||
});
|
||||
await runner.query(articleQueries.SET_IS_FATHER, {
|
||||
articleId: fatherId,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,25 +53,19 @@ export default function setFatherBySku(provider) {
|
||||
throw new Error('Invalid father');
|
||||
}
|
||||
|
||||
await runner.query(queries.UPDATE_FATHER_BY_SKU, {
|
||||
sku,
|
||||
fatherArticleId: fatherId,
|
||||
});
|
||||
|
||||
await runner.query(queries.SET_IS_FATHER, {
|
||||
articleId: fatherId,
|
||||
});
|
||||
|
||||
const childCount = await runner.query(getChildCountSql, {
|
||||
articleId: fatherId,
|
||||
});
|
||||
const count = childCount.rows[0].count;
|
||||
|
||||
// The child's sort is its 0-based position among the father's children.
|
||||
await runner.query(queries.SET_FATHER_SORT, {
|
||||
articleId,
|
||||
await runner.query(queries.UPDATE_FATHER_BY_SKU, {
|
||||
sku,
|
||||
fatherArticleId: fatherId,
|
||||
fathersort: count - 1,
|
||||
fathersort: count,
|
||||
});
|
||||
|
||||
await runner.query(queries.SET_IS_FATHER, {
|
||||
articleId: fatherId,
|
||||
});
|
||||
|
||||
const article = await load(articleId, languageId, runner);
|
||||
|
||||
Reference in New Issue
Block a user