|
|
@@ -149,6 +149,9 @@ void WebServerService::start() {
|
|
|
// Start workflow scheduler
|
|
|
scheduler_->start();
|
|
|
|
|
|
+ // Ensure the executions summary view exists before serving requests
|
|
|
+ ensureExecutionsSummaryView();
|
|
|
+
|
|
|
// Load active workflows from database and register with scheduler
|
|
|
loadScheduledWorkflows();
|
|
|
|
|
|
@@ -232,6 +235,30 @@ void WebServerService::setupRoutes() {
|
|
|
LOG_INFO("API routes registered");
|
|
|
}
|
|
|
|
|
|
+void WebServerService::ensureExecutionsSummaryView() {
|
|
|
+ // View names are namespaced per project from smartbotic-database 2.4.2, so a
|
|
|
+ // view created by this client is also queryable by it. Earlier versions
|
|
|
+ // registered the name unqualified while queries were project-prefixed, which
|
|
|
+ // made the view unreachable.
|
|
|
+ for (const auto& view : storage_->listViews()) {
|
|
|
+ if (view.name == kExecutionsSummaryView) {
|
|
|
+ LOG_DEBUG("Executions summary view already present");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ auto result = storage_->createView(kExecutionsSummaryView, "executions",
|
|
|
+ {"workflowId", "workflowName", "status", "triggerType",
|
|
|
+ "startedAt", "finishedAt", "error", "runnerId"});
|
|
|
+ if (result.failed()) {
|
|
|
+ LOG_ERROR("Could not create the executions summary view: {}. The executions "
|
|
|
+ "listing will fail until this is resolved.", result.error().message());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ LOG_INFO("Created server-side view '{}' over executions", kExecutionsSummaryView);
|
|
|
+}
|
|
|
+
|
|
|
void WebServerService::loadScheduledWorkflows() {
|
|
|
LOG_INFO("Loading scheduled workflows from database...");
|
|
|
|