add event_date column to event_knowledge and event_predictions tables; update related logic in admin panel and augorWorker

This commit is contained in:
ImBenji
2026-04-23 13:13:28 +01:00
parent d972569e54
commit 29c6cdc6c3
8 changed files with 400 additions and 17 deletions
+7 -3
View File
@@ -261,14 +261,16 @@ async function adminRoutes(fastify) {
if (type) { conditions.push('ek.type = ?'); params.push(type); }
const where = conditions.length ? `WHERE ${conditions.join(' AND ')}` : '';
const sortCol = q.sort === 'event_date' ? 'ek.event_date' : 'ek.id';
const total = db.prepare(`SELECT COUNT(*) as n FROM event_knowledge ek ${where}`).get(...params).n;
const rows = db.prepare(`
SELECT ek.id, ek.event_id, ek.type, ek.data, ek.created_at,
SELECT ek.id, ek.event_id, ek.type, ek.data, ek.event_date, ek.created_at,
tc.name as company_name
FROM event_knowledge ek
JOIN tracked_companies tc ON tc.id = ek.company_id
${where}
ORDER BY ek.id DESC
ORDER BY ${sortCol} DESC
LIMIT ? OFFSET ?
`).all(...params, limit, offset);
@@ -290,13 +292,15 @@ async function adminRoutes(fastify) {
if (companyId) { conditions.push('ep.company_id = ?'); params.push(companyId); }
const where = conditions.length ? `WHERE ${conditions.join(' AND ')}` : '';
const sortCol = q.sort === 'event_date' ? 'ep.event_date' : 'ep.id';
const total = db.prepare(`SELECT COUNT(*) as n FROM event_predictions ep ${where}`).get(...params).n;
const rows = db.prepare(`
SELECT ep.*, tc.name as company_name
FROM event_predictions ep
JOIN tracked_companies tc ON tc.id = ep.company_id
${where}
ORDER BY ep.id DESC
ORDER BY ${sortCol} DESC
LIMIT ? OFFSET ?
`).all(...params, limit, offset);