diff --git a/check_data.js b/check_data.js index 3ec4241..f6aa349 100644 --- a/check_data.js +++ b/check_data.js @@ -1,8 +1,5 @@ const { Pool } = require('pg'); const config = require('./lib/db-config'); -// Force localhost for server-side check -config.host = 'localhost'; -config.password = 'WebPerfTest2025'; // Ensure password is explicit just in case const pool = new Pool(config); async function checkData() { diff --git a/lib/db-config.template.js b/lib/db-config.template.js new file mode 100644 index 0000000..5b7d8ae --- /dev/null +++ b/lib/db-config.template.js @@ -0,0 +1,11 @@ +// Database Configuration Template +// Copy this file to lib/db-config.js and update with your actual credentials +// NEVER commit lib/db-config.js to Git - it's in .gitignore for security + +module.exports = { + host: 'YOUR_DATABASE_HOST', // e.g., 'localhost' or '172.16.69.219' + user: 'YOUR_DATABASE_USER', // e.g., 'postgres' + password: 'YOUR_DATABASE_PASSWORD', // Database password + database: 'YOUR_DATABASE_NAME', // e.g., 'webperformance' + port: 5432, // Default PostgreSQL port +}; diff --git a/lib/runner.js b/lib/runner.js index 247be0e..e9c52d0 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -264,10 +264,13 @@ async function _executeTest(url, options) { ]; try { + console.log('📝 Attempting DB Insert for Test:', testId); + console.log('👤 User UUID:', options.userUuid); const db = require('../lib/db'); await db.pool.query(insertQuery, values); + console.log('✅ DB Insert Success!'); } catch (dbErr) { - console.error('Failed to save result to DB:', dbErr); + console.error('❌ Failed to save result to DB:', dbErr); // Don't fail the whole test if DB save fails, just log it } diff --git a/test_db_insert.js b/test_db_insert.js index c399313..c982a22 100644 --- a/test_db_insert.js +++ b/test_db_insert.js @@ -1,10 +1,6 @@ const { Pool } = require('pg'); const config = require('./lib/db-config'); -const { v4: uuidv4 } = require('uuid'); - -// Force localhost -config.host = 'localhost'; -config.password = 'WebPerfTest2025'; +const crypto = require('crypto'); const pool = new Pool(config); @@ -13,7 +9,7 @@ async function testInsert() { const client = await pool.connect(); try { - const testId = uuidv4(); + const testId = crypto.randomUUID(); const query = ` INSERT INTO test_results ( id, url, user_uuid, is_mobile,