From: xangelo Date: Mon, 5 Jun 2023 14:34:25 +0000 (-0400) Subject: add stats to building inventory X-Git-Tag: v0.0.1~67 X-Git-Url: https://git.xangelo.ca/?a=commitdiff_plain;h=6dc895f3fedf6fc4bb19dc4dd1025042aa31e8e0;p=risinglegends.git add stats to building inventory --- 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); };