diff --git a/lib/runner.js b/lib/runner.js index 884e707..0ed0f00 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -240,6 +240,28 @@ async function _executeTest(url, options) { const jsonPath = path.join(reportDir, `${testId}.json`); fs.writeFileSync(jsonPath, JSON.stringify(summary, null, 2)); + // Prepare Database Insert + const insertQuery = ` + INSERT INTO test_results ( + test_id, user_uuid, user_ip, url, is_mobile, + scores, metrics, filmstrip, summary, suite_id, run_number, timestamp + ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, NOW()) + RETURNING id + `; + + const values = [ + testId, + options.userUuid || null, + options.userIp || null, + lhr.finalUrl, + isMobile, + summary.scores, + summary.metrics, + filmstripData, + summary, + options.suiteId || null, + options.runNumber || 1 + ]; try { const db = require('../lib/db'); await db.pool.query(insertQuery, values);