Skip to content

Commit add4d15

Browse files
authored
feat(sql): add view on run nodes (#5108)
1 parent 10bc9a3 commit add4d15

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

engine/sql/196_sql_jobs_view.sql

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
-- +migrate Up
2+
CREATE VIEW view_node_run_job AS
3+
SELECT
4+
jobs->>'id' as "id",
5+
jobs->>'workflow_node_run_id' as "workflow_node_run_id",
6+
jobs->>'status' as "status",
7+
cast(jobs->>'start' as timestamp with time zone) as "started",
8+
cast(jobs->>'queued' as timestamp with time zone) as "queued" ,
9+
cast(jobs->>'done' as timestamp with time zone) as "done",
10+
jobs->>'retry' as "retry",
11+
jobs->>'model' as "model",
12+
jobs->>'worker_name' as "worker",
13+
jobs->>'hatchery_name' as "hatchery"
14+
FROM (
15+
SELECT
16+
jsonb_array_elements(
17+
CASE jsonb_typeof(stages->'run_jobs')
18+
WHEN 'array' THEN stages->'run_jobs'
19+
ELSE '[]' END
20+
) jobs
21+
FROM (
22+
SELECT
23+
jsonb_array_elements(
24+
CASE jsonb_typeof(stages)
25+
WHEN 'array' THEN stages
26+
ELSE '[]' END
27+
) stages
28+
FROM workflow_node_run
29+
) tmpStages
30+
) tmpJobs
31+
order by started desc;
32+
33+
-- +migrate Down
34+
DROP VIEW view_node_run_job;

0 commit comments

Comments
 (0)