From 6dc895f3fedf6fc4bb19dc4dd1025042aa31e8e0 Mon Sep 17 00:00:00 2001 From: xangelo Date: Mon, 5 Jun 2023 10:34:25 -0400 Subject: [PATCH] add stats to building inventory --- seeds/shop_items.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/seeds/shop_items.ts b/seeds/shop_items.ts index 9719634..9c8efb6 100644 --- a/seeds/shop_items.ts +++ b/seeds/shop_items.ts @@ -14,13 +14,18 @@ export async function seed(knex: Knex): Promise { await knex("inventory").del(); const data = await read(join(__dirname, '..', 'data', 'inventory.csv'), 'utf8'); + const stats = { + created: 0, + skipped: 0 + }; const items: Omit[] = []; data.split("\r\n").slice(1).forEach(line => { let pieces = line.split(','); - if(pieces.length === 17) { + if(pieces.length === 17 && pieces[0].length) { console.log('Adding', pieces[0]); + stats.created++; items.push({ name: pieces[0], type: pieces[1] as InventoryType, @@ -44,9 +49,10 @@ export async function seed(knex: Knex): Promise { }); } else { - console.log(`Skipped ${line}`); + stats.skipped++; } }); await knex('shop_items').insert(items); + console.log(stats); }; -- 2.25.1