From f6324faf912eeea608892339174f271fae7f2394 Mon Sep 17 00:00:00 2001 From: ImBenji Date: Thu, 23 Apr 2026 17:35:28 +0100 Subject: [PATCH] add worker event tracking; implement worker rates display in admin panel --- intelligence/db.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/intelligence/db.js b/intelligence/db.js index f6c5e91..83e125b 100644 --- a/intelligence/db.js +++ b/intelligence/db.js @@ -125,8 +125,9 @@ function runColumnMigrations(db) { } function seedCompanies(db) { + const exists = db.prepare("SELECT id FROM tracked_companies WHERE name = ?"); const insert = db.prepare( - "INSERT OR IGNORE INTO tracked_companies (name, ticker, aliases) VALUES (?, ?, ?)" + "INSERT INTO tracked_companies (name, ticker, aliases) VALUES (?, ?, ?)" ); const companies = [ @@ -295,11 +296,15 @@ function seedCompanies(db) { { name: "Deloitte", ticker: "DELOITTE", aliases: [] }, ]; + let added = 0; for (const c of companies) { - insert.run(c.name, c.ticker, JSON.stringify(c.aliases)); + if (!exists.get(c.name)) { + insert.run(c.name, c.ticker, JSON.stringify(c.aliases)); + added++; + } } - console.log(`[db] seeded ${companies.length} tracked companies`); + if (added > 0) console.log(`[db] seeded ${added} new tracked companies`); } module.exports = { getArchiveDb, getIntelligenceDb, runMigrations, runColumnMigrations, seedCompanies };