const { getDb } = require("../config/db"); const { nowIso } = require("../utils/time"); function metric(jobId, name, value, unit = null) { getDb().prepare("INSERT INTO metrics (job_id, name, value, unit, created_at) VALUES (?, ?, ?, ?, ?)") .run(jobId, name, value, unit, nowIso()); } function listMetrics(limit = 200) { return getDb().prepare("SELECT * FROM metrics ORDER BY id DESC LIMIT ?").all(limit); } module.exports = { metric, listMetrics };