[bugfix] correct sku relation to cards

This commit is contained in:
2026-04-08 15:38:56 -04:00
parent 3b4f98e556
commit 6811c4c249
2 changed files with 7 additions and 4 deletions

View File

@@ -234,4 +234,7 @@ where not exists (select 1 from cards where product_id=t.product_id and variant=
`);
console.log(`Inserted ${inserts.rowCount} rows into cards table`);
const skuUpdates = await db.execute(sql`update skus s set card_id = c.card_id from cards c where s.product_id = c.product_id and s.variant = c.variant and s.card_id is distinct from c.card_id`);
console.log(`Updated ${skuUpdates.rowCount} rows in skus table`);
}

View File

@@ -204,9 +204,9 @@ async function syncProductLine(productLine: string, field: string, fieldValue: s
},
});
console.log(`item: ${item.setId}\tdetail: ${detailData.setId}`);
console.log(`item: ${item.setCode}\tdetail: ${detailData.setCode}`);
console.log(`item: ${item.setName}\tdetail: ${detailData.setName}`);
// console.log(`item: ${item.setId}\tdetail: ${detailData.setId}`);
// console.log(`item: ${item.setCode}\tdetail: ${detailData.setCode}`);
// console.log(`item: ${item.setName}\tdetail: ${detailData.setName}`);
// set is...
await db.insert(schema.sets).values({
setId: detailData.setId,
@@ -242,7 +242,7 @@ async function syncProductLine(productLine: string, field: string, fieldValue: s
}
// get image if it doesn't already exist
const imagePath = path.join(process.cwd(), 'public', 'cards', `${item.productId}.jpg`);
const imagePath = path.join(process.cwd(), 'static', 'cards', `${item.productId}.jpg`);
if (!await helper.FileExists(imagePath)) {
const imageResponse = await fetch(`https://tcgplayer-cdn.tcgplayer.com/product/${item.productId}_in_1000x1000.jpg`);
if (imageResponse.ok) {