mirror of
https://github.com/DeNNiiInc/Web-Page-Performance-Test.git
synced 2026-04-17 20:05:58 +00:00
Fix: Add missing DB insert query in runner.js
This commit is contained in:
@@ -240,6 +240,29 @@ 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 (
|
||||
id, url, user_uuid, is_mobile,
|
||||
scores, metrics, filmstrip, timestamp
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, NOW())
|
||||
RETURNING id
|
||||
`;
|
||||
|
||||
// Convert objects to JSON strings for DB text columns if needed,
|
||||
// or rely on pg to stringify objects for JSONB columns if schema uses JSONB.
|
||||
// Based on previous errors, schema might be expecting JSON.
|
||||
|
||||
const values = [
|
||||
testId,
|
||||
lhr.finalUrl,
|
||||
options.userUuid || null, // Ensure options is available or pass it in
|
||||
isMobile,
|
||||
JSON.stringify(summary.scores),
|
||||
JSON.stringify(summary.metrics),
|
||||
JSON.stringify(filmstripData)
|
||||
];
|
||||
|
||||
try {
|
||||
const db = require('../lib/db');
|
||||
await db.pool.query(insertQuery, values);
|
||||
|
||||
Reference in New Issue
Block a user