diff --git a/main.js b/main.js
index b7be94b..a2fd7db 100644
--- a/main.js
+++ b/main.js
@@ -312,6 +312,103 @@ async function updateVersionBadge() {
// ============================================================================
// Identity Management
// ============================================================================
+function getUserUuid() {
+ let uuid = localStorage.getItem('user-uuid');
+ if (!uuid) {
+ uuid = 'user_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);
+ localStorage.setItem('user-uuid', uuid);
+ }
+ return uuid;
+}
+
+// Multi-run progress polling
+async function pollSuiteStatus(suiteId, totalRuns) {
+ const pollInterval = setInterval(async () => {
+ try {
+ const response = await fetch(`/api/suite-status/${suiteId}`);
+ const suite = await response.json();
+
+ // Update progress
+ const progress = (suite.completed_runs / suite.run_count) * 100;
+ document.getElementById('progress-fill').style.width = `${progress}%`;
+ document.getElementById('progress-text').textContent =
+ `Run ${suite.completed_runs} of ${suite.run_count} completed...`;
+
+ // Check if complete
+ if (suite.status === 'completed') {
+ clearInterval(pollInterval);
+ document.getElementById('progress-text').textContent = 'Calculating statistics...';
+
+ // Display multi-run results
+ displayMultiRunResults(suite);
+ document.getElementById('multi-run-progress').style.display = 'none';
+ } else if (suite.status === 'failed') {
+ clearInterval(pollInterval);
+ throw new Error('Some test runs failed');
+ }
+ } catch (error) {
+ clearInterval(pollInterval);
+ console.error('Polling error:', error);
+ document.getElementById('error-msg').textContent = 'Error tracking progress: ' + error.message;
+ document.getElementById('error-msg').style.display = 'block';
+ document.getElementById('multi-run-progress').style.display = 'none';
+ }
+ }, 2000); // Poll every 2 seconds
+}
+
+function displayMultiRunResults(suite) {
+ // Show statistics summary
+ const statsHtml = `
+
+
+
${suite.median_performance_score?.toFixed(0) || 'N/A'}
+
Median Performance
+
+
+
${suite.avg_performance_score?.toFixed(0) || 'N/A'}
+
Average Performance
+
+
+
±${suite.stddev_performance_score?.toFixed(1) || 'N/A'}
+
Std Deviation
+
+
+
+ Individual Runs
+
+
+
+
+ | Run |
+ Performance |
+ LCP (ms) |
+ CLS |
+ TBT (ms) |
+ Actions |
+
+
+
+ ${suite.runs?.map(run => `
+
+ | #${run.run_number} ${run.is_median ? '⭐ Median' : ''} |
+ - |
+ - |
+ - |
+ - |
+
+ View Details
+ |
+
+ `).join('') || '| No run data available |
'}
+
+
+
+ `;
+
+ document.getElementById('results-area').innerHTML = statsHtml;
+ document.getElementById('results-area').style.display = 'block';
+}
+
function getUserUuid() {
let uuid = localStorage.getItem('user_uuid');
if (!uuid) {
diff --git a/migrations/run-migration.sh b/migrations/run-migration.sh
new file mode 100644
index 0000000..2a9a576
--- /dev/null
+++ b/migrations/run-migration.sh
@@ -0,0 +1,56 @@
+#!/bin/bash
+# Database Migration Script for Multi-Run Support
+# Run this on the production server to apply schema changes
+
+set -e # Exit on error
+
+echo "=== Multi-Run Statistics Migration ==="
+echo "Starting database migration..."
+
+# Database connection details
+DB_HOST="202.171.184.108"
+DB_USER="postgres"
+DB_NAME="WebPerformance"
+DB_PORT="5432"
+
+# Get script directory
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+MIGRATION_FILE="$SCRIPT_DIR/001_multi_run_support.sql"
+
+# Check if migration file exists
+if [ ! -f "$MIGRATION_FILE" ]; then
+ echo "Error: Migration file not found: $MIGRATION_FILE"
+ exit 1
+fi
+
+echo "Migration file: $MIGRATION_FILE"
+echo "Target database: $DB_NAME on $DB_HOST"
+echo ""
+read -p "Continue with migration? (yes/no): " confirm
+
+if [ "$confirm" != "yes" ]; then
+ echo "Migration cancelled"
+ exit 0
+fi
+
+# Run migration
+echo "Applying migration..."
+PGPASSWORD='X@gon2005!#$' psql -h "$DB_HOST" -U "$DB_USER" -d "$DB_NAME" -p "$DB_PORT" -f "$MIGRATION_FILE"
+
+if [ $? -eq 0 ]; then
+ echo ""
+ echo "✅ Migration completed successfully!"
+ echo ""
+ echo "New tables/columns created:"
+ echo " - test_suites (new table)"
+ echo " - test_results.suite_id (new column)"
+ echo " - test_results.run_number (new column)"
+ echo " - test_results.is_median (new column)"
+ echo ""
+ echo "You can now deploy the application code."
+else
+ echo ""
+ echo "❌ Migration failed!"
+ echo "Please check the error messages above."
+ exit 1
+fi