From 3ea640350c9a7f3d71dcefd6581e14bfc4755705 Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Thu, 8 Jan 2026 22:03:00 -0500 Subject: [PATCH] Add missing helper functions for workflow execution (addExecutionLog, updateExecutionStatus) --- server.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/server.js b/server.js index 75a657f..5322ee5 100644 --- a/server.js +++ b/server.js @@ -386,6 +386,45 @@ function broadcast(data) { }); } +// Helper function to add log entry to execution +async function addExecutionLog(executionId, logEntry) { + try { + const [execution] = await pool.query('SELECT logs FROM executions WHERE id = ?', [executionId]); + + if (execution.length > 0) { + const logs = typeof execution[0].logs === 'string' ? JSON.parse(execution[0].logs) : execution[0].logs; + logs.push(logEntry); + + await pool.query( + 'UPDATE executions SET logs = ? WHERE id = ?', + [JSON.stringify(logs), executionId] + ); + } + } catch (error) { + console.error(`[Workflow] Error adding execution log:`, error); + } +} + +// Helper function to update execution status +async function updateExecutionStatus(executionId, status) { + try { + await pool.query( + 'UPDATE executions SET status = ?, completed_at = NOW() WHERE id = ?', + [status, executionId] + ); + + broadcast({ + type: 'execution_status', + execution_id: executionId, + status: status + }); + + console.log(`[Workflow] Execution ${executionId} status updated to: ${status}`); + } catch (error) { + console.error(`[Workflow] Error updating execution status:`, error); + } +} + // Authelia SSO Middleware async function authenticateSSO(req, res, next) { // Check for Authelia headers