mirror of
https://github.com/samsonjs/spirit-tracker.git
synced 2026-04-27 15:07:43 +00:00
fix: SKU map tool
This commit is contained in:
parent
af6d268560
commit
d291cc1492
1 changed files with 8 additions and 2 deletions
|
|
@ -37,11 +37,12 @@ let prunedAuto = 0;
|
||||||
let prunedDup = 0;
|
let prunedDup = 0;
|
||||||
|
|
||||||
const seen = new Set(); // dedupe after normalization
|
const seen = new Set(); // dedupe after normalization
|
||||||
|
|
||||||
const nextLinks = [];
|
const nextLinks = [];
|
||||||
|
|
||||||
for (const x of Array.isArray(linksData.links) ? linksData.links : []) {
|
for (const x of Array.isArray(linksData.links) ? linksData.links : []) {
|
||||||
const a = normalizeImplicitSkuKey(x?.fromSku);
|
const a = normalizeImplicitSkuKey(x?.fromSku);
|
||||||
const b = normalizeImplicitSkuKey(x?.toSku);
|
const b = normalizeImplicitSkuKey(x?.toSku);
|
||||||
|
|
||||||
if (!a || !b) {
|
if (!a || !b) {
|
||||||
prunedMissing++;
|
prunedMissing++;
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -67,7 +68,12 @@ for (const x of Array.isArray(linksData.links) ? linksData.links : []) {
|
||||||
}
|
}
|
||||||
seen.add(key);
|
seen.add(key);
|
||||||
|
|
||||||
nextLinks.push({ fromSku: a, toSku: b });
|
// preserve datestamps/metadata; just normalize the SKUs
|
||||||
|
nextLinks.push({
|
||||||
|
...x,
|
||||||
|
fromSku: a,
|
||||||
|
toSku: b,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
linksData.links = nextLinks;
|
linksData.links = nextLinks;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue