Add missing helper functions for workflow execution (addExecutionLog, updateExecutionStatus)
This commit is contained in:
39
server.js
39
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
|
// Authelia SSO Middleware
|
||||||
async function authenticateSSO(req, res, next) {
|
async function authenticateSSO(req, res, next) {
|
||||||
// Check for Authelia headers
|
// Check for Authelia headers
|
||||||
|
|||||||
Reference in New Issue
Block a user