@brandboostinggmbh/observable-workflows 0.16.2 → 0.16.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +23 -12
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -477,6 +477,7 @@ declare const createLogAccessor: (context: {
|
|
|
477
477
|
workflowType: string;
|
|
478
478
|
workflowCount: number;
|
|
479
479
|
workflowTotalWallTimeMilis: number;
|
|
480
|
+
workflowAverageWallTimeMilis: number;
|
|
480
481
|
incompleteWorkflowCount: number;
|
|
481
482
|
successfulWorkflowCount: number;
|
|
482
483
|
failedWorkflowCount: number;
|
package/dist/index.js
CHANGED
|
@@ -244,9 +244,11 @@ async function createIndexes(db) {
|
|
|
244
244
|
await db.prepare(`CREATE INDEX IF NOT EXISTS idx_steps_instance_id ON StepTable (instanceId)`).run();
|
|
245
245
|
await db.prepare(`CREATE INDEX IF NOT EXISTS idx_steps_tenant_id ON StepTable (tenantId)`).run();
|
|
246
246
|
await db.prepare(`CREATE INDEX IF NOT EXISTS idx_steps_start_time ON StepTable (startTime)`).run();
|
|
247
|
+
await db.prepare(`CREATE INDEX IF NOT EXISTS idx_steps_instance_starttime ON StepTable (instanceId, startTime)`).run();
|
|
247
248
|
await db.prepare(`CREATE INDEX IF NOT EXISTS idx_logs_instance_id ON LogTable (instanceId)`).run();
|
|
248
249
|
await db.prepare(`CREATE INDEX IF NOT EXISTS idx_logs_tenant_id ON LogTable (tenantId)`).run();
|
|
249
250
|
await db.prepare(`CREATE INDEX IF NOT EXISTS idx_workflow_properties_tenant_id ON WorkflowProperties (tenantId)`).run();
|
|
251
|
+
await db.prepare(`CREATE INDEX IF NOT EXISTS idx_workflow_properties_tenant_key ON WorkflowProperties (tenantId, key, valueType)`).run();
|
|
250
252
|
}
|
|
251
253
|
/**
|
|
252
254
|
* Main migration function that ensures all tables exist and are up-to-date.
|
|
@@ -726,18 +728,19 @@ const createLogAccessor = (context) => {
|
|
|
726
728
|
}
|
|
727
729
|
if (populateData === void 0) populateData = false;
|
|
728
730
|
let result;
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
731
|
+
const bindings = [];
|
|
732
|
+
const whereConditions = [];
|
|
733
|
+
whereConditions.push("tenantId = ?");
|
|
734
|
+
bindings.push(context.tenantId);
|
|
735
|
+
if (actualInstanceId) {
|
|
736
|
+
whereConditions.push("instanceId = ?");
|
|
737
|
+
bindings.push(actualInstanceId);
|
|
738
|
+
}
|
|
739
|
+
const whereClause = `WHERE ${whereConditions.join(" AND ")}`;
|
|
740
|
+
const limitClause = limit !== void 0 && actualOffset !== void 0 ? "LIMIT ? OFFSET ?" : "";
|
|
741
|
+
const sql = `SELECT * FROM StepTable ${whereClause} ORDER BY startTime ASC ${limitClause}`;
|
|
742
|
+
if (limit !== void 0 && actualOffset !== void 0) bindings.push(limit, actualOffset);
|
|
743
|
+
result = await context.D1.prepare(sql).bind(...bindings).all();
|
|
741
744
|
if (result.results) {
|
|
742
745
|
const steps = await Promise.all(result.results.map(async (row) => {
|
|
743
746
|
let deserializedResult = null;
|
|
@@ -950,6 +953,13 @@ const createLogAccessor = (context) => {
|
|
|
950
953
|
ELSE 0
|
|
951
954
|
END
|
|
952
955
|
) as workflowTotalWallTimeMilis,
|
|
956
|
+
AVG(
|
|
957
|
+
CASE
|
|
958
|
+
WHEN endTime IS NOT NULL AND startTime IS NOT NULL
|
|
959
|
+
THEN (endTime - startTime)
|
|
960
|
+
ELSE NULL
|
|
961
|
+
END
|
|
962
|
+
) as workflowAverageWallTimeMilis,
|
|
953
963
|
SUM(
|
|
954
964
|
CASE
|
|
955
965
|
WHEN startTime IS NOT NULL AND endTime IS NULL
|
|
@@ -982,6 +992,7 @@ const createLogAccessor = (context) => {
|
|
|
982
992
|
workflowType: row.workflowType,
|
|
983
993
|
workflowCount: row.workflowCount,
|
|
984
994
|
workflowTotalWallTimeMilis: row.workflowTotalWallTimeMilis || 0,
|
|
995
|
+
workflowAverageWallTimeMilis: row.workflowAverageWallTimeMilis || 0,
|
|
985
996
|
incompleteWorkflowCount: row.incompleteWorkflowCount || 0,
|
|
986
997
|
successfulWorkflowCount: row.successfulWorkflowCount || 0,
|
|
987
998
|
failedWorkflowCount: row.failedWorkflowCount || 0
|